That still returns none.... Sadly...

On Wed, Apr 6, 2011 at 11:46 PM, Anthony <abasta...@gmail.com> wrote:

> Try
>
> def is_in_conference(f):
>     '''
>     INFO: Special decorator to validate that they are attending a
> conference.
>     '''
>     def g(f=f):
>         if not session.current_conference:
>             redirect(URL('default', 'index'))
>         f()
>     return g
>
> On Wednesday, April 6, 2011 3:45:57 PM UTC-4, encompass wrote:
>
>> Now all page controllers with the decorator return None on the screen.
>> ---
>> Jason
>>
>> On 04/06/2011 09:34 PM, Massimo Di Pierro wrote:
>> > should be
>> >
>> >
>> > def is_in_conference(f):
>> >       '''
>> >       INFO: Special decorator to validate that they are attending a
>> > conference.
>> >       '''
>> >       def g(f=f):
>> >           if not session.current_conference:
>> >               redirect(URL('default', 'index'))
>> >       return g
>> >
>> >
>> > On Apr 6, 12:18 pm, Jason Brower<enco...@gmail.com>  wrote:
>>
>> >> I think the session is lost in the decorator....
>> >> Here is my controller called "conference.py"
>> >>
>> >> def enter_conference():
>> >>       '''
>> >>       INFO:This page is for changing your session to match a particular
>> >> conference
>> >>       that a user may be attending or managing.
>> >>       '''
>> >>       print "enter_conference"
>> >>       if not request.args(0):
>> >>           redirect(URL('default', 'index'))
>> >>       conference = (db((db.conference_attenders.conference ==
>> >> request.args(0))&\
>> >>                       (db.conference_attenders.attender ==
>> >> auth.user_id))).select() or \
>> >>                    (db((db.conference.creator ==
>> auth.user_id))).select()
>> >>       if conference:
>> >>           print "The conference exists and I will now put the user in
>> the
>> >> conference."
>> >>           session.current_conference = request.args(0)
>> >>           redirect(URL('conference','index'))
>> >>       else:
>> >>           redirect(URL('default', 'index'))
>> >>
>> >> def exit():
>> >>       """
>> >>       INFO: This page simple remove them from visiting the conference.
>>
>> >> Though they are still attending.
>> >>       """
>> >>       session.current_conference = None
>> >>       redirect(URL('default', 'index'))
>> >>
>> >> def is_in_conference(f):
>> >>       '''
>> >>       INFO: Special decorator to validate that they are attending a
>> >> conference.
>> >>       '''
>> >>       if not session.current_conference:
>> >>           redirect(URL('default', 'index'))
>> >>       return (f)
>> >>
>> >> @auth.requires_login()
>> >> @is_in_conference
>> >> def index():
>> >>       """
>> >>       INFO: This page takes all the various things of the conference on
>> >> to one page.
>> >>       """
>> >>       return dict()
>> >>
>> >>
>> ---------------------------------------------------------------------------
>> -----------------
>> >> if I put enter_conference/5 for the the link it doesn't work.
>> >> If I put print session.current_conference it print's None
>> >> If I take out the decorator it works.
>> >>
>> >> So what are my options at this point?  Do I really need to put that if
>> >> statement in each method.  The decorator is so much more clean.
>> >> Best Regards,
>> >> Jason
>>
>>

Reply via email to