I have written a simple class to function as pluggable brains for SQL records. My class is called Document, and it looks like this: class Document(RoleManager): " class code here " I need to set local roles on my result objects, so I am inheriting the RoleManager class. Within the __init__() method of my Document class, I make an SQL call to retrieve the local role mappings for the particular document in question. Then I call "self.manage_setLocalRoles(userid, roles )". This call fails, generating an AttributeError on __ac_local_roles__. I believe this is because Zope's base Record class has put the kabosh on setting any of its attributes. So at this point I am wondering if I have attempted the impossible. If so, is my only recourse to write a wrapper class that inherits from RoleManager and encapsulates my record objects? I'm sure I can do this; it just seems inelegant compared with pluggable brains. Furthermore, the base Record class seems to be compiled C++. Is any documentation available for this class? Thanks for your help!
nwingfield@dixon-hughes.com wrote at 2004-5-14 11:49 -0400:
... I believe this is because Zope's base Record class has put the kabosh on setting any of its attributes.
Right!
So at this point I am wondering if I have attempted the impossible.
You will not be able to set attributes other than for fields defined by your SQL result. Those, you can change. You can easily add artificial fields to your SQL... Another work around may be to use acquition, i.e. use the SQL result as (acquisition) parent for your object. You can than define as many attributes as you like in your object. By acquisition magic, lookups are forwarded to your SQL result when your object cannot satisfy them. -- Dieter
I have experimented with the acquisition trick, and it seems to work well. It also gives me a lot of flexibility if I want to create new attributes (in addition to sql data) in the future. Thanks for the suggestion. Dieter Maurer <dieter@handshake.de> wrote on 05/14/2004 03:24:57 PM:
nwingfield@dixon-hughes.com wrote at 2004-5-14 11:49 -0400:
... I believe this is because Zope's base Record class has put the kabosh on setting any of its attributes.
Right!
So at this point I am wondering if I have attempted the impossible.
You will not be able to set attributes other than for fields defined by your SQL result. Those, you can change.
You can easily add artificial fields to your SQL...
Another work around may be to use acquition, i.e. use the SQL result as (acquisition) parent for your object. You can than define as many attributes as you like in your object. By acquisition magic, lookups are forwarded to your SQL result when your object cannot satisfy them.
-- Dieter
participants (3)
-
Dieter Maurer -
nwingfield@che-llp.com -
nwingfield@dixon-hughes.com