def __init__(self):
object.__init__(self)
- def decode(self, path, data=None, has_id=False):
- """Convert the """
+ def decode(self, path, data=None):
+ """Convert the path into a handler, a resource, data, and extra_path"""
if data is None:
data = {}
- if len(path) < 2 or not hasattr(self, path[1]):
- if len(path) == 1:
- resource = self.instantiate(*data)
- else:
+ if len(path) < 2 or not (path[0] is None or hasattr(self, path[0])):
+ if len(path) == 0:
resource = None
+ else:
+ resource = self.instantiate(**data)
return self, resource, data, path[1:]
if len(path) > 2:
data[path[1]] = path[2]
class ProjectHandler(PrestHandler):
def dispatch(self, project_data, project, *args, **kwargs):
self.project_id = project_data['project']
+ self.project_data = project_data
self.resource = project
self.args = args
self.kwargs = kwargs
self.assertEqual(['bloop', 'yeah'], extra)
foo.default(*['project', '27', 'extra'], **{'a':'b', 'b':'97'})
self.assertEqual(foo.project.args, ('extra',))
+ self.assertEqual(foo.project.kwargs, {'a':'b', 'b':'97'})
+ self.assertEqual(foo.project.project_data, {'project': '27'})
+ self.assertEqual(foo.project.resource, ['27'])
def test():
patchesTestSuite = unittest.makeSuite(PrestTester,'test')