Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
beaker question
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Carl  
View profile  
 More options Jul 3 2009, 11:51 am
From: Carl <tg2.u...@gmail.com>
Date: Fri, 3 Jul 2009 08:51:33 -0700 (PDT)
Local: Fri, Jul 3 2009 11:51 am
Subject: beaker question
Hi,
Can someone explain how beaker is used in TG2? I see in the Pylons
docs that it can be used to persist values across calls via cookies.

In my app it is inappropriate. I don't use it in my controller
methods, but beaker still sets a cookie (beaker.session.id).

Can I turn it off via configuration or some other way?

Thanks, Carl


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Diez B. Roggisch  
View profile  
 More options Jul 6 2009, 5:54 am
From: "Diez B. Roggisch" <de...@web.de>
Date: Mon, 6 Jul 2009 11:54:40 +0200
Local: Mon, Jul 6 2009 5:54 am
Subject: Re: [TurboGears] beaker question
On Friday 03 July 2009 17:51:33 Carl wrote:

> Hi,
> Can someone explain how beaker is used in TG2? I see in the Pylons
> docs that it can be used to persist values across calls via cookies.

> In my app it is inappropriate. I don't use it in my controller
> methods, but beaker still sets a cookie (beaker.session.id).

> Can I turn it off via configuration or some other way?

Not directly via config, no.

What you can do is to subclass AppConfig in

myproject.config.app_cfg

and override the

    def add_core_middleware(self, app):
        """Add support for routes dispatch, sessions, and caching."""
        app = RoutesMiddleware(app, config['routes.map'])
        app = SessionMiddleware(app, config)
        app = CacheMiddleware(app, config)
        return app

method with this:

    def add_core_middleware(self, app):
        """Add support for routes dispatch, sessions, and caching."""
        app = RoutesMiddleware(app, config['routes.map'])
        return app

This is untested - but it should rid you of beaker.

Diez


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gigi  
View profile  
 More options Jul 7 2009, 12:12 am
From: Gigi <the.g...@gmail.com>
Date: Mon, 6 Jul 2009 21:12:26 -0700 (PDT)
Local: Tues, Jul 7 2009 12:12 am
Subject: Re: beaker question
Diez,
Your post pointed me in the right direction. I tried your idea, but
the SessionMiddleware is needed (they call it core middleware  for a
reason). Other code expects it to be there, so it can't be just
removed. Instead, I went one level deeper and modified the
SessionMiddleware itself to NOT set a cookie. I didn't want to modify
the beaker package itself of course (bad practice). I could in theory
subclass the beaker SessionMiddleware and then sublass AppConfig to
add my custom SessionMiddleware, but it becomes a little cumbersome.
So, I ended up just replacing the __call__the method of the original
beaker SessionMiddleware in my AppCfg.py file. The commented lines
bellow are the lines that set the cookie:

### Start code #####
from beaker.middleware import SessionMiddleware
from beaker.session import SessionObject
def custom_session_middleware__call__(self, environ, start_response):
    session = SessionObject(environ, **self.options)
    if environ.get('paste.registry'):
        if environ['paste.registry'].reglist:
            environ['paste.registry'].register(self.session, session)
    environ[self.environ_key] = session
    environ['beaker.get_session'] = self._get_session

    def session_start_response(status, headers, exc_info = None):
        #if session.accessed():
        #    session.persist()
        #    if session.__dict__['_headers']['set_cookie']:
        #        cookie = session.__dict__['_headers']['cookie_out']
        #        if cookie:
        #            headers.append(('Set-cookie', cookie))
        return start_response(status, headers, exc_info)
    return self.wrap_app(environ, session_start_response)

SessionMiddleware.__call__ = custom_session_middleware__call__
### End code #####

Thanks,  Karl

On Jul 6, 2:54 am, "Diez B. Roggisch" <de...@web.de> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »