Erik, I've actually changed the code quite a bit but the problem i'm having still exists.
You see trac (for whatever reason) doesn't call the authenticate() method once per request, it calls it quite a few times - which is why i'm having this problem. As for cookies, well i'm using my sites login cookies to log the users into trac, so they can jump between my site and trac seamlessly and without needing to re-login. My issue now is two fold, I want to make it so subsequent calls to this method return the users authenticated username (so i'm not doing multiple slow XML HTTP requests every load) and I also want to display login errors by calling chrome.add_notice(req, "Error loading login API.") but it seems anytime you use the "req" variable in this function trac goes into an infinite loop. help would be very much appreciated. On May 27, 9:36 pm, Erik Bray <[email protected]> wrote: > 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 -~----------~----~----~----~------~----~------~--~---
