There are some problems.

1)
If you notice there is no code in web2py that references auth, except in 
the gluon/tools.py module and this module is not automatically imported in 
the web2py environment. This is because I do not wish to couple auth to the 
core of web2py. Users may want to build their own authentication mechanism 
for apps. 

2)
You code assumes sessions in files. if the user uses instead 
session.connect(...) to put sessions in db, memcache, redis, or cookies, 
your code would fail to find the session.

Massimo

Massimo

On Sunday, 13 October 2013 10:21:12 UTC-5, Arnon Marcus wrote:
>
> I ended up doing this as a proof of concept:
> < in *gluon.main.serve_controller()* >
>
>     user = ''
>     sessionDict = dict(session)
>     if sessionDict.has_key('auth') and sessionDict['auth']:
>         authDict = dict(sessionDict['auth'])
>         if authDict.has_key('user') and authDict['user']:
>             userDict = dict(authDict['user'])
>             if userDict.has_key('first_name') and userDict.has_key(
> 'last_name'):
>                 user = userDict['first_name'] + ' ' + userDict['last_name'
> ]
>
>     def getBody(obj):
>         body = None
>         try:
>             body = obj.getvalue()
>         except:
>             try:
>                 body = obj.read()
>             except:
>                 pass
>
>         return body
>
>
>     logMessage = dict(user=user,
>                       controller=request.controller,
>                       function=request.function,
>                       args=request.args,
>                       vars=dict(request.vars),
>                       requestBody=getBody(request.body),
>                       responseBody=getBody(response.body))
>     print logMessage
>
> There must be better ways of doing things - how could I improve this?
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to