Beispiel #1
0
    def init(self):
        self.categories = {}
        self.startup_crashes = []

        profile_start("Starting plugins")

        for cls in SectionPlugin.get_classes():
            try:
                UserManager.get().require_permission("section:%s" % cls.__name__)

                try:
                    profile_start("Starting %s" % cls.__name__)
                    cat = cls.new(self.ui)
                    profile_end()
                    self.append(cat)
                except SecurityError:
                    pass
                except Exception, e:
                    e.traceback = traceback.format_exc(e)
                    self.startup_crashes.append(e)
            except SecurityError:
                pass

        profile_end()

        def category_order(x):
            order = 98
            if x.category in self.category_order:
                order = self.category_order[x.category]
            return (order, x.order, x.title)

        self.children = sorted(self.children, key=category_order)
        if len(self.children) > 0:
            self.on_switch(self.children[0].uid)
Beispiel #2
0
    def init(self):
        self.categories = {}
        self.startup_crashes = []

        profile('Starting plugins')

        for cls in SectionPlugin.get_classes():
            try:
                UserManager.get().require_permission('section:%s' %
                                                     cls.__name__)

                try:
                    profile('Starting %s' % cls.__name__)
                    cat = cls.new(self.ui)
                    profile_end()
                    self.append(cat)
                except SecurityError:
                    pass
                except Exception, e:
                    e.traceback = traceback.format_exc(e)
                    self.startup_crashes.append(e)
            except SecurityError:
                pass

        profile_end()

        def category_order(x):
            order = 98
            if x.category in self.category_order:
                order = self.category_order[x.category]
            return (order, x.order, x.title)

        self.children = sorted(self.children, key=category_order)
        if len(self.children) > 0:
            self.on_switch(self.children[0].uid)
Beispiel #3
0
    def init(self):
        self.categories = {}
        self.startup_crashes = []

        profile_start('Starting plugins')

        self.is_empty = True
        for cls in SectionPlugin.get_classes():
            try:
                if not hasattr(cls, 'permissionless'):
                    permission_target = cls
                    if hasattr(cls, 'uses_access_permission_of'):
                        permission_target = cls.uses_access_permission_of
                    UserManager.get().require_permission(
                        self.context,
                        'section:%s' % permission_target.__name__)

                try:
                    profile_start('Starting %s' % cls.__name__)
                    cat = cls.new(self.ui)
                    cat.clsname = cls.classname
                    profile_end()
                    self.append(cat)
                    self.is_empty = False
                except SecurityError:
                    pass
                except Exception as e:
                    catcher.backup(e)
                    traceback.print_exc()
                    e.traceback = traceback.format_exc(e)
                    self.startup_crashes.append(e)
            except SecurityError:
                pass

        profile_end()

        def category_order(x):
            order = 98
            if x.category in self.category_order:
                order = self.category_order[x.category]
            return (order, x.order, x.title)

        self.children = sorted(self.children, key=category_order)
        if len(self.children) > 0:
            self.on_switch(self.children[0].uid)
Beispiel #4
0
    def init(self):
        self.categories = {}
        self.startup_crashes = []

        profile_start('Starting plugins')

        self.is_empty = True
        for cls in SectionPlugin.get_classes():
            try:
                if not hasattr(cls, 'permissionless'):
                    permission_target = cls
                    if hasattr(cls, 'uses_access_permission_of'):
                        permission_target = cls.uses_access_permission_of
                    UserManager.get().require_permission(self.context, 'section:%s' % permission_target.__name__)

                try:
                    profile_start('Starting %s' % cls.__name__)
                    cat = cls.new(self.ui)
                    cat.clsname = cls.classname
                    profile_end()
                    self.append(cat)
                    self.is_empty = False
                except SecurityError:
                    pass
                except Exception as e:
                    catcher.backup(e)
                    traceback.print_exc()
                    e.traceback = traceback.format_exc(e)
                    self.startup_crashes.append(e)
            except SecurityError:
                pass

        profile_end()

        def category_order(x):
            order = 98
            if x.category in self.category_order:
                order = self.category_order[x.category]
            return (order, x.order, x.title)

        self.children = sorted(self.children, key=category_order)
        if len(self.children) > 0:
            self.on_switch(self.children[0].uid)
Beispiel #5
0
 def get_permissions(self):
     # Generate permission set on-the-fly
     return [('section:%s' % x.__name__, x.__name__)
             for x in SectionPlugin.get_classes()]
Beispiel #6
0
 def get_permissions(self):
     # Generate permission set on-the-fly
     return [
         ('section:%s' % x.__name__, x.__name__)
         for x in SectionPlugin.get_classes()
     ]