Files
deb-python-wsme/wsme/rest.py
Christophe de Vienne 3fa27294de Start implementing the rest json proto
--HG--
rename : wsme/tests/__init__.py => wsme/tests/protocol.py
2011-09-18 22:19:38 +02:00

21 lines
584 B
Python

class RestProtocol(object):
name = None
dataformat = None
content_types = []
def accept(self, root, request):
if request.path.endswith('.' + self.dataformat):
return True
return request.headers.get('Content-Type') in self.content_types
def handle(self, root, request):
path = request.path.split('/')
a = root
for name in path:
a = getattr(a, name)
if not hasattr(a, '_ews_description'):
raise ValueError('Invalid path')
fonc = a
kw = self.get_args(req)