creating content types dynamically

Maurits van Rees m.van.rees at zestsoftware.nl
Fri May 25 15:13:29 UTC 2007


Alain Hernandez Lopez, on 2007-05-25:
>  Hello
>  My problem is the following, I have two content types, KC and
>  DownloadedDocument, KC is a BaseFolder content type which inside I can
>  create DownloadedDocument objects. Inside of the KC class I've write the
>  next method to create objects dynamically. But when I run the product it
>  gives me an error which I show you next too.
>
>      security.declarePrivate('_saveDocument')
>      def _saveDocument(self,downloadedDocumentList):
>           """
>           Para guardar el documento en la base de datos de Zope
>           """          
>           # se crean los contenidos descargados.             
>           for url, html in downloadedDocumentList:
>               #crear el contenido
>               ids=self.generateUniqueId('DownloadedDocument')
>               self.invokeFactory(type_name="DownloadedDocument",id=ids)
>               self[ids].edit(title=url, text=html)
>
>  This is the error that it gives me
>
>  *Error Type *
>  *AttributeError *
>
>  *Error Value * 
> *generateUniqueId *
>
>  I don't understand why it gives me this error, I've proven to do it from
>  a python script and it has worked perfectly, please if you can help me

The `self` in self.generateUniqueId is the KC basefolder.  So it seems
this folder does not have that method.  Maybe in your tests you are
invoking that method on a DownloadedDocument?

If this does not help you, you could try going in with the python
debugger.  Add a line

  import pdb; pdb.set_trace()

just before the line calling self.generateUniqueId and examine the
situation there or step into (press 's') that method call and see why
it fails.


Maybe of use is an example of a generateUniqueId method, in a content
type of eXtremeManagement:

https://svn.plone.org/svn/collective/eXtremeManagement/trunk/content/Story.py


-- 
Maurits van Rees | http://maurits.vanrees.org/ [NL]
            Work | http://zestsoftware.nl/
"Do not worry about your difficulties in computers,
 I can assure you mine are still greater."





More information about the Product-Developers mailing list