Changeset 14637 in trac.svn


Ignore:
Timestamp:
Mar 25, 2016, 5:56:51 PM (8 years ago)
Author:
rjollos
Message:

1.0.11dev: Replaced methods with equivalent properties

Added Environment.log_dir property.

Refs #12410.

Location:
branches/1.0-stable/trac
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/1.0-stable/trac/admin/web_ui.py

    r14613 r14637  
    490490                              "egg"))
    491491
    492         target_path = os.path.join(self.env.path, 'plugins', plugin_filename)
     492        target_path = os.path.join(self.env.plugins_dir, plugin_filename)
    493493        if os.path.isfile(target_path):
    494494            raise TracError(_("Plugin %(name)s already installed",
     
    516516        if not plugin_filename:
    517517            return
    518         plugin_path = os.path.join(self.env.path, 'plugins', plugin_filename)
     518        plugin_path = os.path.join(self.env.plugins_dir, plugin_filename)
    519519        if not os.path.isfile(plugin_path):
    520520            return
     
    584584        data = {
    585585            'plugins': plugins, 'show': req.args.get('show'),
    586             'readonly': not os.access(self.env.get_plugins_dir(),
     586            'readonly': not os.access(self.env.plugins_dir,
    587587                                      os.F_OK + os.W_OK),
    588588            'safe_wiki_to_html': safe_wiki_to_html,
  • branches/1.0-stable/trac/env.py

    r14613 r14637  
    576576        if not os.path.exists(self.path):
    577577            os.mkdir(self.path)
    578         os.mkdir(self.get_log_dir())
    579         os.mkdir(self.get_htdocs_dir())
    580         os.mkdir(os.path.join(self.path, 'plugins'))
     578        os.mkdir(self.log_dir)
     579        os.mkdir(self.htdocs_dir)
     580        os.mkdir(self.plugins_dir)
    581581
    582582        # Create a few files
     
    587587
    588588        # Setup the default configuration
    589         os.mkdir(os.path.join(self.path, 'conf'))
    590         create_file(os.path.join(self.path, 'conf', 'trac.ini.sample'))
    591         config = Configuration(os.path.join(self.path, 'conf', 'trac.ini'))
     589        os.mkdir(self.conf_dir)
     590        create_file(os.path.join(self.conf_dir, 'trac.ini.sample'))
     591        config = Configuration(os.path.join(self.conf_dir, 'trac.ini'))
    592592        for section, name, value in options:
    593593            config.set(section, name, value)
     
    646646    def setup_config(self):
    647647        """Load the configuration file."""
    648         self.config = Configuration(os.path.join(self.path, 'conf', 'trac.ini'),
     648        self.config = Configuration(os.path.join(self.conf_dir, 'trac.ini'),
    649649                                    {'envname': os.path.basename(self.path)})
    650650        self.setup_log()
     
    657657        return os.path.normcase(os.path.realpath(path))
    658658
     659    @lazy
     660    def conf_dir(self):
     661        """Absolute path to the conf directory.
     662
     663        :since: 1.0.11
     664        """
     665        return self._get_path_to_dir('conf')
     666
     667    @lazy
     668    def htdocs_dir(self):
     669        """Absolute path to the htdocs directory.
     670
     671        :since: 1.0.11
     672        """
     673        return self._get_path_to_dir('htdocs')
     674
     675    def get_htdocs_dir(self):
     676        """Return absolute path to the htdocs directory.
     677
     678        :since 1.0.11: Deprecated and will be removed in 1.3.1. Use the
     679                       `htdocs_dir` property instead.
     680        """
     681        return self._get_path_to_dir('htdocs')
     682
     683    @lazy
     684    def log_dir(self):
     685        """Absolute path to the log directory.
     686
     687        :since: 1.0.11
     688        """
     689        return self._get_path_to_dir('log')
     690
     691    def get_log_dir(self):
     692        """Return absolute path to the log directory.
     693
     694        :since 1.0.11: Deprecated and will be removed in 1.3.1. Use the
     695                       `log_dir` property instead.
     696        """
     697        return self._get_path_to_dir('log')
     698
     699    @lazy
     700    def plugins_dir(self):
     701        """Absolute path to the plugins directory.
     702
     703        :since: 1.0.11
     704        """
     705        return self._get_path_to_dir('plugins')
     706
     707    @lazy
     708    def templates_dir(self):
     709        """Absolute path to the templates directory.
     710
     711        :since: 1.0.11
     712        """
     713        return self._get_path_to_dir('templates')
     714
    659715    def get_templates_dir(self):
    660         """Return absolute path to the templates directory."""
     716        """Return absolute path to the templates directory.
     717
     718        :since 1.0.11: Deprecated and will be removed in 1.3.1. Use the
     719                       `templates_dir` property instead.
     720        """
    661721        return self._get_path_to_dir('templates')
    662 
    663     def get_htdocs_dir(self):
    664         """Return absolute path to the htdocs directory."""
    665         return self._get_path_to_dir('htdocs')
    666 
    667     def get_log_dir(self):
    668         """Return absolute path to the log directory."""
    669         return self._get_path_to_dir('log')
    670 
    671     def get_plugins_dir(self):
    672         """Return absolute path to the plugins directory."""
    673         return self._get_path_to_dir('plugins')
    674722
    675723    def setup_log(self):
     
    679727        logfile = self.log_file
    680728        if logtype == 'file' and not os.path.isabs(logfile):
    681             logfile = os.path.join(self.get_log_dir(), logfile)
     729            logfile = os.path.join(self.log_dir, logfile)
    682730        format = self.log_format
    683731        logid = 'Trac.%s' % sha1(self.path).hexdigest()
     
    841889
    842890    def _update_sample_config(self):
    843         filename = os.path.join(self.env.path, 'conf', 'trac.ini.sample')
     891        filename = os.path.join(self.env.conf_dir, 'trac.ini.sample')
    844892        if not os.path.isfile(filename):
    845893            return
  • branches/1.0-stable/trac/loader.py

    r14613 r14637  
    102102    """Return the path to the `plugins` directory of the environment.
    103103
    104     :since 1.0.11: Deprecated and will be removed in 1.3.1. Use
    105                    Environment.get_plugins_dir() instead."""
    106     return env.get_plugins_dir()
     104    :since 1.0.11: Deprecated and will be removed in 1.3.1. Use the
     105                   Environment.plugins_dir property instead."""
     106    return env.plugins_dir
    107107
    108108
     
    110110                                                   load_py_files())):
    111111    """Load all plugin components found on the given search path."""
    112     plugins_dir = env.get_plugins_dir()
     112    plugins_dir = env.plugins_dir
    113113    search_path = [plugins_dir]
    114114    if extra_path:
     
    139139        return dist
    140140
    141     plugins_dir = env.get_plugins_dir()
     141    plugins_dir = env.plugins_dir
    142142    plugins = {}
    143143    from trac.core import ComponentMeta
  • branches/1.0-stable/trac/tests/functional/testcases.py

    r14303 r14637  
    4646        env.config.set('components', 'RaiseExceptionPlugin.*', 'enabled')
    4747        env.config.save()
    48         create_file(os.path.join(env.path, 'plugins',
    49                                  'RaiseExceptionPlugin.py'),
     48        create_file(os.path.join(env.plugins_dir, 'RaiseExceptionPlugin.py'),
    5049"""\
    5150from trac.core import Component, implements
     
    9089        """Test for regression of the plugin reload fix in r6017"""
    9190        # Setup the DeleteTicket plugin
     91        env = self._testenv.get_trac_environment()
    9292        plugin = open(os.path.join(self._testenv.trac_src,
    9393                                   'sample-plugins', 'workflow',
    9494                                   'DeleteTicket.py')).read()
    95         open(os.path.join(self._testenv.tracdir, 'plugins',
    96                           'DeleteTicket.py'), 'w').write(plugin)
    97         env = self._testenv.get_trac_environment()
     95        plugin_path = os.path.join(env.plugins_dir, 'DeleteTicket.py')
     96        open(plugin_path, 'w').write(plugin)
    9897        prevconfig = env.config.get('ticket', 'workflow')
    9998        env.config.set('ticket', 'workflow',
     
    114113            env.config.save()
    115114            for ext in ('py', 'pyc', 'pyo'):
    116                 filename = os.path.join(self._testenv.tracdir, 'plugins',
     115                filename = os.path.join(env.plugins_dir,
    117116                                        'DeleteTicket.%s' % ext)
    118117                if os.path.exists(filename):
     
    123122    def runTest(self):
    124123        """Test for regression of http://trac.edgewall.org/ticket/3833 a"""
     124        env = self._testenv.get_trac_environment()
    125125        # Assume the logging is already set to debug.
    126         traclogfile = open(os.path.join(self._testenv.tracdir, 'log',
    127                                         'trac.log'))
     126        traclogfile = open(os.path.join(env.log_dir, 'trac.log'))
    128127        # Seek to the end of file so we only look at new log output
    129128        traclogfile.seek(0, 2)
     129
    130130        # Verify that logging is on initially
    131         env = self._testenv.get_trac_environment()
    132 
    133131        env.log.debug("RegressionTestTicket3833 debug1")
    134132        debug1 = traclogfile.read()
     
    143141        # Turn logging off, try to log something, and verify that it does
    144142        # not show up.
    145         traclogfile = open(os.path.join(self._testenv.tracdir, 'log',
    146                                         'trac.log'))
     143        env = self._testenv.get_trac_environment()
     144        traclogfile = open(os.path.join(env.log_dir, 'trac.log'))
    147145        # Seek to the end of file so we only look at new log output
    148146        traclogfile.seek(0, 2)
    149         env = self._testenv.get_trac_environment()
    150147
    151148        env.config.set('logging', 'log_level', 'INFO')
     
    167164        # Turn logging back on, try to log something, and verify that it
    168165        # does show up.
    169         traclogfile = open(os.path.join(self._testenv.tracdir, 'log',
    170                                         'trac.log'))
     166        env = self._testenv.get_trac_environment()
     167        traclogfile = open(os.path.join(env.log_dir, 'trac.log'))
    171168        # Seek to the end of file so we only look at new log output
    172169        traclogfile.seek(0, 2)
    173         env = self._testenv.get_trac_environment()
    174170
    175171        env.config.set('logging', 'log_level', 'DEBUG')
     
    309305        env.config.set('components', 'RaiseExceptionPlugin.*', 'enabled')
    310306        env.config.save()
    311         create_file(os.path.join(env.path, 'plugins', 'RaiseExceptionPlugin.py'),
     307        create_file(os.path.join(env.plugins_dir, 'RaiseExceptionPlugin.py'),
    312308"""\
    313309from trac.core import Component, implements
  • branches/1.0-stable/trac/tests/functional/testenv.py

    r13591 r14637  
    345345        env.config.set('trac', 'permission_policies',
    346346                       'AuthzPolicy, ' + permission_policies)
    347         authz_file = self.tracdir + '/conf/' + filename
     347        authz_file = os.path.join(env.conf_dir, filename)
    348348        if isinstance(authz_content, basestring):
    349349            authz_content = [line.strip() for line in
  • branches/1.0-stable/trac/ticket/tests/functional.py

    r14480 r14637  
    129129        env.config.set('components', plugin_name + '.*', 'enabled')
    130130        env.config.save()
    131         create_file(os.path.join(env.path, 'plugins', plugin_name + '.py'),
     131        create_file(os.path.join(env.plugins_dir, plugin_name + '.py'),
    132132"""\
    133133from genshi.builder import tag
     
    18941894        """Test for regression of http://trac.edgewall.org/ticket/6048"""
    18951895        # Setup the DeleteTicket plugin
     1896        env = self._testenv.get_trac_environment()
    18961897        plugin = open(os.path.join(self._testenv.trac_src, 'sample-plugins',
    18971898                                   'workflow', 'DeleteTicket.py')).read()
    1898         open(os.path.join(self._testenv.tracdir, 'plugins',
    1899                           'DeleteTicket.py'), 'w').write(plugin)
    1900         env = self._testenv.get_trac_environment()
     1899        plugin_path = os.path.join(env.plugins_dir, 'DeleteTicket.py')
     1900        open(plugin_path, 'w').write(plugin)
    19011901        prevconfig = env.config.get('ticket', 'workflow')
    19021902        env.config.set('ticket', 'workflow',
     
    19241924        env = self._testenv.get_trac_environment() # reload environment
    19251925        for ext in ('py', 'pyc', 'pyo'):
    1926             filename = os.path.join(self._testenv.tracdir, 'plugins',
    1927                                     'DeleteTicket.%s' % ext)
     1926            filename = os.path.join(env.plugins_dir, 'DeleteTicket.%s' % ext)
    19281927            if os.path.exists(filename):
    19291928                os.unlink(filename)
  • branches/1.0-stable/trac/web/chrome.py

    r14480 r14637  
    703703        return [('common', pkg_resources.resource_filename('trac', 'htdocs')),
    704704                ('shared', self.shared_htdocs_dir),
    705                 ('site', self.env.get_htdocs_dir())]
     705                ('site', self.env.htdocs_dir)]
    706706
    707707    def get_templates_dirs(self):
    708708        return filter(None, [
    709             self.env.get_templates_dir(),
     709            self.env.templates_dir,
    710710            self.shared_templates_dir,
    711711            pkg_resources.resource_filename('trac', 'templates'),
     
    11461146        files = {}
    11471147        # Collect templates list
    1148         site_templates = list_dir(self.env.get_templates_dir(), '.html')
     1148        site_templates = list_dir(self.env.templates_dir, '.html')
    11491149        shared_templates = list_dir(Chrome(self.env).shared_templates_dir,
    11501150                                    '.html')
    11511151
    11521152        # Collect static resources list
    1153         site_htdocs = list_dir(self.env.get_htdocs_dir())
     1153        site_htdocs = list_dir(self.env.htdocs_dir)
    11541154        shared_htdocs = list_dir(Chrome(self.env).shared_htdocs_dir)
    11551155
  • branches/1.0-stable/trac/wiki/tests/functional.py

    r13874 r14637  
    5858        env.config.set('components', plugin_name + '.*', 'enabled')
    5959        env.config.save()
    60         create_file(os.path.join(env.path, 'plugins',
    61                                  plugin_name + '.py'), """\
     60        create_file(os.path.join(env.plugins_dir, plugin_name + '.py'), """\
    6261from genshi.builder import tag
    6362from trac.core import Component, implements
Note: See TracChangeset for help on using the changeset viewer.