Exemple #1
0
    def __new__(cls, name, bases, attrs):
        obj = super(ViewType, cls).__new__(cls, name, bases, attrs)

        kind = attrs.get("_type")

        if kind:
            pooler.register_object(obj, key=kind, group="view_types")

        return obj
    def __new__(cls, name, bases, attrs):
        obj = super(ViewType, cls).__new__(cls, name, bases, attrs)

        kind = attrs.get("_type")

        if kind:
            pooler.register_object(obj, key=kind, group="view_types")

        return obj
Exemple #3
0
    def __init__(cls, name, bases, attrs):
        super(ControllerType, cls).__init__(name, bases, attrs)
        
        if "path" in attrs and name != "BaseController":
            raise Exception("Can't override 'path' attribute.")

        path = attrs.get("_cp_path")
        if path:
            if not path.startswith("/"):
                raise Exception("Invalid path '%s', should start with '/'." % (path))

            pooler.register_object(cls, key=path, group="controllers")
Exemple #4
0
def register_widget(klass, types, view="form"):
    """Register a widget class for the given view and types

    @param view: the view type (e.g. form, tree)
    @param types: register for the give types
    @param klass: widget class
    """

    if not isinstance(types, (list, tuple)):
        types = [types]

    for t in types:
        pooler.register_object(klass, key=t, group=view)
def register_widget(klass, types, view="form"):
    """Register a widget class for the given view and types

    @param view: the view type (e.g. form, tree)
    @param types: register for the give types
    @param klass: widget class
    """

    if not isinstance(types, (list, tuple)):
        types = [types]

    for t in types:
        pooler.register_object(klass, key=t, group=view)
Exemple #6
0
    def __init__(cls, name, bases, attrs):
        super(ControllerType, cls).__init__(name, bases, attrs)

        if "path" in attrs and name != "BaseController":
            raise Exception("Can't override 'path' attribute.")

        path = attrs.get("_cp_path")
        if path:
            if not path.startswith("/"):
                raise Exception("Invalid path '%s', should start with '/'." %
                                (path))

            pooler.register_object(cls, key=path, group="controllers")