Re: Bug in Archetypes constructor
Max M <[email protected]>
| Newsgroups | gmane.comp.web.zope.plone.archetypes.devel |
|---|---|
| Message-ID | <[email protected]> |
Martin Aspeli wrote:
>
> Max M wrote:
>
>>Another thing... is there any way to overwrite the constructor in my
>>content type, so I can work around the bug?
>>
>
> This is probably not quite what you're looking for, but you may be able to
> set _at_rename_after_creation = True and then make your own
> _renameAfterCreation() method (see PoiIssue, for example) that sets the id.
> This will be called when the object is first saved, not when it's
> instantiated, but if you want to use portal_factory, this is a good thing -
> the factory implicitly relies on the id of the object it's holding being
> unique within the acquisition chain.
Yeah that is a nice workaround too. I found another thats a bit simpler
in my case.
I am creating some subcontent at the same time with
"at_post_create_script", so I just hook into that and set the id. Seems
to work ok:
security.declarePrivate('at_post_create_script')
def at_post_create_script(self):
"Adds the subscriber folder automatically"
subscribers = 'subscribers'
self.invokeFactory('Subscribers', id=subscribers,
title='Subscribers')
self._reserved_names = [subscribers]
self.setId('foldernewsletter')
Thanks.
--
hilsen/regards Max M, Denmark
http://www.mxm.dk/
IT's Mad Science
Phone: +45 66 11 84 94
Mobile: +45 29 93 42 96
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642