Hi, I have a problem with a class I wrote where I have a list as an attribute of the class. When I append something to that list, it stays there at first, but only until I restart Zope. It disappears (==is set to the value I assigned to it in __init__) and reappears as well when I hit reload a few times very quickly. Whenever I flush the cache it disappears immediately. There seems to be no transaction registered by Zope, because it doesn't show up under 'Undo'. I observed this both thru a dtml page and a debugging function written in python. I attached the code below, the method and attributes I'm talking about are IEEShare.read_access_roles, IEEShare.write_access_roles and IEEShare.add_user_access() The problem exists with both Zope 2.2.0 and 2.2.1b1. I'm running 2.2.1b1 right now on a SuSE Linux 6.4 default installation. (standard libc, threads etc.) Both versions of Zope are compiled from source.
__doc__ = """IEEFolder product module.""" __version__ = '0.1' import string from Globals import HTMLFile,MessageDialog,Persistent import OFS.Folder import OFS.PropertyManager import Acquisition import AccessControl from AccessControl import getSecurityManager manage_addIEEFolderForm = HTMLFile('ieefolderAdd', globals()) def manage_addIEEFolder(self, id, title=None, REQUEST=None): """Add an IEE Folder to a folder.""" ob=IEEFolder() ob.id=str(id) if title: ob.title=title self._setObject(id, ob) if REQUEST is not None: return self.manage_main(self, REQUEST, update_menu=1) def findProperty(ids, props, searchterm, path='', all=0): """Find a property """ result=[] checkPermission=getSecurityManager().checkPermission for obj in ids: if hasattr(obj, '_properties') and checkPermission('Access contents information', obj): for md in getattr(obj, '_properties'): propid=md['id'] if (all or (propid in props)) and \ (string.find(str(getattr(obj, propid)),searchterm) != -1): result.append({'object': obj, 'id': path + obj.id, 'url': obj.absolute_url()}) if getattr(obj, 'isPrincipiaFolderish', None): result.extend(findProperty(obj.objectValues(), props, searchterm, \ path=path+obj.id+'.', all=all)) return result class IEEFolder(OFS.Folder.Folder, Persistent, Acquisition.Implicit, AccessControl.Role.RoleManager, OFS.PropertyManager.PropertyManager ): meta_type = 'IEE Folder' __ac_permissions__=( ('Read Access', ('manage_findPropertyForm', 'manage_findProperty', 'index_html', 'manage_main', 'manage_workspace', 'objectIds', 'objectValues', 'objectItems', '')), ('Write Access', ('manage_delObjects',))) manage_workspace__roles__=('Read Access','Write Access') manage_options = ( {'label': 'Folder View', 'action': 'index_html', 'image': 'folder-view'}, {'label': 'Search', 'action': 'manage_findPropertyForm', 'image': 'search'}, {'label': 'Undo', 'action': 'manage_UndoForm', 'image': 'undo'}) index_html = HTMLFile('index', globals()) manage_main = HTMLFile('index', globals()) manage_findPropertyForm=HTMLFile('findProperty', globals()) findPropertyResult=HTMLFile('findPropertyResult', globals()) manage_UndoForm=HTMLFile('undo', globals()) def filtered_objectIds(self): map(lambda x: x.id, filter(lambda x: getSecurityManager().checkPermission('Read Access', x), self.objectValues())) def manage_findProperty(self, searchterm, props=[], allprops='all'): """Find a property.""" if type(props) is type(''): props=[props] if allprops == 'all': allprops = 1 else: allprops = 0 return self.findPropertyResult(self, result=findProperty(self.objectValues(), props, searchterm, all=allprops), URL=self.absolute_url())
__doc__ = """IEEShare product module.""" __version__ = '0.1' import nis,traceback from Globals import HTMLFile,MessageDialog,Persistent from Products.CARS.IEEFolder import IEEFolder from Products.CARS.NisLogin import NisLogin from Products.LoginManager.LoginManager import manage_addLoginManager from Globals import HTMLFile manage_addIEEShareForm = HTMLFile('ieeshareAdd', globals()) def manage_addIEEShare(self, id, title=None, REQUEST=None): """Add an IEE Share to a folder.""" ob=IEEShare() ob.id=str(id) ob.title=title self._setObject(id, ob) ob=self._getOb(id) ob.manage_role('Read Access', permissions=('Read Access',)) ob.manage_role('Write Access', permissions=('Write Access',)) # manage_addLoginManager(ob, usource='NIS User Source') if REQUEST is not None: return self.manage_main(self, REQUEST, update_menu=1) class IEEShare(IEEFolder.IEEFolder): meta_type = 'IEE Share' read_access_roles=None write_access_roles=None def __init__(self): self.read_access_roles=[] self.write_access_roles=[] def add_user_access(self, user, lst, access='Some'): try: nis.match(user, 'passwd.byname') except nis.error: return MessageDialog( title = 'Error!', message = '%s: No such user' % user, action = 'manage_main') if user in lst: return MessageDialog( title = 'Error!', message = 'User %s already has %s access.' % (access, user), action = 'manage_main') lst.append(str(user)) get_transaction().commit() return MessageDialog( title = 'Success!', message = '%s access for %s has been successfully added.' \ % (access, user), action = 'manage_main') def manage_addReadAccess(self, user, REQUEST=None): """foo""" return self.add_user_access(user, self.read_access_roles, access='Read') def manage_addWriteAccess(self, user, REQUEST=None): """bar""" return self.add_user_access(user, self.write_access_roles, access='Write') manage_addReadAccessForm=HTMLFile('addAccessForm', globals(), type='Read') manage_addWriteAccessForm=HTMLFile('addAccessForm', globals(), type='Write') manage_showAccessForm=HTMLFile('showAccessForm', globals())