Changeset 1501

Show
Ignore:
Timestamp:
11/09/06 22:07:45 (2 years ago)
Author:
coderanger
Message:

DatamoverPlugin:

  • Starting work on the new mutable provider
  • Better error message when no tickets are selected
  • Work around for #T4119
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • datamoverplugin/0.10/datamover/api.py

    r1305 r1501  
    2626                envs[env] = { 
    2727                    'name': _open_environment(env).project_name, 
    28                     'mutable': provider.mutable_environments() and envs.get(env, {'mutable': 1}).get('mutable'), 
     28                    'mutable': provider.mutable_environments() and envs.get(env, {'mutable': True}).get('mutable'), 
    2929                    'provider': envs.get(env, {'provider': []}).get('provider') + [provider], 
    3030                } 
     
    3232        return envs 
    3333 
     34    def any_mutable(self): 
     35        """Indicate if any of the active providers are mutable.""" 
     36        for provider in self.env_providers: 
     37            if provider.mutable_environments(): 
     38                return True 
     39        return False 
  • datamoverplugin/0.10/datamover/providers.py

    r1096 r1501  
    44 
    55from api import IEnvironmentProvider 
     6 
     7__all__ = ['SiblingProviderModule', 'DBProviderModule'] 
    68 
    79class SiblingProviderModule(Component): 
     
    2224    def mutable_environments(self): 
    2325        return False 
     26 
     27class DBProviderModule(Component): 
     28    """Provide environments from a database table.""" 
     29     
  • datamoverplugin/0.10/datamover/templates/datamover_config.cs

    r1096 r1501  
    11<h2>Datamover Configuration</h2> 
     2 
     3<?cs if:datamover.any_mutable ?> 
     4<form class="addnew" id="addenv" method="post"> 
     5    <fieldset> 
     6        <legend>Add Environment</legend> 
     7        <div class="field"> 
     8            <label>Path: <input type="text" name="env_path" /></label> 
     9        </div> 
     10        <div class="buttons"> 
     11            <input type="submit" name="add" value="Add" /> 
     12        </div> 
     13    </fieldset> 
     14</form> 
     15<?cs /if ?> 
    216 
    317<form class="mod" id="modconfig" method="post"> 
  • datamoverplugin/0.10/datamover/ticket.py

    r1305 r1501  
    3939            action_verb = {'copy':'Copied', 'move':'Moved'}[action] 
    4040             
     41            # Double check the ticket number is actually a number 
     42            if source_type == 'id': 
     43                try: 
     44                    int(source) 
     45                except ValueError: 
     46                    raise TracError('Value %r is not numeric'%source) 
     47             
     48            self.log.debug('DatamoverTicketModule: Source is %s (%s)', source, source_type) 
     49             
    4150            query_string = { 
    42                 'ticket': 'id=%s'%int(source)
     51                'ticket': 'id=%s'%source
    4352                'component': 'component=%s'%source, 
    4453                'all': 'id!=0', 
     
    4756                 
    4857            try: 
    49                 ids = [x['id'] for x in Query.from_string(self.env, query_string).execute(req)] 
     58                # Find the ids we want 
     59                ids = None 
     60                if source_type == 'ticket': # Special case this pending #T4119 
     61                    ids = [int(source)] 
     62                else: 
     63                    self.log.debug('DatamoverTicketModule: Running query %r', query_string) 
     64                    ids = [x['id'] for x in Query.from_string(self.env, query_string).execute(req)] 
     65                    self.log.debug('DatamoverTicketModule: Results: %r', ids) 
     66                     
    5067                dest_db = _open_environment(dest).get_db_cnx() 
    5168                for id in ids: 
     
    5774                        Ticket(self.env, id).delete() 
    5875                     
    59                 req.hdf['datamover.message'] = '%s tickets %s'%(action_verb, ', '.join([str(n) for n in ids])) 
     76                if ids: 
     77                    req.hdf['datamover.message'] = '%s tickets %s'%(action_verb, ', '.join([str(n) for n in ids])) 
     78                else: 
     79                    req.hdf['datamover.message'] = 'No tickets %s'%(action_verb.lower()) 
    6080            except TracError, e: 
    6181                req.hdf['datamover.message'] = "An error has occured: \n"+str(e) 
  • datamoverplugin/0.10/datamover/web_ui.py

    r1096 r1501  
    1717     
    1818    def process_admin_request(self, req, cat, page, path_info): 
    19         envs = DatamoverSystem(self.env).all_environments() 
     19        system = DatamoverSystem(self.env) 
     20        envs = system.all_environments() 
     21        any_mutable = system.any_mutable() 
    2022                 
    2123        req.hdf['datamover.envs'] = envs 
     24        req.hdf['datamover.any_mutable'] = any_mutable 
    2225        return 'datamover_config.cs', None 
    2326                 
  • datamoverplugin/0.10/setup.py

    r1096 r1501  
    66setup( 
    77    name = 'TracDatamoverPlugin', 
    8     version = '0.1', 
     8    version = '1.0', 
    99    packages = ['datamover'], 
    1010    package_data={ 'datamover' : [ 'templates/*.cs' ] }, 
     
    1212    author_email = "coderanger@yahoo.com", 
    1313    description = "Move data between Trac instances.", 
    14     long_description = "Move/copy tickets and wiki pages from one Trac instance to another o nthe same server.", 
     14    long_description = "Move/copy tickets and wiki pages from one Trac instance to another on the same server.", 
    1515    license = "BSD", 
    1616    keywords = "trac plugin data move copy", 
     
    2727 
    2828    install_requires = [ 'TracWebAdmin' ], 
     29     
     30    classifiers = [ 
     31        'Framework :: Trac', 
     32    ], 
    2933)