[Zope-CMF] adding a type with a new factory method
Karl Anderson
kra@monkey.org
19 Jul 2002 18:43:44 -0700
I'm trying to create a new type based on an existing one (CMFPost,
part of CMFForum).
Right now, I'm only trying to change the factory method. So, I copied
the CMFPost type to MyCMFPost, and changed the factory method to
"myAddPost". To create myAddPost, I added an External Method to the
portal root, adapted from CMFPost.addPost, the old factory method (in
the Python product).
However, this fails, apparently because the External Method is called
differently - self isn't the container. I couldn't use a
Script(Python), because I can't call _setObject from it.
I finally got this working (so far) by adding a keyword argument called
'thecontainer' to the External Method, and having the skin that the
MyCMFPost-adding action uses pass its context as the 'thecontainer'
argument to context.invokeFactory (I couldn't use 'container', because
PortalTypes.constructContent() complained about extra values for that
keyword argument, which I still don't understand).
Am I going about this the right way? It seems wrong that I have to
pass the container explicitly.
Is there an example of changing a factory method? Should I give up
and subclass before I run into real problems?
--
Karl Anderson kra@monkey.org http://www.monkey.org/~kra/