[Zope] Can't add objects to Folder-like product
Florent Guillaume
fg@nuxeo.com
12 Nov 2001 00:18:20 GMT
> It's not your bad, it's just that for whatever reason, self in __init__ isn't
> Acquisition wrapped, which sucks :-(
>
> Anyway, I take it you have a manage_addParsing method somewhere that does
> something like:
>
> x = Parsing()
>
> ?
>
> In that case, change your __init__ method so it starts something like:
>
> def __init__(self,parent ...anything else you want here...):
> self = self.__of__(parent)
>
> and, change could line that creates the Parsing object to:
>
> x = Parsing(self,...whatever you had before...)
Urgh... I'd rather not do this kind of initialization in __init__, but
from whatever method calls the class constructor. Standard Zope idiom
would be for instance:
def addMyClass(container, id, title='', REQUEST=None):
"""MyClass constructor."""
ob = MyClass(id, title)
container._setObject(id, ob)
ob = container._getOb(id) # now we have a wrapped object
ob.postintialization() # do what you want in here
if REQUEST is not None:
REQUEST.RESPONSE.redirect(ob.absolute_url() + '/manage_main')
[you'll note that I dislike calling "self" what is actually "container"]
Florent
--
Florent Guillaume, Nuxeo SARL (Paris, France)
+33 1 40 33 79 10 http://nuxeo.com mailto:fg@nuxeo.com