Bug in Archetypes constructor

Max M <[email protected]>
Newsgroups gmane.comp.web.zope.plone.archetypes.devel
Message-ID <[email protected]>
I am writing an archetype based object. I need to give it a specific id.


So I write this:

     def __init__(self, id, **kwargs):
         BaseNewsletter.__init__(self, 'foldernewsletter', **kwargs)


When I try to add this type, I get an error. I have chased the bug down 
to the constructor call I have marked below:

     def _constructInstance(self, container, id, *args, **kw):
         """Build a bare instance of the appropriate type.

         Does not do any security checks.

         Returns the object without calling _finishConstruction().
         """
         m = self._getFactoryMethod(container, check_security=0)
         id = str(id)
         if getattr(aq_base(m), 'isDocTemp', 0):
             kw['id'] = id
             newid = m(m.aq_parent, self.REQUEST, *args, **kw)
         else:
             newid = m(id, *args, **kw) # ERROR ERROR ERROR ERROR
         # allow factory to munge ID
         newid = newid or id
         return container._getOb(newid)

It turns out that the newid returned::

     newid = m(id, *args, **kw)

newid == 'foldernewsletter'

is different from the one actually in the container. So when::

     container._getOb(newid) is called, it causes an attribute error.

actualid == 'foldersubscribeletter.2006-04-06.7196934836'

This must be a bug!

My "Product factory method" is called "addFolderSubscribeletter". This 
is not a real function I assume, but one that is created dynamically by AT.

My problem is that I cannot find where in the source to look for this. 
Would anybody give me a pointer to where/how the archetypes factory 
method is created, so that I can debug further?


Another thing... is there any way to overwrite the constructor in my 
content type, so I can work around the bug?


-- 

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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.