Great!

Thanks Anthony, that exactly what I needed.

Richard

On Wed, Feb 16, 2011 at 11:18 AM, Anthony <[email protected]> wrote:

> According to the book, controller functions that take arguments or that
> begin with a double underscore are not publicly exposed and therefore cannot
> be reached via a URL -- they can only be called from other functions. So,
> since last_hour_events function takes an argument, I think you're OK --
> access will automatically be restricted.
>
> See http://web2py.com/book/default/chapter/04#Dispatching
>
> Anthony
>
> On Wednesday, February 16, 2011 10:34:56 AM UTC-5, Richard wrote:
>
>> Hello,
>>
>> I used this scenario don't know if it good or not... I am open to
>> suggestion if it is not a good pratice.
>>
>>  def index():
>>     """
>>     Index page using the internationalization operator T and flash
>>     rendered by views/default/index.html or views/generic.html
>>     """
>>     table,nb_events=last_hour_events(tables_list)
>>     return dict(
>>         table=table,
>>         nb_events=nb_events)
>>
>>
>>  def last_hour_events(tables_list):
>>     """
>>     Establishing the list of last hour actions and return the 10 lasts of
>> the list
>>     """
>>     now = datetime.datetime.now()
>>     time_one_hour_before_now = now - datetime.timedelta(hours=1)
>>     last_hour_events_list = []
>>     for t in tables_list:
>>         for row in db(db[t].sdate >=
>> time_one_hour_before_now).select(db[t].id, orderby=db[t].sdate):
>>             last_hour_events_list.append(A(T('This is a new event in the
>> last hour'),
>>                 _href=URL(r=request,c='test', f='read',args=(db[t],row.id
>> ))))
>>     nb_events=len(last_hour_events_list)
>>     table=TABLE(last_hour_events_list[0:10])
>>     return (table,nb_events)
>>
>>  So I would like prevent the direct execution of the above function
>> ("last_hour_events").
>>
>> Wich decorator should I use?
>>
>> Also, I think listing all the decorator available with description into
>> one location somewhere in the book could be a great improvement of the
>> documentation, since there is no complete information about decorators
>> excepted mention here and there few decorator at a time.
>>
>> Richard
>>
>

Reply via email to