On Wed, May 27, 2009 at 9:19 AM, Erik Bray <[email protected]> wrote: > On Tue, May 26, 2009 at 11:03 PM, Scott <[email protected]> wrote: >> >> How can I set variables in python / trac that are reset to null every >> page load? According to your comment above I used class level >> variables which persist across page reloads even when different people >> are viewing the page. >> >> What I want to do every page load is (psudocode): >> >> user_authenticated = False >> >> if not user_authenticated: >> run auth code >> user_authenticated = True >> >> Problem is, the value or user_authenticated is saved across all page >> loads, when I actually just want it set once and remembered for the >> current page load by python / trac. Hopefully this explains what i'm >> after. > > Well, where is `user_authenticated` being set and what are you doing > with it? Does it need to be passed along through multiple components > in the course of the request? I assume yes, since otherwise there'd > be little point to what you're asking. > > Anyways, req.authname already tells you whether or not a user has been > authenticated, so I'm not sure why you would need to add something > else for this.
Ack, sorry, I just realized that you posted your code in your first post, so now I see what you're doing. Get rid of self.authname, first of all. That variable is only used locally to your authenticate() method, so there's no sense in making it an attribute of anything. And your authenticated variable is also, like I said, unnecessary, as is that if statement at the beginning of your authenticate() method. Authentication is only performed once per request. But what really don't get about this, is why are you having your users provide their username and password as cookies?! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Trac Development" 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/trac-dev?hl=en -~----------~----~----~----~------~----~------~--~---
