Exemplo n.º 1
0
    def _register(name, category, schema, klass, title, description):
        ConfigletClass = configlettype.ConfigletType(
            str(name), schema, klass, title, description)
        interface.classImplements(ConfigletClass, schema)

        # register behavior for configlet
        bname = 'memphis.controlpanel-%s'%name

        # behavior
        bfactory = configlet.BehaviorFactory(name, bname)
        storage.registerBehavior(
            bname, schema, bfactory, schema = IConfigletData,
            title=title, description=description, configContext=None)

        # set additional attributes
        ConfigletClass.__category__ = category

        # configlet instance
        inst = ConfigletClass()

        # register configlet as utility
        config.registerUtility(inst, schema, '')

        # register configlet in control panel
        getUtility(IControlPanel).addConfiglet(inst)
        inst.__behavior__ = storage.getBehavior(schema)
Exemplo n.º 2
0
    def update(self):
        super(ContentTypeBehaviors, self).update()

        behaviors = [(bh.title, bh)
                     for name, bh in getUtilitiesFor(IBehaviorType)]
        behaviors.sort()
        self.behaviors = [storage.getBehavior(IContent)] + \
            [behavior for t, behavior in behaviors]
Exemplo n.º 3
0
def getRoot():
    global rootOID

    behavior = storage.getBehavior(IRoot)
    try:
        if rootOID is None:
            rootOID = behavior.getBehaviorOIDs().next()
        return LocationProxy(storage.getItem(rootOID), None, "")
    except StopIteration:
        item = storage.insertItem(IRoot)
        rootOID = item.oid
        dc = IContent(item)
        dc.title = u"Site"
        dc.description = u"Default memphis site."

        event.notify(ObjectCreatedEvent(item))
        return LocationProxy(item, None, "")