Changeset 6411
- Timestamp:
- 08/19/08 16:58:17 (5 months ago)
- Location:
- Trunk/contributors/ChrisDent/experimental/TiddlyWeb
- Files:
-
- 10 modified
-
googleappengine/googledata.py (modified) (1 diff)
-
test/test_web_recipe.py (modified) (1 diff)
-
tiddlyweb/store.py (modified) (1 diff)
-
tiddlyweb/stores/__init__.py (modified) (3 diffs)
-
tiddlyweb/stores/text.py (modified) (2 diffs)
-
tiddlyweb/web/bag.py (modified) (2 diffs)
-
tiddlyweb/web/recipe.py (modified) (1 diff)
-
tiddlyweb/web/search.py (modified) (2 diffs)
-
tiddlyweb/web/tiddler.py (modified) (3 diffs)
-
urls.map (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
Trunk/contributors/ChrisDent/experimental/TiddlyWeb/googleappengine/googledata.py
r6067 r6411 187 187 return [] 188 188 189 def list_tiddler_revisions(self, tiddler):190 return []191 -
Trunk/contributors/ChrisDent/experimental/TiddlyWeb/test/test_web_recipe.py
r6384 r6411 193 193 194 194 assert response['status'] == '415' 195 196 def test_delete_recipe(): 197 """ 198 DELETE the other recipe 199 """ 200 http = httplib2.Http() 201 response, content = http.request('http://our_test_domain:8001/recipes/other', 202 method='DELETE') 203 print content 204 assert response['status'] == '204' 205 206 response, content = http.request('http://our_test_domain:8001/recipes/other', 207 method='GET') 208 assert response['status'] == '404' 209 210 # what happens when we delete the same recipe again? 211 response, content = http.request('http://our_test_domain:8001/recipes/other', 212 method='DELETE') 213 assert response['status'] == '404' 195 214 196 215 def test_get_recipe_wiki_bag_constraints(): -
Trunk/contributors/ChrisDent/experimental/TiddlyWeb/tiddlyweb/store.py
r5802 r6411 10 10 11 11 from tiddlyweb.config import config 12 13 class StoreMethodNotImplemented(IOError): 14 pass 12 15 13 16 class NoBagError(IOError): -
Trunk/contributors/ChrisDent/experimental/TiddlyWeb/tiddlyweb/stores/__init__.py
r6408 r6411 4 4 system. 5 5 """ 6 7 from tiddlyweb.store import StoreMethodNotImplemented 6 8 7 9 class StorageInterface(object): … … 23 25 self.environ = environ 24 26 27 def recipe_delete(self, recipe): 28 raise StoreMethodNotImplemented 29 25 30 def recipe_get(self, recipe): 26 pass31 raise StoreMethodNotImplemented 27 32 28 33 def recipe_put(self, recipe): 29 pass34 raise StoreMethodNotImplemented 30 35 31 36 def bag_delete(self, bag): 32 pass37 raise StoreMethodNotImplemented 33 38 34 39 def bag_get(self, bag): 35 pass40 raise StoreMethodNotImplemented 36 41 37 42 def bag_put(self, recipe): 38 pass43 raise StoreMethodNotImplemented 39 44 40 45 def tiddler_delete(self, tiddler): 41 pass46 raise StoreMethodNotImplemented 42 47 43 48 def tiddler_get(self, tiddler): 44 pass49 raise StoreMethodNotImplemented 45 50 46 51 def tiddler_put(self, tiddler): 47 pass52 raise StoreMethodNotImplemented 48 53 49 54 def user_get(self, user): 50 pass55 raise StoreMethodNotImplemented 51 56 52 57 def user_put(self, user): 53 pass58 raise StoreMethodNotImplemented 54 59 55 60 def list_recipes(self): 56 pass61 raise StoreMethodNotImplemented 57 62 58 63 def list_bags(self): 59 pass64 raise StoreMethodNotImplemented 60 65 61 66 def list_tiddler_revisions(self, tiddler): 62 pass67 raise StoreMethodNotImplemented 63 68 64 69 def tiddler_written(self, tiddler): … … 71 76 72 77 def search(self, search_query): 73 pass78 raise StoreMethodNotImplemented -
Trunk/contributors/ChrisDent/experimental/TiddlyWeb/tiddlyweb/stores/text.py
r6408 r6411 18 18 19 19 class Store(StorageInterface): 20 21 def recipe_delete(self, recipe): 22 recipe_path = self._recipe_path(recipe) 23 24 try: 25 if not os.path.exists(recipe_path): 26 raise NoRecipeError, '%s not present' % recipe_path 27 os.remove(recipe_path) 28 except NoRecipeError: 29 raise 30 except Exception, e: 31 raise IOError, 'unable to delete recipe %s: %s' % (recipe.name, e) 20 32 21 33 def recipe_get(self, recipe): … … 50 62 try: 51 63 if not os.path.exists(bag_path): 52 raise NoBagError, '%s not present' % tiddler_base_filename 53 print 'bag_path to delete %s' % bag_path 64 raise NoBagError, '%s not present' % bag_path 54 65 shutil.rmtree(bag_path) 55 # XXX: We need to return a value so the caller knows56 # that we did something otherwise it will choose57 # to raise a 415. Not satisfied with this solution58 # as it doesn't map to how the rest of the system behaves.59 # Probably need to raise exceptions from the interface.60 return 161 66 except NoBagError: 62 67 raise -
Trunk/contributors/ChrisDent/experimental/TiddlyWeb/tiddlyweb/web/bag.py
r6408 r6411 11 11 12 12 from tiddlyweb.bag import Bag 13 from tiddlyweb.store import Store, NoBagError 13 from tiddlyweb.store import Store, NoBagError, StoreMethodNotImplemented 14 14 from tiddlyweb.serializer import Serializer, NoSerializationError 15 15 from tiddlyweb import control … … 34 34 # we don't need to check for existence here because 35 35 # the above get already did 36 if bag.store.delete(bag) is not None: 37 start_response("204 No Content", []) 38 return [] 36 try: 37 bag.store.delete(bag) 38 except StoreMethodNotImplemented: 39 raise HTTP400, 'Bag DELETE not supported' 39 40 40 raise HTTP415, 'DELETE not supported' 41 start_response("204 No Content", []) 42 return [] 41 43 42 44 def get(environ, start_response): -
Trunk/contributors/ChrisDent/experimental/TiddlyWeb/tiddlyweb/web/recipe.py
r6250 r6411 10 10 from tiddlyweb.recipe import Recipe 11 11 from tiddlyweb.bag import Bag 12 from tiddlyweb.store import Store, NoRecipeError, NoBagError 12 from tiddlyweb.store import Store, NoRecipeError, NoBagError, StoreMethodNotImplemented 13 13 from tiddlyweb.serializer import Serializer, NoSerializationError 14 from tiddlyweb.web.http import HTTP4 15, HTTP404, HTTP40314 from tiddlyweb.web.http import HTTP400, HTTP415, HTTP404, HTTP403 15 15 from tiddlyweb.web.tiddlers import send_tiddlers 16 16 from tiddlyweb import control 17 17 from tiddlyweb.web import util as web 18 19 def delete(environ, start_response): 20 """ 21 Delete a recipe, where what delete means 22 depends on the store used. 23 24 XXX: There are no permissions on this method. 25 There should be! 26 """ 27 recipe = _determine_recipe(environ) 28 29 try: 30 recipe.store.delete(recipe) 31 except StoreMethodNotImplemented: 32 raise HTTP400, 'Recipe DELETE not supported' 33 34 start_response("204 No Content", []) 35 return [] 18 36 19 37 def get(environ, start_response): -
Trunk/contributors/ChrisDent/experimental/TiddlyWeb/tiddlyweb/web/search.py
r6266 r6411 11 11 from tiddlyweb.bag import Bag 12 12 from tiddlyweb.auth import ForbiddenError, UserRequiredError 13 from tiddlyweb.store import StoreMethodNotImplemented 13 14 from tiddlyweb.web import util as web 14 15 from tiddlyweb.web.tiddlers import send_tiddlers … … 28 29 29 30 store = environ['tiddlyweb.store'] 30 tiddlers = store.search(search_query) 31 try: 32 tiddlers = store.search(search_query) 33 except StoreMethodNotImplemented: 34 raise HTTP400, 'Search system not implemented' 31 35 32 36 usersign = environ['tiddlyweb.usersign'] -
Trunk/contributors/ChrisDent/experimental/TiddlyWeb/tiddlyweb/web/tiddler.py
r6249 r6411 9 9 from tiddlyweb.recipe import Recipe 10 10 from tiddlyweb.bag import Bag 11 from tiddlyweb.store import Store, NoTiddlerError, NoBagError 11 from tiddlyweb.store import Store, NoTiddlerError, NoBagError, StoreMethodNotImplemented 12 12 from tiddlyweb.serializer import Serializer, TiddlerFormatError 13 13 from tiddlyweb.web.http import HTTP404, HTTP415, HTTP412, HTTP409, HTTP403, HTTP304 … … 114 114 try: 115 115 revision = store.list_tiddler_revisions(tiddler)[0] 116 except IndexError:116 except StoreMethodNotImplemented: 117 117 revision = 1 118 118 tiddler.revision = revision … … 218 218 # If a tiddler is not present in the store. 219 219 raise HTTP404, 'tiddler %s not found, %s' % (tiddler.title, e) 220 except StoreMethodNotImplemented: 221 raise HTTP400, 'no revision support' 220 222 221 223 return send_tiddlers(environ, start_response, tmp_bag) -
Trunk/contributors/ChrisDent/experimental/TiddlyWeb/urls.map
r6408 r6411 33 33 GET tiddlyweb.web.recipe:get 34 34 PUT tiddlyweb.web.recipe:put 35 DELETE tiddlyweb.web.recipe:delete 35 36 36 37 # the tiddlers produced by this recipe
