Skip to content

Commit

Permalink
Handle case where SignedCookieSessionFactory is not available.
Browse files Browse the repository at this point in the history
  • Loading branch information
Preston-Landers committed Jul 24, 2017
1 parent e630a34 commit 46889a0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions velruse/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,10 @@ def default_setup(config):
specified then an in-memory storage backend will be used.
"""
# from pyramid.session import UnencryptedCookieSessionFactoryConfig
from pyramid.session import SignedCookieSessionFactory
try:
from pyramid.session import SignedCookieSessionFactory as SessionFactory
except ImportError:
from pyramid.session import UnencryptedCookieSessionFactoryConfig as SessionFactory

log.info('Using an unencrypted cookie-based session. This can be '
'changed by pointing the "velruse.setup" setting at a different '
Expand All @@ -102,8 +104,7 @@ def default_setup(config):
else:
secret = ''.join('%02x' % x for x in os.urandom(16))
log.info('autogenerated session secret: %s', secret)
factory = SignedCookieSessionFactory(
secret, cookie_name=cookie_name)
factory = SessionFactory(secret, cookie_name=cookie_name)
config.set_session_factory(factory)

# setup backing storage
Expand Down

0 comments on commit 46889a0

Please sign in to comment.