Re: [Zope-dev] aq_inContextOf/can anyone explain this zmonitor log?
On Mon, Aug 21, 2000 at 04:21:33PM +0100, Toby Dickenson wrote: On Mon, 21 Aug 2000 16:03:38 +0200, Bob Pepin [EMAIL PROTECTED] wrote: Yeah, this is a good one. Theres some debate in the Collector about whether this is actually a bug or not. In short, aq_inContextOf checks for nested aquisition contexts. It does *not* check for nested objects. It will return zero if you pass it parallel acquisition contexts, even if the objects are indeed nested. Here is the full story, and a patch to get it to work the other way. http://classic.zope.org:8080/Collector/1066/view (This patch used to work, but ive not used it since it was submitted) hmm... shouldn't either User.BasicUser.allowed() or aq_inContextOf be modified then, since the intent in allowed() doesn't seem to be to check for nested contexts? ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
[Zope-dev] aq_inContextOf/can anyone explain this zmonitor log?
Hi, I just experienced some very weird behaviour from aq_inContextOf while I was trying to get Cut and Paste to work (I had to trace to the whole security stuff to do this, and read the C source for the acquisition stuff the figure out what aq_inContextOf does of course... thanks for having such a great, consistent, mature and well-documented design Zope-guys...) oh, btw, Copy Paste seems to work only for objects that have their User Source at the / level because of the behaviour of inContextOf. well, here's the log: Python 1.5.2 (#5, Aug 10 2000, 15:45:20) [GCC 2.95.2 19991024 (release)] Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam Welcome to secure_monitor_channel connected 127.0.0.1:2625 at 859f680 import Zope import Zope app=Zope.app() app=Zope.app() iee=app.iee iee=app.iee doc1=app.iee.doc1 doc1=app.iee.doc1 doc1.aq_inContextOf(iee) doc1.aq_inContextOf(iee) 0 doc1.aq_inContextOf(app) doc1.aq_inContextOf(app) 1 doc1.aq_inContextOf(app.iee) doc1.aq_inContextOf(app.iee) 0 iee.doc1.aq_inContextOf(app.iee) iee.doc1.aq_inContextOf(app.iee) 0 iee.doc1.aq_inContextOf(iee) iee.doc1.aq_inContextOf(iee) 1 app.iee.doc1.aq_inContextOf(iee) app.iee.doc1.aq_inContextOf(iee) 0 app.iee.doc1.aq_inContextOf(app.iee) app.iee.doc1.aq_inContextOf(app.iee) 0 doc1.aq_inContextOf(iee) doc1.aq_inContextOf(iee) 0 doc1=iee.doc1 doc1=iee.doc1 doc1.aq_inContextOf(iee) doc1.aq_inContextOf(iee) 1 doc1.aq_inContextOf(app.iee) doc1.aq_inContextOf(app.iee) 0 doc1=app.iee.doc1 doc1=app.iee.doc1 doc1.aq_inContextOf(app.iee) doc1.aq_inContextOf(app.iee) ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Caching problems
On Wed, Aug 16, 2000 at 05:31:29PM +0100, Carlos Neves wrote: You directly change a nonpersistence participant object. As stated in http://www.python.org/workshops/2000-01/proceedings/papers/fulton/zodb3.html : [...] but mainly... RTFM ;-) Well, thanks, but too bad the only FM I've been able to find about Zope are those .py files in lib/python/... I spent a whole day looking for documentation on ZODB internals on zope.org and zdp.zope.org, without being able to find anything... how about adding that paper to the search engine on zope.org? Is there more documentation like that one out there? ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
[Zope-dev] Caching problems
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
[Zope-dev] ZPatterns, Transactions, _register/_unregister
Hi, I've encountered some weird behaviour in the ZPatterns Transactional class when I was trying to write a User Source for the Login Manager Product. I'm using Zope 2.2.0 with LoginManager 0.8.7a1 and ZPatterns 0.4.1snap1 The problem is that _unregister seems to be trying to delete the _v_registered attribute of an object that doesn't have it set whenever I return None from authenticateUser(). The weird thing is that the object seems to be _register()ed and _v_registered appears to be set to 1 in _register(), but when _unregister() is called it has the value 'None' again. I've attached my code that's trying to implement the UserSource. here is what my modified _register and _unregister functions look like: def _register(self): f=open('/tmp/zopelog', 'a', 0) f.write('Register %s(%s)\n' % (self.id, str(self))) f.write('Before: %s._v_registered=%s\n' % (self.id, getattr(self, '_v_registered', 'N/A'))) for i in traceback.format_stack(): f.write(i) if self._v_registered: return get_transaction().register(Reporter(self)) self._v_registered = 1 f.write('After: %s._v_registered=%s\n' % (self.id, getattr(self, '_v_registered', 'N/A'))) f.close() def _unregister(self): f=open('/tmp/zopelog', 'a', 0) f.write('Unregister %s(%s)\nBefore: %s._v_registered=%s\n' \ % (self.id, str(self), self.id, getattr(self, '_v_registered', 'N/A'))) f.close() del self._v_registered and this is a sample log: Register UserSource(NisUserSource instance at 85ab2e8) Before: UserSource._v_registered=None File "/home/picard/bpe/Zope-2.2.0-src/ZServer/PubCore/ZServerPublisher.py", line 95, in __init__ response=response) File "/home/picard/bpe/Zope-2.2.0-src/lib/python/ZPublisher/Publish.py", line 222, in publish_module response = publish(request, module_name, after_list, debug=debug) File "/home/picard/bpe/Zope-2.2.0-src/lib/python/ZPublisher/Publish.py", line 162, in publish object=request.traverse(path, validated_hook=validated_hook) File "/home/picard/bpe/Zope-2.2.0-src/lib/python/ZPublisher/BaseRequest.py", line 427, in traverse else: user=v(request, auth, roles) File "/home/picard/bpe/Zope-2.2.0-src/lib/python/Products/LoginManager/LoginManager.py", line 110, in validate user = _DefaultAuth.findLogin(self, request, auth, user, roles) File "/home/picard/bpe/Zope-2.2.0-src/lib/python/Products/LoginManager/LoginMethods.py", line 147, in findLogin user = manager.getItem(name) File "/home/picard/bpe/Zope-2.2.0-src/lib/python/Products/LoginManager/LoginManager.py", line 65, in getItem user = source.__of__(self).getItem(name) File "/home/picard/bpe/Zope-2.2.0-src/lib/python/Products/ZPatterns/Rack.py", line 61, in getItem self._registerCanonical(k,item) # XXX Should we cache non-existence? File "/home/picard/bpe/Zope-2.2.0-src/lib/python/Products/ZPatterns/DataManagers.py", line 52, in _registerCanonical self._register() File "/home/picard/bpe/Zope-2.2.0-src/lib/python/Products/ZPatterns/Transactions.py", line 47, in _register for i in traceback.format_stack(): After: UserSource._v_registered=1 Unregister UserSource(NisUserSource instance at 85ab2e8) Before: UserSource._v_registered=None from Products.ZPatterns.PlugIns import PlugIn from Products.LoginManager.UserSources import BasicUserSource,LoginUser from Products.LoginManager.LoginMethods import LoginMethod from Products.LoginManager import LoginManager import nis, string, crypt from Products.ZPatterns.PlugIns import defaultConstructors class NisUserSource(BasicUserSource, PlugIn): __plugin_kind__ = "User Source" meta_type = "NIS User Source" f=open('/tmp/zopelog', 'a', 0) i=0 def dbg(self, str): self.f.write('[%03d] %s\n' % (self.i, str)) self.i = self.i + 1 def retrieveItem(self, name): self.dbg('retrieveItem: %s' % name) try: passwd=nis.match(name, 'passwd.byname') except nis.error: return None user=LoginUser(name) user._setRack(self) self.dbg('retrieveItem: %s ok.' % user.getUserName()) return user def authenticateUser(self, user, password, REQUEST=None): self.dbg('authenticateUser: %s %s' % (user, 'password')) name=user.getUserName() if name is None: return None try: passwd=nis.match(name, 'passwd.byname') except nis.error: return None crypted=string.split(passwd, ':')[1] test=crypt.crypt(password, crypted) self.dbg('%s == %s: %d' % (crypted, test, crypted==test)) return crypted==test def rolesForUser(self, user): if user.getUserName() == 'bpe': return ['Write Access'] else: return ['Read Access'] def domainsForUser(self, user): return [] def initialize(context): context.registerPlugInClass(