On Wed, Nov 19, 2008 at 12:47 PM, Andrew Stone <[EMAIL PROTECTED]> wrote: > Hi Jorge, > > Thanks for your reply. Unfortunately, I don't think that your solution will > quite work for my application, which it just occurred to me from reading > your solution is probably a pretty interesting (i.e. different) TG > application. > > I am essentially using TG to manage a live cluster of systems. So my > "model" isn't actually stored in the database, its pulled directly from the > cluster's current state. Now, I don't have threading issues -- if 2 users > get on at the same time nothing will die or crash. But what may happen is > that someone will be trying to upload new software onto a node at the same > time that another person is trying to reboot it! This is the sort of > operation I am trying to avoid. Since operations like "upload software" > span multiple web pages & requests, I can't use a simple thread lock (also, > I wouldn't want to lock someone out without a web response for more then a > few seconds). A simple way to do this is to only let 1 person with the > permissions to do things like reboot the system on at a time. > ok I can't think of a better way of doing that with some queue implementation, but fine, it seems you know what you are doing.
> So I really want to do something like write a custom "log in" that only > allows 1 user (of a certain group) to log in at a time. Or I could use a > global "lock" variable on the top of the relevant pages that only lets 1 > session through, and redirects all other requests. But to do any of these > things, I need to be able to examine all active sessions (I enabled the idle > timeout so the session will be destroyed if the user forgets to log out) & I > can't find an API to do so. I could keep track of the sessions myself but > then I would have to do my own idle timeout logic which might not keep in > sync with the idle timeout logic in TG, resulting in cases where noone could > log in, etc. > my suggestion will be first to turn off the cookie stuff, you don't want to time it out at say 30min and have the system looked for that amount of time so browser close = logout then you need a common place to store this "state" I suggest a field in the db or some kind of global lock. > Is there a way to get a list of all currently active sessions in TG? > the rest of the solution depends if you are using tg1 or tg2? > Thanks, > Andrew > > > On Wed, Nov 19, 2008 at 6:16 AM, Jorge Vargas <[EMAIL PROTECTED]> > wrote: >> >> On Mon, Nov 17, 2008 at 2:37 PM, AndrewStone <[EMAIL PROTECTED]> >> wrote: >> > >> > Is there any way to limit the number of simultaneous sessions >> > (preferably by priviledge). For example I only want one "admin" to be >> > able to log on at a time so that 2 users' changes do not conflict. >> > >> the proper way of handling this is for your app to be thread safe & db >> safe, sqlalchemy should take care of most of this. if you have "long >> lasting user sessions" a solution for this is to add a timestamp field >> named last_modified to the table in question and check that before >> each save, giving back the user an error, asking him to refresh the >> page (hence load the new data). >> >> > It seems like a common request, but I've been doing a lot of searching >> > on this list and in the web in general and haven't come up with any >> > hits! >> > >> > Thanks for any help, >> > Andrew >> > >> > > >> > >> >> > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears" 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/turbogears?hl=en -~----------~----~----~----~------~----~------~--~---

