Changeset 6408
- Timestamp:
- 08/19/08 15:26:01 (5 months ago)
- Location:
- Trunk/contributors/ChrisDent/experimental/TiddlyWeb
- Files:
-
- 5 modified
-
test/test_web_bag.py (modified) (1 diff)
-
tiddlyweb/stores/__init__.py (modified) (1 diff)
-
tiddlyweb/stores/text.py (modified) (1 diff)
-
tiddlyweb/web/bag.py (modified) (1 diff)
-
urls.map (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
Trunk/contributors/ChrisDent/experimental/TiddlyWeb/test/test_web_bag.py
r6247 r6408 209 209 assert info['policy']['delete'] == policy_dict['delete'] 210 210 211 def test_delete_bag(): 212 """ 213 PUT a new bag to the server and then DELETE it. 214 """ 215 json_string = simplejson.dumps(dict(policy={})) 216 217 http = httplib2.Http() 218 response, content = http.request('http://our_test_domain:8001/bags/deleteme', 219 method='PUT', headers={'Content-Type': 'application/json'}, body=json_string) 220 location = response['location'] 221 222 assert response['status'] == '204' 223 assert location == 'http://our_test_domain:8001/bags/deleteme' 224 225 response, content = http.request(location, method='DELETE') 226 print content 227 assert response['status'] == '204' 228 229 response, content = http.request(location, method='GET', headers={'Accept':'application/json'}) 230 assert response['status'] == '404' 231 211 232 def test_put_bag_wrong_type(): 212 233 """ -
Trunk/contributors/ChrisDent/experimental/TiddlyWeb/tiddlyweb/stores/__init__.py
r6121 r6408 27 27 28 28 def recipe_put(self, recipe): 29 pass 30 31 def bag_delete(self, bag): 29 32 pass 30 33 -
Trunk/contributors/ChrisDent/experimental/TiddlyWeb/tiddlyweb/stores/text.py
r6286 r6408 44 44 45 45 recipe_file.close() 46 47 def bag_delete(self, bag): 48 bag_path = self._bag_path(bag.name) 49 50 try: 51 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 54 shutil.rmtree(bag_path) 55 # XXX: We need to return a value so the caller knows 56 # that we did something otherwise it will choose 57 # to raise a 415. Not satisfied with this solution 58 # as it doesn't map to how the rest of the system behaves. 59 # Probably need to raise exceptions from the interface. 60 return 1 61 except NoBagError: 62 raise 63 except Exception, e: 64 raise IOError, 'unable to delete bag %s: %s' % (bag.name, e) 46 65 47 66 def bag_get(self, bag): -
Trunk/contributors/ChrisDent/experimental/TiddlyWeb/tiddlyweb/web/bag.py
r6250 r6408 17 17 from tiddlyweb.web.tiddlers import send_tiddlers 18 18 from tiddlyweb.web.http import HTTP400, HTTP404, HTTP415 19 20 def delete(environ, start_response): 21 # XXX refactor out a _determine_bag or _determine_bag_name 22 # lots of duplication going on here. 23 bag_name = environ['wsgiorg.routing_args'][1]['bag_name'] 24 bag_name = urllib.unquote(bag_name) 25 bag_name = unicode(bag_name, 'utf-8') 26 bag_name = web.handle_extension(environ, bag_name) 27 28 usersign = environ['tiddlyweb.usersign'] 29 30 bag = _get_bag(environ, bag_name) 31 bag.policy.allows(usersign, 'delete') 32 # reuse the store attribute that was set on the 33 # bag when we "got" it. 34 # we don't need to check for existence here because 35 # the above get already did 36 if bag.store.delete(bag) is not None: 37 start_response("204 No Content", []) 38 return [] 39 40 raise HTTP415, 'DELETE not supported' 19 41 20 42 def get(environ, start_response): -
Trunk/contributors/ChrisDent/experimental/TiddlyWeb/urls.map
r5818 r6408 80 80 GET tiddlyweb.web.bag:get 81 81 PUT tiddlyweb.web.bag:put 82 DELETE tiddlyweb.web.bag:delete 82 83 83 84 # tiddlers in a bag, with option filter string in the query string
