Created
July 7, 2010 23:13
-
-
Save chrisdickinson/467430 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Fab(object): | |
def __enter__(self): | |
self._stack = [] | |
return self | |
def __exit__(self, *args, **kwargs): | |
print self._stack | |
def __call__(self, *args): | |
self._stack += args | |
return self | |
def tmpl(self): | |
print "tmpl\t", self | |
return self | |
def listen(self, *args): | |
print "listen\t", self | |
return self | |
with Fab() as fab: | |
(fab)\ | |
(listen, 0xFAB)\ | |
(r'^hello/$')(tmpl)\ | |
( "hello, {{ self }}")\ | |
(r'(?P<what>\w+)/$')(tmpl)\ | |
( "hello, {{ self.what }}")\ | |
(404) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment