Created
February 19, 2014 22:56
-
-
Save jvanasco/9103419 to your computer and use it in GitHub Desktop.
better ISession interface
This file contains 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 ISession(IDict): | |
... | |
... | |
... | |
id = Attribute('String `id`') | |
cookie_name = Attribute('String `cookie_name`') | |
cookie_value_in = Attribute('String `cookie_value_in`') | |
cookie_value_out = Attribute('String `cookie_value_in`') | |
... | |
... | |
... | |
This file contains 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
@implementer(ISession) | |
class CookieSession(dict): | |
... | |
... | |
def __init__(self, request): | |
... | |
... | |
self.cookie_name = cookie_name | |
... | |
... | |
## would need to handle id, cookie_value_in , cookie_value_out |
This file contains 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
def BeakerSessionFactoryConfig(**options): | |
""" Return a Pyramid session factory using Beaker session settings | |
supplied directly as ``**options``""" | |
class PyramidBeakerSessionObject(SessionObject): | |
... | |
... | |
... | |
... | |
@property | |
def id(self): | |
return self._session().id | |
@property | |
def cookie_name(self): | |
return self.key | |
@property | |
def cookie_value_in(self): | |
return self.id | |
@property | |
def cookie_value_out(self): | |
return self.id | |
... | |
... | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment