[Zope-CMF] Duplicating NewsItem and custom CMF product.

Erik Enge erik@thingamy.net
09 Jul 2001 18:16:40 +0200


Hi, guys.

I'm endavouring to grok CMF, but it's a struggle.  I've got it halfway
pinned down now, but suddenly, in a weak moment of mine, it escaped!

First, I tried to make my own python CMF product; CMFTestProduct.
This product provides the TestObject object and not much else.  I
basically abused CMFCalendar beyond recognition.  Adding it is
no problemo, but viewing is a different story.  I get:

 Error Type: Not Found
 Error Value: Cannot find default view for "/cmf_site/Members/user1/test_object2"

What's the secret?

Second, I tried to mangle NewsItem.py in CMFDefault/.  I copied it to a
file (in the same CMFDefault/ folder) named NewsItemErik.py.  Then I
modified the skins, Portal.py and the content of NewsItemErik.py to
reflect this change.  I created a new site and News Item Erik is now
in the portal_types; great, nice, I like :).  I was kinda assuming to
be able to see News Item Erik after clicking "New..." as a Member of
the site, but uh-oh.  No-can-do.  After some sourcediving, I narrowed
it down to this fellow:

    def _getFactoryMethod(self, container, raise_exc=0):
        if not self.product or not self.factory:
            return None
        try:
            p = container.manage_addProduct[self.product]
            m = getattr(p, self.factory, None)
            if m is not None:
                if getSecurityManager().validate(p, p, self.factory, m):
                    return m
            return None
        except:
            if raise_exc:
                raise
            return None

It's the

        m = getattr(p, self.factory, None)

that fails (or returns None, if you absolutely must know).  Could
anyone be so kinda as to tell me why?  It would be very much
appretiated.  Sourcediving isn't one of my favourite sports, even
though I quite like it, I like real diving and sun-bathing more!

(CMF looks great though, keep up the good work!)

(Oh, and I have loads of lovely nitpicking on source code - missing
module-docstrings, CVS-headers, wild'n'crazy-excepts and more.  Anyone
interested?)