question on setting PropertySheet value from External Method
Hi, I'm having trouble setting a property of a ZClass propertysheet from an external method. I can successfully create an instance of the ZClass and from a DTML document set the properties, but I can't seem to get the syntax right for doing it from the external method. Could someone give me some advice? Here are the relevant lines from my external method that successfully creates the ZClass instance: recordID = "7893" t = "A new title" self.resources.manage_addProduct['agnicCatalog'].resourceClass.createInObjectManager(recordID, self.REQUEST) I have a folder called 'resources' that I want to hold all instances of the class 'resourceClass'. The above line works fine to create the instance. But, when I try to change the Title property with: self.resources[recordID].propertysheets['Basic'].manage_changeProperties(Title = t) I get TypeError -- sequence index must be integer I've tried a bunch of variations with recordID, but nothing seems to work. Can someone set me straight? Thanks! ============================================================================ Tim Lynch tim.lynch@cornell.edu Mann Library 607.255.9570 Cornell University Ithaca, NY 14853
Hi, I'm a new Zope user so bear with me.... What I would like to do is create a specific set of users who will be redirected to specific subfolders according to the login and password they provide, starting from a main portal. I've tried with the acl_user system, but I don't seem to be able to get it right. I'm getting confused with the differences in authorisation, permission, etc. I'm only concerned with people actually accessing (viewing) the specific parts of a site. Can somebody point me into a starting direction here? Flip
From: "Flip Hoedemaeker" <flip@keydp.com>
What I would like to do is create a specific set of users who will be redirected to specific subfolders according to the login and password they provide, starting from a main portal. I've tried with the acl_user system, but I don't seem to be able to get it right. I'm getting confused with the differences in authorisation, permission, etc. I'm only concerned with people actually accessing (viewing) the specific parts of a site. Can somebody point me into a starting direction here?
Roles are a set of permissions that make up a type of user, like a Manager, Member, Contributor, Guest, Editor, Reviewer or whatever. You set up what each type of user should be able to do in the root document. You can override it lower down, but you don't have to unless you want to make a folder less accessible than it's parent (see below). After this you add users to roles they should have, ie Manager, member, and so on. Making a folder less accessible is done by: 1. Making a new role called "Groupmember" or something. Do not add any users to this role globally! 2. Override the permission settings for the restricted folders so that only "Groupmember" has acces to the folder. 3. Give the users that should have access to the folder a Local role of "Groupmember" in that folder! Done! If you have many folders like this, you do NOT have to have one role per folder. Instead you put all these folders in the folder you restriced in step 2, and you give users the local role "Groupmember" in each of the folders the user should have access too. Summary: 1. Roles define a set of permissions. 2. You give users these permissions on a per folder basis with local roles. 3. You only need to set permissions at a folder if you want to make the access stricter than it is on the parent folder.
Flip Hoedemaeker writes:
What I would like to do is create a specific set of users who will be redirected to specific subfolders according to the login and password they provide, starting from a main portal. I've tried with the acl_user system, but I don't seem to be able to get it right. I'm getting confused with the differences in authorisation, permission, etc. I'm only concerned with people actually accessing (viewing) the specific parts of a site. Can somebody point me into a starting direction here? Not trivial...
You can send them to a (protected) Python Script (maybe one that bind "traversal_subpath"). The Python Script looks at the user (his roles) and redirects as necessary. This is good for a single entry point. If your "redirection" should work all over the site, you need the "traversal_subpath" binding and use some form of "restrictedTraverse" to reach the final object. Some background reading may be adequate: the Zope Book or <http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html> Dieter
Got it. I had poured over the list archives without finding the magic incantation before posting my plea to the list. Finally, this afternoon while poking around Zope Labs I came across a recipe that got me to: self.resources[recordID].propertysheets.Basic.manage_changeProperties({'Title':t}) which works. Much thanks to 'peterbe' and his/her message of 2001-08-08. - lynch
Hi,
I'm having trouble setting a property of a ZClass propertysheet from an external method. I can successfully create an instance of the ZClass and from a DTML document set the properties, but I can't seem to get the syntax right for doing it from the external method. Could someone give me some advice?
Here are the relevant lines from my external method that successfully creates the ZClass instance:
recordID = "7893" t = "A new title"
self.resources.manage_addProduct['agnicCatalog'].resourceClass.createInObjectManager(recordID, self.REQUEST)
I have a folder called 'resources' that I want to hold all instances of the class 'resourceClass'. The above line works fine to create the instance.
But, when I try to change the Title property with:
self.resources[recordID].propertysheets['Basic'].manage_changeProperties(Title = t)
I get TypeError -- sequence index must be integer
I've tried a bunch of variations with recordID, but nothing seems to work.
Can someone set me straight? Thanks!
============================================================================ Tim Lynch tim.lynch@cornell.edu Mann Library 607.255.9570 Cornell University Ithaca, NY 14853
Tim Lynch writes:
But, when I try to change the Title property with:
self.resources[recordID].propertysheets['Basic'].manage_changeProperties(Title = t)
I get TypeError -- sequence index must be integer This probably comes from "propertysheets['Basic']".
Try the attribute access syntax: "propertysheets.Basic". But, do you have a propertysheet named "Basic" ?. If not, you will get an "AttributeError". Dieter
Thanks Dieter, As you might have seen by now from a second message to the list, I did manage to solve this problem. But to follow up your email. yes, I do have a propertysheet named Basic. I did try the alternative syntax: propertysheets.Basic at one point, but not since I fixed the problem by changing how I passed the the Title value from Title = t (which didn't work) to {'Title':t} (which does work). What I'm using now is propertysheets['Basic'] and that does work. I got the "Title = t" syntax from an example posted back in April I believe. The write said it worked for him, but I had no luck. Actually, what I've got working now is: self.resources[recordID].propertysheets.Basic.manage_changeProperties({'Title':t, 'Description':d}) Title is of type string and Description of type text. My propertysheet has other properties of type token, lines, and date. Once I'm able to update all properties via the external method, I'll post a final note on my experience -- hopefully it'll save other newbies some head scratching. thanks again! Tim
Tim Lynch writes:
But, when I try to change the Title property with:
self.resources[recordID].propertysheets['Basic'].manage_changeProperties(Title = t)
I get TypeError -- sequence index must be integer This probably comes from "propertysheets['Basic']".
Try the attribute access syntax: "propertysheets.Basic".
But, do you have a propertysheet named "Basic" ?. If not, you will get an "AttributeError".
Dieter
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (4)
-
Dieter Maurer -
Flip Hoedemaeker -
Lennart Regebro -
Tim Lynch