the only thing you know about a user "logged in" is that his session has a
session.auth key with data filled in. You can't know without further
modification to web2py's code if a user is logged in in any other way.
So, you need to read the session files (all of them).
Session files are usually stored into
yourapplication/sessions/remoteip.uuid files.
This files are in "pickle" format, so you must unpickle them and read as
they were a dictionary.
import cPickle
with open(session_file, 'rb') as session:
data = cPickle.loads(session.read())
print data
"data" contains the session data. Elaborate further your processing logic
as you wish
On Monday, October 22, 2012 11:28:18 PM UTC+2, Saurabh Kumar wrote:
>
> Hi, can you elaborate a bit more on as to how to do this in code? I am
> somewhat confused.
>
> On Monday, October 22, 2012 8:34:21 AM UTC-4, Niphlod wrote:
>>
>> you must load all the session files, unpickle them and see if there is an
>> auth.user key in it.
>>
>> On Monday, October 22, 2012 12:55:12 PM UTC+2, Saurabh Kumar wrote:
>>>
>>> By external python script, I mean a python script run using following
>>> command:
>>>
>>> python web2py.py -S app_name -M -R
>>> applications/app_name/private/script.py
>>>
>>> I have to check if the user with a given user_id is 'logged in' inside
>>> this script.
>>>
>>
--