[Zope-CMF] Re: Zope-CMF digest, Vol 1 #1134 - 13 msgs

Carl Rendell cer@sol43.com
Wed, 29 May 2002 00:30:23 -0700


I've been using this method posted by Alan on zope labs, and it 
works for me. I also verified that it is a preferred method for CMF 
content with some of the contributors here on the mailing list.

http://www.zopelabs.com/cookbook/1003270687

For folder I've been using -

context.invokeFactory(type_name='FolderType', id='yourID')

Both work equally well in my application and context.

Zope 2.5.1 - CMF 1.3beta1

~C

On Tuesday, May 28, 2002, at 11:37  PM, zope-cmf-request@zope.org wrote:

> Message: 2
> From: Keller Nicolas <nicolas.keller@slb.de>
> To: "'zope-cmf@zope.org'" <zope-cmf@zope.org>
> Date: Tue, 28 May 2002 18:18:08 +0200
> Subject: [Zope-CMF] Add content programmatically
>
> Hi!
>
> For hours I've tried to accomplish the following: I've got a CMF
> product that holds content and acts as an folder. What I want to=20
> to now is to add a file (eg. an empty image object) after the object
> was created. I think the following code is not totally wrong (at=20
> least I hope so for my ego :)) but it always comes up with an=20
> "AttributeError: portal_types" - Traceback.
>
> ----------------------------- cutting -------------------------------
>
> class CMFExtNews(PortalFolder, PortalContent, DefaultDublinCoreImpl):
>
>     meta_type =3D 'CMFExtNews'
>
>     def __init__(self, id, title=3D''):
>         DefaultDublinCoreImpl.__init__(self)
>         self.id =3D id
>         self.title =3D title
>         self.invokeFactory('Image', 'img')      <------ The bad one
>    =20
> ----------------------------- cutting -------------------------------
>
> Without the 'self.invokeFactory('Image', 'img')'-line the product=20
> works perfect but I'm really hopeless on this one.
>
> Any hints?
>
> Bye,
>
> Nicolas Keller

Carl E. Rendell
Solution43
Information Distribution Consulting        |   "Ahhhh the power of
cer@sol43.com                              |    acquisition"  - Chef Z