Changeset 2953

Show
Ignore:
Timestamp:
02/22/07 17:56:04 (2 years ago)
Author:
mscott
Message:

some code reorganization

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/mscott/SchevoPylonsNav/trunk/schevopylonsnav/config/routing.py

    r2938 r2953  
    2121    map.resource('database', 'databases') 
    2222     
     23    map.resource('query', 'queries') 
     24     
     25    map.resource('transaction', 'transactions', 
     26                 member=dict(execute='POST'), 
     27                 ) 
     28     
    2329    map.resource('extent', 'extents', 
    2430                 path_prefix='/databases/:db_id', 
    2531                 ) 
    26      
    27     map.resource('query', 'queries') 
    2832     
    2933    map.resource('query', 'queries', 
     
    3438                 ) 
    3539 
    36     map.resource('transaction', 'transactions') 
    37      
    3840    map.resource('transaction', 'transactions', 
    3941                 controller='extent_transactions', 
     
    4345                 ) 
    4446                  
     47    map.resource('entity', 'entities', 
     48                 path_prefix='/databases/:db_id/extents/:extent_id', 
     49                 ) 
     50     
    4551    map.connect(':controller/:action/:id') 
    4652    map.connect('*url', controller='template', action='view') 
  • sandbox/mscott/SchevoPylonsNav/trunk/schevopylonsnav/controllers/transactions.py

    r2952 r2953  
    1717        # url_for('transactions') 
    1818        pass 
    19      
     19         
    2020    def new(self, format='html'): 
    2121        """GET /new: Form to create a new item.""" 
     
    6060        c.tx_id = id 
    6161        return render_response('/transactions/edit.html') 
     62 
     63    def execute(self, id): 
     64        """POST /id;execute: Execute a transaction.""" 
     65        # url_for('execute_transaction', id=ID) 
     66        tx = g.tx_cache[id] 
     67         
  • sandbox/mscott/SchevoPylonsNav/trunk/schevopylonsnav/templates/transactions/show.html

    r2950 r2953  
    3333        <input type="submit" value="Edit" /> 
    3434    </form> 
     35 
     36    <form method="post" action="${h.url_for('execute_transaction', id=c.tx_id)}"> 
     37        <input type="submit" value="Execute" /> 
     38    </form> 
    3539</%def> 
  • sandbox/mscott/SchevoPylonsNav/trunk/schevopylonsnav/tests/functional/test_transactions.py

    r2952 r2953  
    1313        # Bar field is shown. 
    1414        assert 'Bar' in response 
     15        # Edit and Execute buttons are shown. 
     16        assert 'Edit' in response 
     17        assert 'Execute' in response 
    1518 
    1619    def test_edit(self): 
     
    2225        response = response.follow() 
    2326        # Find the edit button and click it. 
    24         assert 'Edit' in response 
    2527        form = response.forms[0] 
    2628        response = form.submit() 
     
    4749        # The new value should now be on the page. 
    4850        assert 'newvalue123' in response 
     51         
     52    def test_execute(self): 
     53        # Get the transaction. 
     54        response = self.app.post( 
     55            url_for('extent_call_transaction', db_id='db', extent_id='Foo', 
     56            id='create')) 
     57        # Call it to get the transaction. 
     58        response = response.follow() 
     59        # Find the edit button and click it. 
     60        assert 'Edit' in response 
     61        form = response.forms[0] 
     62        response = form.submit() 
     63        # Find the bar field and edit it. 
     64        form = response.forms[0] 
     65        bar = form.fields['bar'][0] 
     66        assert bar.value == u'' 
     67        bar.value = 'newvalue123' 
     68        # Save the form and follow its redirection. 
     69        response = form.submit() 
     70        response = response.follow() 
     71        # The new value should now be on the page. 
     72        assert 'newvalue123' in response 
     73        # Execute the transaction and follow its redirection. 
     74        form = response.forms[1] 
     75        # response = form.submit() 
     76        # print dir(response) 
     77        # response = response.follow() 
     78