I suppose because it does a db insert on every request. On Tuesday, April 23, 2013 8:26:53 AM UTC-4, Richard wrote: > > Guruyaya, could you explain why, to you, this basic simple usage stats is > unefficiant. > > Thanks > > Richard > > > On Tue, Apr 23, 2013 at 12:26 AM, guruyaya <[email protected]<javascript:> > > wrote: > >> The idea seems extremly unefficiant. Wouldn't it make more sense to build >> it from logs, on a seperate machine? >> >> >> On Tuesday, April 23, 2013 1:08:02 AM UTC+3, Richard wrote: >>> >>> Hello, >>> >>> I want to share this little snippet : >>> >>> # MODEL >>> >>> # Statistics of utilisation >>> db.define_table('usage_**statistics', >>> Field('time_stamp','datetime', default=request.now), >>> Field('client_ip','string', default=request.client), >>> Field('user_id', 'reference auth_user', default=auth.user and >>> auth.user.id), >>> Field('request_controller','**string', default=request.controller), >>> Field('request_function','**string', default=request.function), >>> Field('request_extension','**string', default=request.extension), >>> Field('request_ajax','string', default=request.ajax), >>> Field('request_args','string', default=request.args), >>> Field('request_vars','string', default=request.vars), >>> Field('request_view','string', default=request.view), >>> Field('request_http_user_**agent','string', >>> default=request.env.http_user_**agent), >>> Field('request_language','**string', default=request.env.http_** >>> accept_language), >>> Field('description', 'text'), >>> migrate=False, >>> ) >>> >>> # CONTROLLER >>> >>> def select(): >>> """ >>> Display log event into usage_statistics table. >>> """ >>> db.usage_statistics.id.**readable = False >>> table = SQLFORM.grid(db.usage_**statistics, >>> orderby=~db.usage_statistics.**time_stamp, ui='jquery-ui', formstyle = >>> 'divs',) >>> return dict(table=table) >>> >>> # VIEWS >>> >>> # Just put these two lines in ALL your views or only the views you want >>> to log and you can log what your users do!! >>> >>> {{db.usage_statistics.insert()**}} >>> {{db.commit()}} >>> >>> *Only thing I didn't figured out yet is what the best way to log delete >>> event... I thought about that :* >>> >>> # Not tested and pseudo code >>> def myeventlogcall(form) >>> if form.delete: >>> db.usage_statistics.insert() >>> db.commit() >>> >>> def update_functions(): >>> ... >>> form.process(ondelete=myevent**logcall) >>> ... >>> >>> But, it makes things complicated if case there is already ondelete in an >>> update_function... >>> >>> Any suggestion is welcome. >>> >>> Thanks >>> >>> Richard >>> >>> -- >> >> --- >> 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 [email protected] <javascript:>. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > >
-- --- 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 [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

