diff options
author | Ben Bangert <ben@groovie.org> | 2009-08-04 23:33:52 -0700 |
---|---|---|
committer | Ben Bangert <ben@groovie.org> | 2009-08-04 23:33:52 -0700 |
commit | b64dfa2bab5cec7447145b2cf44799fb24ad2c1b (patch) | |
tree | e74a2245c27188639fbfc4159863f5cc1011418a /routes | |
parent | 2f90f8c2b29512b37421c3fd0d7fe5b9656a89b6 (diff) | |
download | routes-b64dfa2bab5cec7447145b2cf44799fb24ad2c1b.tar.gz |
Enable use of the submapper with the with statement
--HG--
branch : trunk
Diffstat (limited to 'routes')
-rw-r--r-- | routes/mapper.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/routes/mapper.py b/routes/mapper.py index 4198532..6bd2109 100644 --- a/routes/mapper.py +++ b/routes/mapper.py @@ -26,7 +26,7 @@ class SubMapper(object): def __init__(self, obj, **kwargs): self.kwargs = kwargs self.obj = obj - + def connect(self, *args, **kwargs): newkargs = {} newargs = args @@ -45,6 +45,13 @@ class SubMapper(object): newkargs[key] = kwargs[key] return self.obj.connect(*newargs, **newkargs) + # Provided for those who prefer using the 'with' syntax in Python 2.5+ + def __enter__(self): + return self + + def __exit__(self, type, value, tb): + pass + class Mapper(object): """Mapper handles URL generation and URL recognition in a web |