|
|
|
|
|
|
|
URL = property(lambda self: application_uri(self.environ)) |
|
|
def go(self): |
def go(self): |
name = shift_path_info(self.environ) |
name = shift_path_info(self.environ) |
if name: |
if name: |
return self.handle_child(name) |
return self.handle_child(name) |
|
|
url = application_uri(self.environ).rstrip('/') |
url = self.URL.rstrip('/') |
leaf = not self.sub_pages and type(self).handle_child == Page.handle_child |
leaf = not self.sub_pages and type(self).handle_child == Page.handle_child |
|
|
if name=='': # trailing / |
if name=='': # trailing / |
|
|
|
|
|
|
|
|
|
|
def invoke_method(self): |
def invoke_method(self): |
rm = self.environ['REQUEST_METHOD'] |
rm = self.environ['REQUEST_METHOD'] |
if rm=='HEAD' or rm in self.http_methods: |
if rm=='HEAD' or rm in self.http_methods: |
"""Override this in a subclass to return a DBAPI connection object""" |
"""Override this in a subclass to return a DBAPI connection object""" |
raise NotImplementedError |
raise NotImplementedError |
|
|
def query(self, *args, **kw): |
def cursor(self, *args, **kw): |
"""Create and return a cursor (after optionally running a query on it) |
"""Create and return a cursor (after optionally running a query on it) |
|
|
If positional arguments are supplied, they're passed to the cursor's |
If positional arguments are supplied, they're passed to the cursor's |
|
|
return cursor |
return cursor |
|
|
|
def query(self, *args, **kw): |
|
csr = self.cursor(*args, **kw) |
|
return (Row(csr,r) for rows in iter(csr.fetchmany,[]) for r in rows) |
|
|
|
|
|
class Row(object): |
|
"""Easy-access dict/object wrapper for DBAPI row tuples""" |
|
|
|
def __init__(self, cursor, row): |
|
self.__dict__ = dict(self, zip([d[0]for d in cursor.description], row)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|