RE: Subject: [Zope-dev] change ownership
Magnus, OK, here goes the evil workaround It seems that getUser does not return an acquisition wrapped object, so make your external method this to wrap it (thus giving ownerinfo the ability to determine the user db): def setOwner(self, username): #note: this assumes that the closest User database houses 'username' user = self.acl_users.getUser(username) self.changeOwnership(user.__of__(self.acl_users)) return 'done.' --Tim McLaughlin (tmclaugh) -Original Message- From: Magnus Heino (Rivermen) To: 'Tim McLaughlin'; Magnus Heino (Rivermen) Sent: 5/11/01 1:20 AM Subject: SV: Subject: [Zope-dev] change ownership > could you give me a url, name & pw, and let me take a look at > the zclass? Nope, I'm doing this on my laptop behind a firewall. But, this is how to reproduce it; This is my external method: [magnus@daysleeper Extensions]$ cat Owner.py def setObjectOwner(self, username): self.changeOwnership(self.acl_users.getUser(username)) return '%s is now the owner of %s' % (username, self.id) def getObjectOwner(self): return self.getOwner() [magnus@daysleeper Extensions]$ Goto Control_Panel/Products. Add a product 'FooProduct'. Enter the FooProduct and create a ZClass with id and metatype 'FooClass'. Enter the FooClass and add a External Method. Set Id and Function Name to 'setObjectOwner'. Module name is 'Owner'. Go to the Root zope folder. It contains a standard acl_users. Add a FooClass named 'foo'. Call the external method on the object like this: http://192.168.237.105:8080/foo/setObjectOwner?username=magnus magnus is my username that lives in the acl_users. You get the Attributeerror on aq_inner. Any clues? :-P Thanks. /Magnus ___ 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: Subject: [Zope-dev] change ownership
Do you have multiple acl_users objects in the acquisition context of the object? Because if you do and the self.acl_users will acquire (possibly) the wrong user database. If that's not the problem, I'm gonna have to let it cook, and I'll probably come up w/ somethin' later. --Tim You could also try a ZUserFolder and use restrictedTraverse if you want. :-) -Original Message- From: Magnus Heino (Rivermen) [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 10, 2001 9:23 AM To: 'Tim McLaughlin'; Magnus Heino (Rivermen) Cc: '[EMAIL PROTECTED]' Subject: SV: Subject: [Zope-dev] change ownership The one that comes with Zope. /Magnus > -Ursprungligt meddelande- > Från: Tim McLaughlin [mailto:[EMAIL PROTECTED]] > Skickat: den 10 maj 2001 15:26 > Till: 'Magnus Heino (Rivermen)'; Tim McLaughlin > Kopia: '[EMAIL PROTECTED]' > Ämne: RE: Subject: [Zope-dev] change ownership > > > What kind of UserFolder are you using... LoginManager or something? > > -Original Message- > From: Magnus Heino (Rivermen) [mailto:[EMAIL PROTECTED]] > Sent: Thursday, May 10, 2001 9:13 AM > To: 'Tim McLaughlin'; Magnus Heino (Rivermen) > Cc: '[EMAIL PROTECTED]' > Subject: SV: Subject: [Zope-dev] change ownership > > > > > def set_owner(self, user_name): > > self.changeOwnership(self.acl_users.getUser(user_name)) > > > > OK, so that should keep you busy for a while. Anyway, the > > Not long enough :-P > > > point is that the > > parameter to changeOwnership is a User _object_. Good luck. > > Ive got this external method in a zclass: > > def setObjectOwner(self, username): > self.changeOwnership(self.acl_users.getUser(username)) > > I call it like > http://localhost:8080/myobject/setObjectOwner?username=foo > and get this error: > > > > Zope Error > Zope has encountered an error while publishing this resource. > > Error Type: AttributeError > Error Value: aq_inner > > > > -- > -- > > > Troubleshooting Suggestions > > The URL may be incorrect. > The parameters passed to this resource may be incorrect. > A resource that this resource relies on may be encountering an error. > For more detailed information about the error, please refer > to the HTML > source for this page. > > If the error persists please contact the site maintainer. > Thank you for your > patience. > > > > > Traceback (innermost last): > File > /usr/home/magnus/www/Zope-2.3.2-src/lib/python/ZPublisher/Publish.py, > line 223, in publish_module > File > /usr/home/magnus/www/Zope-2.3.2-src/lib/python/ZPublisher/Publish.py, > line 187, in publish > File > /usr/home/magnus/www/Zope-2.3.2-src/lib/python/Zope/__init__.py, line > 221, in zpublisher_exception_hook > (Object: PLATS_1) > File > /usr/home/magnus/www/Zope-2.3.2-src/lib/python/ZPublisher/Publish.py, > line 171, in publish > File > /usr/home/magnus/www/Zope-2.3.2-src/lib/python/ZPublisher/mapply.py, > line 160, in mapply > (Object: setObjectOwner) > File > /usr/home/magnus/www/Zope-2.3.2-src/lib/python/ZPublisher/Publish.py, > line 112, in call_object > (Object: setObjectOwner) > File > /usr/home/magnus/www/Zope-2.3.2-src/lib/python/Products/Extern > alMethod/Exter > nalMethod.py, line 262, in __call__ > (Object: setObjectOwner) > (Info: ((, 'david'), {}, None)) > File > /usr/home/magnus/www/Zope-2.3.2-src/Extensions/Owner.py, line 2, in > setObjectOwner > (Object: PLATS_1) > File > /usr/home/magnus/www/Zope-2.3.2-src/lib/python/AccessControl/O > wned.py, line > 168, in changeOwnership > (Object: PLATS_1) > File > /usr/home/magnus/www/Zope-2.3.2-src/lib/python/AccessControl/O > wned.py, line > 302, in ownerInfo > AttributeError: (see above) > ___ 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: Subject: [Zope-dev] change ownership
What kind of UserFolder are you using... LoginManager or something? -Original Message- From: Magnus Heino (Rivermen) [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 10, 2001 9:13 AM To: 'Tim McLaughlin'; Magnus Heino (Rivermen) Cc: '[EMAIL PROTECTED]' Subject: SV: Subject: [Zope-dev] change ownership > def set_owner(self, user_name): > self.changeOwnership(self.acl_users.getUser(user_name)) > > OK, so that should keep you busy for a while. Anyway, the Not long enough :-P > point is that the > parameter to changeOwnership is a User _object_. Good luck. Ive got this external method in a zclass: def setObjectOwner(self, username): self.changeOwnership(self.acl_users.getUser(username)) I call it like http://localhost:8080/myobject/setObjectOwner?username=foo and get this error: Zope Error Zope has encountered an error while publishing this resource. Error Type: AttributeError Error Value: aq_inner Troubleshooting Suggestions The URL may be incorrect. The parameters passed to this resource may be incorrect. A resource that this resource relies on may be encountering an error. For more detailed information about the error, please refer to the HTML source for this page. If the error persists please contact the site maintainer. Thank you for your patience. Traceback (innermost last): File /usr/home/magnus/www/Zope-2.3.2-src/lib/python/ZPublisher/Publish.py, line 223, in publish_module File /usr/home/magnus/www/Zope-2.3.2-src/lib/python/ZPublisher/Publish.py, line 187, in publish File /usr/home/magnus/www/Zope-2.3.2-src/lib/python/Zope/__init__.py, line 221, in zpublisher_exception_hook (Object: PLATS_1) File /usr/home/magnus/www/Zope-2.3.2-src/lib/python/ZPublisher/Publish.py, line 171, in publish File /usr/home/magnus/www/Zope-2.3.2-src/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: setObjectOwner) File /usr/home/magnus/www/Zope-2.3.2-src/lib/python/ZPublisher/Publish.py, line 112, in call_object (Object: setObjectOwner) File /usr/home/magnus/www/Zope-2.3.2-src/lib/python/Products/ExternalMethod/Exter nalMethod.py, line 262, in __call__ (Object: setObjectOwner) (Info: ((, 'david'), {}, None)) File /usr/home/magnus/www/Zope-2.3.2-src/Extensions/Owner.py, line 2, in setObjectOwner (Object: PLATS_1) File /usr/home/magnus/www/Zope-2.3.2-src/lib/python/AccessControl/Owned.py, line 168, in changeOwnership (Object: PLATS_1) File /usr/home/magnus/www/Zope-2.3.2-src/lib/python/AccessControl/Owned.py, line 302, in ownerInfo AttributeError: (see above) ___ 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: Subject: [Zope-dev] change ownership
I call the external method like this from DTML... set_owner(restrictedTraverse(path_to_user)), where path to user is a physical path, but I'm using the ZUserFolder, so I can use the restrictedTraverse to get to users. UserFolder has a different API. You could do this if your acl_users is a standard UserFolder... set_owner(acl_users.getUser(user_name)) in DTML or make your external method this... def set_owner(self, user_name): self.changeOwnership(self.acl_users.getUser(user_name)) OK, so that should keep you busy for a while. Anyway, the point is that the parameter to changeOwnership is a User _object_. Good luck. --Tim -Original Message- From: Magnus Heino (Rivermen) [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 10, 2001 7:25 AM To: 'Tim McLaughlin'; '[EMAIL PROTECTED]'; Magnus Heino (Rivermen) Subject: SV: Subject: [Zope-dev] change ownership I can get it to work :-/ I get an attributeerror on aq_inner in lib/python/AccessControl/Owned.py, line 302, in ownerInfo Seems as if the user i provide isn't of the right type? How do you use your method? How is it being called? /Magnus > Magnus, > No, changeOwnership is not exposed for TTW calling. But you > can expose it > through an external method... I used this one on a ZClass. > > def set_owner(self, user): > self.changeOwnership(user) > return ___ 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 )