[z3-five] AddMenuItem in five

Maciej Wisniowski maciej.wisniowski at coig.katowice.pl
Mon Sep 11 13:54:33 CEST 2006


Daniel, please, stay on the mailing list. These messages
may be useful for the others and for us if someone will
correct something etc.

 > I donnot understand what's the MainModuleFactory.
 > Is this a new module that creates an instance of my object?
MainModuleFactory (you may call it MyFactory or
MyClassFactory) is simply a function that creates
instance of your class.

So say you may have:

main_module.py:

class MainModule(Folder):
    """MainModule"""

    implements(IMainModule)

    isPrincipiaFolderish = 1

    def __init__(self, id, title, default_conn_id):
        self.id              = id
        self.title           = title
        self.default_conn_id = default_conn_id
    (...)

def MainModuleFactory(view, id, title, default_conn_id):
    cf = MainModule(id, title, default_conn_id)
    return cf.__of__(view.context)


interfaces.py:

class IMainModule(Interface):
    title = TextLine(
        title=_("Title"),
        required=False,
        description=_("The title of the MainModule."))
       
    default_conn_id = Choice(
        title=_(u"Default connection id"),
        vocabulary='ConnectionVocabulary',
        description=_(u"Identifier of the default connection id"),
        required=True)

And the rest is in zcml (in my previous message).

It works, but there are a bit different solutions too. You ma want
to take a look at Five/form/tests or Five/docs/products/ViewsTutorial
or http://svn.nuxeo.org/trac/pub/browser/Zope2/CalZope/trunk/browser
(configure.zcml and adding.py).

I was learning about all of these from CalZope. Thanks Nuxeo :)

-- 
Maciej Wisniowski


More information about the z3-five mailing list