(second attempt: was not showing in the listing of posts!)

Hi I got this all working - problem was due to way vars where defined
in a SQLFORM.factory.
I am developing my code further and added basic validation that the
username and password inputs
are not blank prior to submitting twiitter_update function.
I am trying to now catch a bad username / password which throws a
html
401 . I would like to know if I can code
to catch this authentication error returned from the twitter site in
my code and send feedback to user.

in controller I have the following snippet as part of a larger
function:


  if form.accepts(request.vars,session):
    session.no_table_username = request.vars.no_table_username
    session.no_table_password = request.vars.no_table_password
    if not (session.no_table_username=="" and
session.no_table_password=="") :
       twitter_post
(session.no_table_username,session.no_table_password,form.vars.Message)


returns
Traceback (most recent call last):
  File "C:\APPS\augmi\gluon\restricted.py", line 184, in restricted
    exec ccode in environment
  File "C:/APPS/augmi/applications/init/controllers/default.py", line
152, in <module>
  File "C:\APPS\augmi\gluon\globals.py", line 103, in <lambda>
    self._caller = lambda f: f()
  File "C:\APPS\augmi\gluon\tools.py", line 1618, in f
    return action(*a, **b)
  File "C:/APPS/augmi/applications/init/controllers/default.py", line
134, in my_augmi
    twitter_post
(session.no_table_username,session.no_table_password,form.vars.Message)
  File "C:/APPS/augmi/applications/init/controllers/default.py", line
23, in twitter_post
    return  gluon.contrib.simplejson.loads(urllib2.urlopen
(request).read())
  File "C:\Python25\lib\urllib2.py", line 124, in urlopen
    return _opener.open(url, data)
  File "C:\Python25\lib\urllib2.py", line 387, in open
    response = meth(req, response)
  File "C:\Python25\lib\urllib2.py", line 498, in http_response
    'http', request, response, code, msg, hdrs)
  File "C:\Python25\lib\urllib2.py", line 425, in error
    return self._call_chain(*args)
  File "C:\Python25\lib\urllib2.py", line 360, in _call_chain
    result = func(*args)
  File "C:\Python25\lib\urllib2.py", line 506, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 401: Unauthorized


any help appreciated


On Nov 30, 11:43 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:

--

You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.


Reply via email to