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 registerContentType(
    name, specification, klass=None, behaviors=(), schemas=(), title="", description="", ct_factory=None
):
    """ Register new content type
    """

    sm = getSiteManager()

    # register new content behavior
    bh_name = "content.type-%s" % name
    storage.registerBehavior(bh_name, specification, Content, "", None, title, description)

    behaviors = tuple(behaviors) + (bh_name,)
    ct = ct_factory(name, specification, behaviors, schemas, title, description)

    # register content type as named utility
    sm.registerUtility(ct, IContentType, name=name)

    return ct