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 __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")
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)