Changeset 2938

Show
Ignore:
Timestamp:
02/21/07 16:29:26 (2 years ago)
Author:
mscott
Message:

Create query objects too

Files:

Legend:

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

    r2936 r2938  
    2525                 ) 
    2626     
     27    map.resource('query', 'queries') 
     28     
    2729    map.resource('query', 'queries', 
    2830                 controller='extent_queries', 
    2931                 path_prefix='/databases/:db_id/extents/:extent_id', 
    3032                 name_prefix='extent_', 
     33                 member=dict(call='POST'), 
    3134                 ) 
    3235 
  • sandbox/mscott/SchevoPylonsNav/trunk/schevopylonsnav/controllers/extent_queries.py

    r2930 r2938  
    1717        return render_response('/extent_queries/index.html') 
    1818     
     19    def call(self, db_id, extent_id, id): 
     20        """POST /id;call: Call the query method.""" 
     21        # url_for('extent_call_query', id=ID) 
     22        db = self.dbs[db_id] 
     23        extent = db.extent(extent_id) 
     24        method = extent.q[id] 
     25        query = method() 
     26        query_cache = g.query_cache 
     27        token = g.new_cache_token(query_cache) 
     28        query_cache[token] = query 
     29        return redirect_to(h.url_for('query', id=token)) 
     30 
    1931    def create(self): 
    2032        """POST /: Create a new item.""" 
     
    4557        pass 
    4658     
    47     def show(self, id, format='html'): 
     59    def show(self, db_id, extent_id, id, format='html'): 
    4860        """GET /id: Show a specific item.""" 
    4961        # url_for('extent_query', id=ID) 
    50         pass 
     62        c.dbs = dbs = self.dbs 
     63        c.db_id = db_id 
     64        c.db = db = dbs[db_id] 
     65        c.extent = db.extent(extent_id) 
     66        c.method = c.extent.q[id] 
     67        c.method_id = id 
     68        return render_response('/extent_queries/show.html') 
    5169     
    5270    def edit(self, id, format='html'): 
  • sandbox/mscott/SchevoPylonsNav/trunk/schevopylonsnav/controllers/extent_transactions.py

    r2936 r2938  
    1818    def call(self, db_id, extent_id, id): 
    1919        """POST /id;call: Call the transaction method.""" 
    20         # url_for('call_extent_transaction', id=ID) 
     20        # url_for('extent_call_transaction', id=ID) 
    2121        db = self.dbs[db_id] 
    2222        extent = db.extent(extent_id) 
  • sandbox/mscott/SchevoPylonsNav/trunk/schevopylonsnav/controllers/transactions.py

    r2937 r2938  
    5252        # url_for('edit_transaction', id=ID) 
    5353        pass 
    54      
  • sandbox/mscott/SchevoPylonsNav/trunk/schevopylonsnav/lib/app_globals.py

    r2937 r2938  
    3939             
    4040        """ 
     41        self.query_cache = LRUCache(size=2048) 
    4142        self.tx_cache = LRUCache(size=2048) 
    4243        self.cache_tokens = set() 
  • sandbox/mscott/SchevoPylonsNav/trunk/schevopylonsnav/templates/extent_queries/index.html

    r2931 r2938  
    3232                    % for name in c.extent.q: 
    3333                        <li> 
    34                             <a href="#">${h.label(c.extent.q[name])}</a> 
     34                            <a href="${h.url_for('extent_query', db_id=c.db_id, extent_id=c.extent.name, id=name)}" 
     35                                >${h.label(c.extent.q[name])}</a> 
    3536                        </li> 
    3637                    % endfor 
  • sandbox/mscott/SchevoPylonsNav/trunk/schevopylonsnav/templates/extent_transactions/index.html

    r2935 r2938  
    3232                    % for name in c.extent.t: 
    3333                        <li> 
    34                             <a href="${h.url_for('extent_transaction', db_id=c.db_id, extent_id=c.extent.name, id=name)}">${h.label(c.extent.t[name])}</a> 
     34                            <a href="${h.url_for('extent_transaction', db_id=c.db_id, extent_id=c.extent.name, id=name)}" 
     35                                >${h.label(c.extent.t[name])}</a> 
    3536                        </li> 
    3637                    % endfor 
  • sandbox/mscott/SchevoPylonsNav/trunk/schevopylonsnav/tests/functional/test_extent_queries.py

    r2930 r2938  
    99        assert 'By Example' in response 
    1010        assert 'Exact Matches' in response 
     11 
     12    def test_get_exact(self): 
     13        response = self.app.get( 
     14            url_for('extent_query', db_id='db', extent_id='Foo', 
     15            id='exact')) 
     16        assert 'Exact Matches' in response 
     17 
     18    def test_call_exact(self): 
     19        response = self.app.post( 
     20            url_for('extent_call_query', db_id='db', extent_id='Foo', 
     21            id='exact')) 
     22        assert response.status == 302 
     23        response = response.follow()