minor improvements; handle NotFound more gracefully
This commit is contained in:
parent
a16c1dd469
commit
7b98616008
5 changed files with 11 additions and 7 deletions
|
@ -14,10 +14,10 @@ def zope_app_factory(config):
|
|||
storageFactory = config.StorageFactory(config)
|
||||
def zope_app(environ, start_response):
|
||||
storage = storageFactory(config.dbschema)
|
||||
appRoot = Root(storage, config)
|
||||
appRoot = Root(storage)
|
||||
request = BrowserRequest(environ['wsgi.input'], environ)
|
||||
request.setPublication(Publication(appRoot))
|
||||
request = publish(request, False)
|
||||
request = publish(request, True)
|
||||
response = request.response
|
||||
start_response(response.getStatusString(), response.getHeaders())
|
||||
return response.consumeBodyIter()
|
||||
|
@ -41,3 +41,9 @@ class Publication(DefaultPublication):
|
|||
return ob, ()
|
||||
return ob, ('index.html',)
|
||||
|
||||
def handleException(self, ob, request, exc_info, retry_allowed=True):
|
||||
if exc_info[0] != NotFound:
|
||||
raise
|
||||
request.response.reset()
|
||||
request.response.handleException(exc_info)
|
||||
|
||||
|
|
|
@ -40,6 +40,5 @@ class DefaultView:
|
|||
result = dict(head=ob.head, data=ob.data)
|
||||
if IContainer.providedBy(ob):
|
||||
result['items'] = list(ob.keys())
|
||||
print('***', result)
|
||||
return json.dumps(result)
|
||||
|
||||
|
|
|
@ -45,8 +45,7 @@ class Root(Folder):
|
|||
"""A dummy (virtual) root folder for creating real folders
|
||||
using the Folder API."""
|
||||
|
||||
def __init__(self, storage, config=None):
|
||||
self.config = config
|
||||
def __init__(self, storage):
|
||||
cont = storage.create(Folders)
|
||||
super(Root, self).__init__(container=cont)
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ from scopes.storage.folder import Root
|
|||
|
||||
|
||||
def publishRequest(config, storage, path):
|
||||
appRoot = Root(storage, config)
|
||||
appRoot = Root(storage)
|
||||
request = TestRequest(environ=dict(PATH_INFO=path))
|
||||
request.setPublication(Publication(appRoot))
|
||||
request = publish(request, False)
|
||||
|
|
|
@ -60,7 +60,7 @@ def test_tracking(self, config):
|
|||
def test_folder(self, config):
|
||||
storage = config.storageFactory(config.dbschema)
|
||||
storage.dropTable('folders')
|
||||
root = folder.Root(storage, config)
|
||||
root = folder.Root(storage)
|
||||
self.assertEqual(list(root.keys()), [])
|
||||
root['top'] = folder.Folder()
|
||||
self.assertEqual(list(root.keys()), ['top'])
|
||||
|
|
Loading…
Add table
Reference in a new issue