As expected, every time the problem appears (that is, I submit a form and
get challenged to login again), there's an additional/new session file in
the session dir. The only usages of 'session' are reading/writing, such as
session.meetInfo.currAssgmts = False
attachments = session.meetInfo.attachments
Would a redirect in my controller be doing anything to reset the session?
Here's my controller that's involved. Note the call to setupMeetInSession.
I'm assuming (uh-oh) that this isn't recreating a session:
@auth.requires_login()
def send_info():
setupMeetInSession()
if request.post_vars.sendBtn:
attachments = session.meetInfo.attachments
recipients = request.post_vars.recips.split(',')
mailResult = mail.send(recipients,
subject = request.post_vars.subject,
message = request.post_vars.message,
attachments = attachments
,cc = ['[email protected]',
'[email protected]']
)
if mailResult:
session.flash = 'Email(s) sent'
if request.args(0) == 'Meet':
url = 'all_meets'
elif request.args(0) == 'Team':
url = 'all_teams'
elif request.args(0) == 'Person_certification':
url = 'all_officials'
elif request.args(0) == 'Official':
url = 'all_officials'
else:
url = 'index'
redirect(URL(url))
else:
response.flash = 'Error sending mail'
else:
if request.args(0) == 'Meet':
retVals = send_info_meet()
elif request.args(0) == 'Team':
retVals = send_info_team()
elif request.args(0) == 'Official':
retVals = send_info_official()
else:
print '******** Got bogus args(0): ' + request.args(0)
redirect(URL('index'))
session.meetInfo.attachments = retVals.attachments
form = FORM(
FIELDSET('Subject: ',
INPUT(_name='subject', value=retVals.subject)),
FIELDSET('Recipients: ',
INPUT(_name='recips',
value=','.join(retVals.recipients))),
FIELDSET('Message: ',
TEXTAREA(_name='message', value=retVals.message)),
INPUT(_type='submit', _value='send', _name='sendBtn'),
INPUT(_type='submit', _value='cancel', _name='cancelBtn')
,FIELDSET('debug', TEXTAREA(value='retVals len: %d; sess len: %d'
% (len(retVals.attachments), len(session.meetInfo.attachments))))
)
return dict(form=form)
def setupMeetInSession():
session.meetInfo = session.meetInfo or Storage()
return
The view is simple:
{{extend 'layout.html'}}
{{"""
Send meet information
"""}}
<h2>{{=' '.join(x.capitalize() for x in request.function.split('_'))}}</h2>
{{=form}}
{{if request.is_local:}}
{{=response.toolbar()}}
{{pass}}
???
Thanks in advance.
On Wednesday, October 31, 2012 10:29:14 AM UTC-6, Niphlod wrote:
>
> inspect the session/ folder and clean it.
> Then try again with your preferred browser and see if a file is created.
> Then make sure that another file doesn't get created as long as you don't
> clear the cache/open the page with another browser
> Then make sure that for every time you store something in session
> (session.something = 1) the session file is updated (watch the last
> modified time)
>
>
> On Wednesday, October 31, 2012 5:02:01 PM UTC+1, MichaelF wrote:
>>
>> Any pointers on how I can debug this? Should I insert a debug trace and
>> step through the controller and the view? Should I enable logging and
>> insert various log statements?
>>
>> Thanks.
>>
>> On Monday, October 8, 2012 4:19:59 PM UTC-6, MichaelF wrote:
>>>
>>> I've seen this before but I cannot remember what's causing it.
>>>
>>> I have @auth.requires_login() decorating several of my controller
>>> functions. I log in first, 'go' to one of those controller functions/pages
>>> in my browser, and I get challenged to log in (even though I'm already
>>> logged in). I log in and it takes me where I want to go. On that page I
>>> fill out a form and submit it. That page/controller requires login, and I'm
>>> challenged again, even though the previous page (where I pressed 'submit')
>>> said I was logged in. How did I get logged out?
>>>
>>> On a related note: I take out the 'requires_login' decoration and run.
>>> It seems, though, that the session isn't working. (I know, I know; it's
>>> working, but I'm doing something to prevent it from doing so!) For example,
>>> on the page/controller that creates the form I save a Storage object in
>>> session.meetInfo. When I submit, session.meetInfo isn't there. 'session' is
>>> there but not meetInfo. I have no session.forget() calls anywhere (that I
>>> can see).
>>>
>>> This happens in Chrome and Firefox. I close all Chrome/FF tabs/windows
>>> and start fresh (without restarting); no luck. This is Windows 7, web2py
>>> 2.x.
>>>
>>> Thoughts/suggestions?
>>>
>>
--