Changeset 68

Show
Ignore:
Timestamp:
07/18/05 04:10:01 (3 years ago)
Author:
athomas
Message:

AdminConsoleProviderPatch:

  • Moved !IAdminConsoleProvider to trac/scripts/admin.py
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • adminconsoleproviderpatch/trunk/admin-provider.diff

    r64 r68  
    1 Index: setup.py 
    2 =================================================================== 
    3 --- setup.py    (revision 1962) 
    4 +++ setup.py    (working copy) 
    5 @@ -211,7 +211,7 @@ 
    6        url=URL, 
    7        packages=['trac', 'trac.mimeview', 'trac.scripts', 'trac.ticket', 
    8                  'trac.upgrades', 'trac.versioncontrol', 'trac.web', 
    9 -                'trac.wiki'], 
    10 +                'trac.wiki', 'trac.admin'], 
    11        data_files=[(_p('share/trac/templates'), glob('templates/*')), 
    12                    (_p('share/trac/htdocs'), glob(_p('htdocs/*.*')) + [_p('htdocs/README')]), 
    13                    (_p('share/trac/htdocs/css'), glob(_p('htdocs/css/*'))), 
    141Index: trac/scripts/admin.py 
    152=================================================================== 
    16 --- trac/scripts/admin.py       (revision 1962
     3--- trac/scripts/admin.py       (revision 1976
    174+++ trac/scripts/admin.py       (working copy) 
    18 @@ -39,6 +39,9 @@ 
     5@@ -39,7 +39,11 @@ 
    196 from trac.Milestone import Milestone 
    207 from trac.perm import PermissionSystem 
    218 from trac.ticket.model import * 
    22 +from trac.admin.console import IAdminConsoleProvider 
    23 +from trac.core import ComponentManager, ExtensionPoint 
     9+from trac.core import ComponentManager, ExtensionPoint, Interface 
    2410+from trac.loader import load_components 
    2511  
     12+__all__ = [ 'IAdminConsoleProvider' ] 
     13+ 
    2614 try: 
    2715     sum 
    28 @@ -50,7 +53,24 @@ 
     16 except NameError: 
     17@@ -50,7 +54,40 @@ 
    2918             tot += item 
    3019         return tot 
    3120  
     21+class IAdminConsoleProvider(Interface): 
     22+    """ 
     23+    Extension point interface for components to provide an administrative 
     24+    interface from within trac-admin. 
     25+    """ 
     26  
     27+    def get_console_commands(tracadm): 
     28+        """ 
     29+        Return an iterable of (name, help, callable, completer) tuples. 
     30+ 
     31+        tracadm is a TracAdmin instance. 
     32+ 
     33+        completer can be null. help is in the same format that trac-admin 
     34+        uses. 
     35+        """ 
     36+ 
    3237+class AdminCommands(trac.core.Component): 
    3338+    """ 
     
    3540+    """ 
    3641+    admin_providers = ExtensionPoint(IAdminConsoleProvider) 
    37   
     42
    3843+    def import_providers(self, env, tracadm): 
    3944+        load_components(env) 
     
    5156     intro = '' 
    5257     license = trac.__license_long__ 
    53 @@ -64,6 +84,7 @@ 
     58@@ -64,6 +101,7 @@ 
    5459     _date_format = '%Y-%m-%d' 
    5560     _datetime_format = '%Y-%m-%d %H:%M:%S' 
     
    5964     def __init__(self, envdir=None): 
    6065         cmd.Cmd.__init__(self) 
    61 @@ -72,6 +93,7 @@ 
     66@@ -72,6 +110,7 @@ 
    6267             self.env_set(os.path.abspath(envdir)) 
    6368  
     
    6772  
    6873     def emptyline(self): 
    69 @@ -84,6 +106,7 @@ 
     74@@ -84,6 +123,7 @@ 
    7075               '%(copy)s\n\n'                                    \ 
    7176               "Type:  '?' or 'help' for help on commands.\n" %  \ 
     
    7580  
    7681     ## 
    77 @@ -99,6 +122,12 @@ 
     82@@ -99,6 +139,12 @@ 
    7883     def env_check(self): 
    7984         try: 
     
    8893             return 0 
    8994         return 1 
    90 @@ -117,6 +146,8 @@ 
     95@@ -117,6 +163,8 @@ 
    9196         try: 
    9297             if not self.__env: 
     
    97102         except Exception, e: 
    98103             print 'Failed to open environment.', e 
    99 @@ -209,6 +240,8 @@ 
     104@@ -209,6 +257,8 @@ 
    100105                                xrange(0, (1 + len(sep)) * cnum + sum(colw))]) 
    101106         print 
     
    106111         if not doc: return 
    107112         self.print_listing(['Command', 'Description'], doc, '  --', decor)  
    108 @@ -299,15 +332,13 @@ 
     113@@ -299,15 +349,13 @@ 
    109114             except AttributeError: 
    110115                 print "No documentation found for '%s'" % arg[0] 
     
    129134             if not self.interactive: 
    130135                 print 
    131 Index: trac/admin/__init__.py 
    132 =================================================================== 
    133 --- trac/admin/__init__.py      (revision 0) 
    134 +++ trac/admin/__init__.py      (revision 0) 
    135 @@ -0,0 +1 @@ 
    136 +from trac.admin.console import * 
    137 Index: trac/admin/console.py 
    138 =================================================================== 
    139 --- trac/admin/console.py       (revision 0) 
    140 +++ trac/admin/console.py       (revision 0) 
    141 @@ -0,0 +1,41 @@ 
    142 +# -*- coding: iso8859-1 -*- 
    143 +# 
    144 +# Copyright (C) 2003, 2004, 2005 Edgewall Software 
    145 +# Copyright (C) 2003, 2004, 2005 Alec Thomas <alec@swapoff.org> 
    146 +# 
    147 +# Trac is free software; you can redistribute it and/or 
    148 +# modify it under the terms of the GNU General Public License as 
    149 +# published by the Free Software Foundation; either version 2 of the 
    150 +# License, or (at your option) any later version. 
    151 +# 
    152 +# Trac is distributed in the hope that it will be useful, 
    153 +# but WITHOUT ANY WARRANTY; without even the implied warranty of 
    154 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
    155 +# General Public License for more details. 
    156 +# 
    157 +# You should have received a copy of the GNU General Public License 
    158 +# along with this program; if not, write to the Free Software 
    159 +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
    160 +# 
    161 +# Author: Alec Thomas <alec@swapoff.org> 
    162 + 
    163 +from trac.core import Interface 
    164 +import sys 
    165 + 
    166 +__all__ = [ 'IAdminConsoleProvider' ] 
    167 + 
    168 +class IAdminConsoleProvider(Interface): 
    169 +    """ 
    170 +    Extension point interface for components to provide an administrative 
    171 +    interface from within trac-admin. 
    172 +    """ 
    173 + 
    174 +    def get_console_commands(tracadm): 
    175 +        """ 
    176 +        Return an iterable of (name, help, callable, completer) tuples. 
    177 + 
    178 +        tracadm is a TracAdmin instance. 
    179 + 
    180 +        completer can be null. help is in the same format that trac-admin 
    181 +        uses. 
    182 +        """