Note: I've also tried variations like .save() instead of .persist(),
and removing the redirect().

On Wed, Jun 2, 2010 at 8:55 PM, Yang Zhang <[email protected]> wrote:
> I have a simple controllers and development.ini (pasted below) that
> configure cookie-based beaker sessions with encrypt_key, validate_key,
> etc., but the cookies aren't being produced (verified from browser and
> also the rest of the application isn't seeing them). I can manually
> add cookies, though (as demonstrated). Any hints? Thanks in advance.
>
>
>
> import logging
>
> from pylons import request, response, session, tmpl_context as c, url
> from pylons.controllers.util import abort, redirect
>
> from pod.lib.base import BaseController, render
> from pod.pb import User
> from pod import model, pb
> from pod.lib.util import *
>
> from decorator import decorator
>
> log = logging.getLogger(__name__)
>
> class AuthController(BaseController):
>
>  def signout(self):
>    response.delete_cookie('podl')
>    redirect('/auth/set_user')
>
>  def set_user(self):
>    if request.method == 'GET':
>      s = model.Session()
>      users = s.query(model.User).all()
>      users = map(lambda u: unpack(pb.User(), u.val), users)
>      return render('/page/select_user.html', extra_vars={'users': users})
>
>    username = request.params.getone('username')
>    if not username:
>      abort(400)
>      return
>
>    session['a'] = 'a'
>    print repr(session)
>    session.persist() # TODO make sure we don't have session fixation
>    response.set_cookie('podl', username, max_age=60*60*24*365)
>    redirect('/' + username.split('@')[1])
>
>
>
> #
> # pod - Pylons development environment configuration
> #
> # The %(here)s variable will be replaced with the parent directory of this 
> file
> #
> [DEFAULT]
> debug = true
> # Uncomment and replace with the address which should receive any error 
> reports
> #email_to = [email protected]
> smtp_server = localhost
> error_email_from = pa...@localhost
>
> [server:main]
> use = egg:Paste#http
> host = 0.0.0.0
> port = 5000
>
> [app:main]
> use = egg:pod
> full_stack = true
> static_files = true
>
> cache_dir = %(here)s/data
> beaker.session.type = cookie
> beaker.session.cookie_domain = localhost
> beaker.session.key = pod
> beaker.session.secret = somesecret
> beaker.session.encrypt_key = myencryptkey
> beaker.session.validate_key = myvalidatekey
> # beaker.session.cookie_expires defaults to false
> # but set session timeout to be 15 days
> beaker.session.timeout = 1296000
>
> # If you'd like to fine-tune the individual locations of the cache data dirs
> # for the Cache data, or the Session saves, un-comment the desired settings
> # here:
> #beaker.cache.data_dir = %(here)s/data/cache
> #beaker.session.data_dir = %(here)s/data/sessions
>
> # SQLAlchemy database URL
> sqlalchemy.url = sqlite:///%(here)s/development.db
>
> # WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT*
> # Debug mode will enable the interactive debugging tool, allowing ANYONE to
> # execute malicious code after an exception is raised.
> #set debug = false
>
> authkit.setup.method = form, cookie
> authkit.form.authenticate.user.data = myuser:mypass
>                                      myuser2:mypass2
> authkit.cookie.secret = secretstring
> authkit.cookie.signoutpath = /auth/signout
>
>
> # Logging configuration
> [loggers]
> keys = root, routes, pod, sqlalchemy
>
> [handlers]
> keys = console
>
> [formatters]
> keys = generic
>
> [logger_root]
> level = INFO
> handlers = console
>
> [logger_routes]
> level = INFO
> handlers =
> qualname = routes.middleware
> # "level = DEBUG" logs the route matched and routing variables.
>
> [logger_pod]
> level = DEBUG
> handlers =
> qualname = pod
>
> [logger_sqlalchemy]
> level = INFO
> handlers =
> qualname = sqlalchemy.engine
> # "level = INFO" logs SQL queries.
> # "level = DEBUG" logs SQL queries and results.
> # "level = WARN" logs neither.  (Recommended for production systems.)
>
> [handler_console]
> class = StreamHandler
> args = (sys.stderr,)
> level = NOTSET
> formatter = generic
>
> [formatter_generic]
> format = %(asctime)s,%(msecs)03d %(levelname)-5.5s [%(name)s]
> [%(threadName)s] %(message)s
> datefmt = %H:%M:%S
>
> --
> Yang Zhang
> http://yz.mit.edu/
>



-- 
Yang Zhang
http://yz.mit.edu/

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to