Hi Jorge, Yeah, this should definitely be done with SQL. You're only doing a single join, so it seems like it should be doable with SQLObject.
Were you unable to retrieve the TG_Visit *class* or the TG_Visit data? It seems like you should be able to use that existing one. Kevin On 5/22/06, Jorge Godoy <[EMAIL PROTECTED]> wrote: > What is the best way to retrieve all connected users (i.e., the ones with a > visit still valid)? I've developed a property for my User class that returns > me if an individual user is connected or not, but I have to check all users > manually and to do that I have to instantiate them... > > I could write a view -- and in fact if there's no easy way this is what I'm > going to do -- but I'd like to see if there's some mechanism that I'm missing > before writing SQL again ;-) > > > Today, my hack looks like this (proof of concept only, it will perform very > bad in production, I believe): > > > def _get_is_connected(self): > connected = None > ids_visits = model.VisitIdentity.select( > model.VisitIdentity.q.user_id == self.id) > for id in ids_visits: > connected = model.Visit.select( > model.Visit.q.expiry > datetime.now()) > if connected: > return True > else: > return False > > > Also, to make this work, I had to copy & paste code from > turbogears.visit.soprovider -- the TG_Visit class and I had to rename it as > Visit, to avoid duplicate definitions... -- because I couldn't find a way to > retrieve it directly from there. > > > I believe that if I could convert this into a static method and return a list > of user instances instead of True/False it would be more efficient... > > > TIA, > -- > Jorge Godoy <[EMAIL PROTECTED]> > > > > > -- Kevin Dangoor TurboGears / Zesty News email: [EMAIL PROTECTED] company: http://www.BlazingThings.com blog: http://www.BlueSkyOnMars.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears Trunk" 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-trunk -~----------~----~----~----~------~----~------~--~---
