예제 #1
0
 def __init__(self):
     Component.__init__(self)
     try:
         dir = resource_filename(__name__, 'locale')
         add_domain(self.env.path, dir)
     except:
         pass
예제 #2
0
    def __init__(self, default_data=False, enable=None):
        ComponentManager.__init__(self)
        Component.__init__(self)
        self.enabled_components = enable
        self.db = InMemoryDatabase()
        self.path = ''

        self.config = TestConfiguration(None)

        from trac.log import logger_factory
        self.log = logger_factory('test')

        from trac.web.href import Href
        self.href = Href('/trac.cgi')
        self.abs_href = Href('http://example.org/trac.cgi')

        from trac import db_default
        if default_data:
            cursor = self.db.cursor()
            for table, cols, vals in db_default.get_data(self.db):
                cursor.executemany(
                    "INSERT INTO %s (%s) VALUES (%s)" %
                    (table, ','.join(cols), ','.join(['%s' for c in cols])),
                    vals)
            self.db.commit()

        self.known_users = []
예제 #3
0
 def __init__(self):
     Component.__init__(self)
     self.entries = self.get_entries()
     self.__class__.engine = self
     t = threading.Thread(target=self.poll)
     t.daemon = True
     t.start()
예제 #4
0
 def __init__(self, *args, **kwargs):
     """
     Intercept the instanciation to start the ticker
     """
     Component.__init__(self, *args, **kwargs)
     self.cronconf = CronConfig(self.env)
     self.webUi = WebUi(self)
     self.apply_config()
예제 #5
0
파일: core.py 프로젝트: nyuhuhuu/trachacks
 def __init__(self,*args,**kwargs):
     """
     Intercept the instanciation to start the ticker
     """        
     Component.__init__(self, *args, **kwargs)
     self.cronconf = CronConfig(self.env)        
     self.webUi = WebUi(self)        
     self.apply_config()        
예제 #6
0
 def __init__(self):
     Component.__init__(self)
     try:
         import adspanel
         if self.env.is_component_enabled(adspanel.web_ui.AdsPanel):
             raise TracError("You need to disable/un-install the old "
                             "AdsPanel plugin in order to work with the new"
                             "one. (package rename)")
     except ImportError:
         pass
예제 #7
0
    def __init__(self):
        Component.__init__(self)

        from pkg_resources import parse_version
        version = parse_version(trac_version)
        if version < parse_version('0.11.1'):
            self._jquery_ui_filename = None
        else:
            self._jquery_ui_filename = \
                'adminenumlistplugin/jqueryui-%s/jquery-ui.min.js' % \
                ('1.8.24', '1.6')[version < parse_version('0.12')]
예제 #8
0
 def __init__(self, *args, **kwds):
     Component.__init__(self, *args, **kwds)
     self.git_dir = self.config.get("trac","repository_dir","")
     if not self.git_dir:
         raise TracError("repository_dir is not set in the config file")
     self.cgit_host = self.config.get("trac", "cgit_host", "")
     if not self.cgit_host:
         raise TracError("cgit_host is not set in the config file")
     self.cgit_repo = self.config.get("trac", "cgit_repository", "")
     if not self.cgit_repo:
         raise TracError("cgit_repository is not set in the config file")
예제 #9
0
 def __init__(self):
     Component.__init__(self)
     self._render_exceptions = []
     self._index = 0
     self._link = None
     self._args = None
     self._type = 'CodeExample'
     self._path = None, None, None, None
     self._regex_match = None
     self._lines_match = None
     self._title = None
     self._repo = None
예제 #10
0
    def __init__(self, default_data=False, enable=None):
        """Construct a new Environment stub object.

        :param default_data: If True, populate the database with some
                             defaults.
        :param enable: A list of component classes or name globs to
                       activate in the stub environment.
        """
        ComponentManager.__init__(self)
        Component.__init__(self)
        self.systeminfo = []

        import trac
        self.path = os.path.dirname(trac.__file__)
        if not os.path.isabs(self.path):
            self.path = os.path.join(os.getcwd(), self.path)

        # -- configuration
        self.config = Configuration(None)
        # We have to have a ticket-workflow config for ''lots'' of things to
        # work.  So insert the basic-workflow config here.  There may be a
        # better solution than this.
        load_workflow_config_snippet(self.config, 'basic-workflow.ini')
        self.config.set('logging', 'log_level', 'DEBUG')
        self.config.set('logging', 'log_type', 'stderr')
        if enable is not None:
            self.config.set('components', 'trac.*', 'disabled')
        for name_or_class in enable or ():
            config_key = self._component_name(name_or_class)
            self.config.set('components', config_key, 'enabled')

        # -- logging
        from trac.log import logger_handler_factory
        self.log, self._log_handler = logger_handler_factory('test')

        # -- database
        self.dburi = get_dburi()
        if self.dburi.startswith('sqlite'):
            self.config.set('trac', 'database', 'sqlite::memory:')
            self.db = InMemoryDatabase()

        if default_data:
            self.reset_db(default_data)

        from trac.web.href import Href
        self.href = Href('/trac.cgi')
        self.abs_href = Href('http://example.org/trac.cgi')

        self.known_users = []
        translation.activate(Locale and Locale('en', 'US'))
예제 #11
0
    def __init__(self, default_data=False, enable=None):
        """Construct a new Environment stub object.

        :param default_data: If True, populate the database with some
                             defaults.
        :param enable: A list of component classes or name globs to
                       activate in the stub environment.
        """
        ComponentManager.__init__(self)
        Component.__init__(self)
        self.systeminfo = []

        import trac
        self.path = os.path.dirname(trac.__file__)
        if not os.path.isabs(self.path):
            self.path = os.path.join(os.getcwd(), self.path)

        # -- configuration
        self.config = Configuration(None)
        # We have to have a ticket-workflow config for ''lots'' of things to
        # work.  So insert the basic-workflow config here.  There may be a
        # better solution than this.
        load_workflow_config_snippet(self.config, 'basic-workflow.ini')
        self.config.set('logging', 'log_level', 'DEBUG')
        self.config.set('logging', 'log_type', 'stderr')
        if enable is not None:
            self.config.set('components', 'trac.*', 'disabled')
        for name_or_class in enable or ():
            config_key = self._component_name(name_or_class)
            self.config.set('components', config_key, 'enabled')

        # -- logging
        from trac.log import logger_handler_factory
        self.log, self._log_handler = logger_handler_factory('test')

        # -- database
        self.dburi = get_dburi()
        if self.dburi.startswith('sqlite'):
            self.config.set('trac', 'database', 'sqlite::memory:')
            self.db = InMemoryDatabase()

        if default_data:
            self.reset_db(default_data)

        from trac.web.href import Href
        self.href = Href('/trac.cgi')
        self.abs_href = Href('http://example.org/trac.cgi')

        self.known_users = []
        translation.activate(Locale and Locale('en', 'US'))
예제 #12
0
 def __init__(self, *args, **kwargs):
     Component.__init__(self, *args, **kwargs)
     self.actions = get_workflow_config(self.config)
     if not '_reset' in self.actions:
         # Special action that gets enabled if the current status no longer
         # exists, as no other action can then change its state. (#5307)
         self.actions['_reset'] = {
             'default': 0,
             'name': 'reset',
             'newstate': 'new',
             'oldstates': [],  # Will not be invoked unless needed
             'operations': ['reset_workflow'],
             'permissions': []}
     self.log.debug('Workflow actions at initialization: %s\n' %
                    str(self.actions))
예제 #13
0
 def __init__(self, *args, **kwargs):
     Component.__init__(self, *args, **kwargs)
     self.actions = get_workflow_config(self.config)
     if not '_reset' in self.actions:
         # Special action that gets enabled if the current status no longer
         # exists, as no other action can then change its state. (#5307)
         self.actions['_reset'] = {
             'default': 0,
             'name': 'reset',
             'newstate': 'new',
             'oldstates': [],  # Will not be invoked unless needed
             'operations': ['reset_workflow'],
             'permissions': []
         }
     self.log.debug('Workflow actions at initialization: %s\n' %
                    str(self.actions))
예제 #14
0
파일: test.py 프로젝트: gdgkyoto/kyoto-gtug
    def __init__(self, default_data=False, enable=None):
        """Construct a new Environment stub object.

        default_data: If True, populate the database with some defaults.
        enable: A list of component classes or name globs to activate in the
                stub environment.
        """
        ComponentManager.__init__(self)
        Component.__init__(self)
        self.enabled_components = enable or ['trac.*']
        self.systeminfo = [('Python', sys.version)]

        import trac
        self.path = os.path.dirname(trac.__file__)
        if not os.path.isabs(self.path):
            self.path = os.path.join(os.getcwd(), self.path)

        # -- configuration
        self.config = Configuration(None)
        # We have to have a ticket-workflow config for ''lots'' of things to
        # work.  So insert the basic-workflow config here.  There may be a
        # better solution than this.
        load_workflow_config_snippet(self.config, 'basic-workflow.ini')
        self.config.set('logging', 'log_level', 'DEBUG')
        self.config.set('logging', 'log_type', 'stderr')

        # -- logging
        from trac.log import logger_factory
        self.log = logger_factory('test')

        # -- database
        self.dburi = get_dburi()
        if self.dburi.startswith('sqlite'):
            self.db = InMemoryDatabase()

        if default_data:
            self.reset_db(default_data)

        from trac.web.href import Href
        self.href = Href('/trac.cgi')
        self.abs_href = Href('http://example.org/trac.cgi')

        self.known_users = []
예제 #15
0
파일: sso.py 프로젝트: SpamExperts/trac-sso
 def __init__(self, *args, **kwargs):
     Component.__init__(self, *args, **kwargs)
     self.__parse_config()
 def __init__(self, *args, **kwargs):
     Component.__init__(self, *args, **kwargs)
     add_domain(self.env.path, resource_filename(__name__, 'locale'))
예제 #17
0
    def __init__(self,
                 default_data=False,
                 enable=None,
                 disable=None,
                 path=None,
                 destroying=False):
        """Construct a new Environment stub object.

        :param default_data: If True, populate the database with some
                             defaults.
        :param enable: A list of component classes or name globs to
                       activate in the stub environment.
        :param disable: A list of component classes or name globs to
                        deactivate in the stub environment.
        :param path: The location of the environment in the file system.
                     No files or directories are created when specifying
                     this parameter.
        :param destroying: If True, the database will not be reset. This is
                           useful for cases when the object is being
                           constructed in order to call `destroy_db`.
        """
        if enable is not None and not isinstance(enable, (list, tuple)):
            raise TypeError('Keyword argument "enable" must be a list')
        if disable is not None and not isinstance(disable, (list, tuple)):
            raise TypeError('Keyword argument "disable" must be a list')

        ComponentManager.__init__(self)
        Component.__init__(self)

        self.systeminfo = []

        import trac
        self.path = path
        if self.path is None:
            self.path = os.path.dirname(trac.__file__)
            if not os.path.isabs(self.path):
                self.path = os.path.join(os.getcwd(), self.path)

        # -- configuration
        self.config = Configuration(None)
        # We have to have a ticket-workflow config for ''lots'' of things to
        # work.  So insert the basic-workflow config here.  There may be a
        # better solution than this.
        load_workflow_config_snippet(self.config, 'basic-workflow.ini')
        self.config.set('logging', 'log_level', 'DEBUG')
        self.config.set('logging', 'log_type', 'stderr')
        if enable is not None:
            self.config.set('components', 'trac.*', 'disabled')
        else:
            self.config.set('components', 'tracopt.versioncontrol.*',
                            'enabled')
        for name_or_class in enable or ():
            config_key = self._component_name(name_or_class)
            self.config.set('components', config_key, 'enabled')
        for name_or_class in disable or ():
            config_key = self._component_name(name_or_class)
            self.config.set('components', config_key, 'disabled')

        # -- logging
        from trac.log import logger_handler_factory
        self.log, self._log_handler = logger_handler_factory('test')

        # -- database
        self.config.set('components', 'trac.db.*', 'enabled')
        self.dburi = get_dburi()

        init_global = False
        if self.global_databasemanager:
            self.components[DatabaseManager] = self.global_databasemanager
        else:
            self.config.set('trac', 'database', self.dburi)
            self.global_databasemanager = DatabaseManager(self)
            self.config.set('trac', 'debug_sql', True)
            self.config.set('logging', 'log_type', 'stderr')
            self.config.set('logging', 'log_level', 'DEBUG')
            init_global = not destroying

        if default_data or init_global:
            self.reset_db(default_data)

        from trac.web.href import Href
        self.href = Href('/trac.cgi')
        self.abs_href = Href('http://example.org/trac.cgi')

        self.known_users = []
        translation.activate(locale_en)
 def __init__(self, *args, **kwargs):
     Component.__init__(self, *args, **kwargs)
     add_domain(self.env.path, resource_filename(__name__, 'locale'))
예제 #19
0
파일: test.py 프로젝트: dafrito/trac-mirror
    def __init__(self, default_data=False, enable=None, disable=None, path=None, destroying=False):
        """Construct a new Environment stub object.

        :param default_data: If True, populate the database with some
                             defaults.
        :param enable: A list of component classes or name globs to
                       activate in the stub environment.
        """
        ComponentManager.__init__(self)
        Component.__init__(self)

        self.systeminfo = []

        import trac

        self.path = path
        if self.path is None:
            self.path = os.path.dirname(trac.__file__)
            if not os.path.isabs(self.path):
                self.path = os.path.join(os.getcwd(), self.path)

        # -- configuration
        self.config = Configuration(None)
        # We have to have a ticket-workflow config for ''lots'' of things to
        # work.  So insert the basic-workflow config here.  There may be a
        # better solution than this.
        load_workflow_config_snippet(self.config, "basic-workflow.ini")
        self.config.set("logging", "log_level", "DEBUG")
        self.config.set("logging", "log_type", "stderr")
        if enable is not None:
            self.config.set("components", "trac.*", "disabled")
        else:
            self.config.set("components", "tracopt.versioncontrol.*", "enabled")
        for name_or_class in enable or ():
            config_key = self._component_name(name_or_class)
            self.config.set("components", config_key, "enabled")
        for name_or_class in disable or ():
            config_key = self._component_name(name_or_class)
            self.config.set("components", config_key, "disabled")

        # -- logging
        from trac.log import logger_handler_factory

        self.log, self._log_handler = logger_handler_factory("test")

        # -- database
        self.config.set("components", "trac.db.*", "enabled")
        self.dburi = get_dburi()

        init_global = False
        if self.global_databasemanager:
            self.components[DatabaseManager] = global_databasemanager
        else:
            self.config.set("trac", "database", self.dburi)
            self.global_databasemanager = DatabaseManager(self)
            self.config.set("trac", "debug_sql", True)
            self.config.set("logging", "log_type", "stderr")
            self.config.set("logging", "log_level", "DEBUG")
            init_global = not destroying

        if default_data or init_global:
            self.reset_db(default_data)

        from trac.web.href import Href

        self.href = Href("/trac.cgi")
        self.abs_href = Href("http://example.org/trac.cgi")

        self.known_users = []
        translation.activate(locale_en)
예제 #20
0
 def __init__(self):
     Component.__init__(self)
예제 #21
0
 def __init__(self):
     Component.__init__(self)
     if not self.wrapped:
         self.wrap()