Changeset 2936
- Timestamp:
- 02/21/07 14:49:55 (2 years ago)
- Files:
-
- sandbox/mscott/SchevoPylonsNav/trunk/schevopylonsnav/config/routing.py (modified) (2 diffs)
- sandbox/mscott/SchevoPylonsNav/trunk/schevopylonsnav/controllers/extent_transactions.py (modified) (1 diff)
- sandbox/mscott/SchevoPylonsNav/trunk/schevopylonsnav/controllers/transactions.py (added)
- sandbox/mscott/SchevoPylonsNav/trunk/schevopylonsnav/lib/app_globals.py (modified) (3 diffs)
- sandbox/mscott/SchevoPylonsNav/trunk/schevopylonsnav/tests/functional/test_extent_transactions.py (modified) (1 diff)
- sandbox/mscott/SchevoPylonsNav/trunk/schevopylonsnav/tests/functional/test_transactions.py (added)
- sandbox/mscott/SchevoPylonsNav/trunk/setup.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/mscott/SchevoPylonsNav/trunk/schevopylonsnav/config/routing.py
r2935 r2936 30 30 name_prefix='extent_', 31 31 ) 32 33 map.resource('transaction', 'transactions') 32 34 33 35 map.resource('transaction', 'transactions', … … 37 39 member=dict(call='POST'), 38 40 ) 39 41 40 42 map.connect(':controller/:action/:id') 41 43 map.connect('*url', controller='template', action='view') 42 44 43 45 return map 46 \ sandbox/mscott/SchevoPylonsNav/trunk/schevopylonsnav/controllers/extent_transactions.py
r2935 r2936 19 19 """POST /id;call: Call the transaction method.""" 20 20 # url_for('call_extent_transaction', id=ID) 21 pass 21 db = self.dbs[db_id] 22 extent = db.extent(extent_id) 23 method = extent.t[id] 24 tx = method() 25 tx_cache = g.tx_cache 26 token = g.new_cache_token(tx_cache) 27 tx_cache[token] = tx 28 return redirect_to(h.url_for('transaction', id=token)) 22 29 23 30 def create(self): sandbox/mscott/SchevoPylonsNav/trunk/schevopylonsnav/lib/app_globals.py
r2929 r2936 1 from random import randint 2 3 from lrucache import LRUCache 4 5 6 def random_token(): 7 return randint(0, 9999999) 8 9 1 10 class Globals(object): 2 11 … … 26 35 27 36 """ 28 pass 37 self.tx_cache = LRUCache(size=2048) 38 self.cache_tokens = set() 29 39 30 40 def __del__(self): … … 34 44 """ 35 45 pass 46 47 def new_cache_token(self, cache): 48 cache_tokens = self.cache_tokens 49 while True: 50 # Search for an unused token. 51 t = random_token() 52 while t in cache_tokens: 53 t = random_token() 54 # Place a 'hold' on the token. 55 cache_tokens.add(t) 56 if t in cache: 57 # Release hold. 58 cache_tokens.remove(t) 59 # Start over. 60 continue 61 # Place the token in the cache and release hold. 62 cache[t] = None 63 cache_tokens.remove(t) 64 return t sandbox/mscott/SchevoPylonsNav/trunk/schevopylonsnav/tests/functional/test_extent_transactions.py
r2935 r2936 9 9 assert 'Create' in response 10 10 11 def test_ create(self):11 def test_get_create(self): 12 12 response = self.app.get( 13 13 url_for('extent_transaction', db_id='db', extent_id='Foo', 14 14 id='create')) 15 15 assert 'Call' in response 16 17 def test_call_create(self): 18 response = self.app.post( 19 url_for('extent_call_transaction', db_id='db', extent_id='Foo', 20 id='create')) 21 assert response.status == 302 22 # response = response.follow() sandbox/mscott/SchevoPylonsNav/trunk/setup.py
r2932 r2936 27 27 'SchevoWsgi==dev,>=0.1a1dev-r2820', 28 28 'Mako', 29 'lrucache', 29 30 ], 30 31 31 32 dependency_links = [ 32 33 'http://schevo.org/wiki/ThirdPartyEggs', 34 'http://evan.prodromou.name/Software/Python/LRUCache', 33 35 ], 34 36
