Env and vars are somewhat different, being dicts. The Proper (TM) way
for those would be target = request.vars.get('myoptionalvar', None).
The reason this is the Proper (TM) way is that you *have* to know when
you're handling undefined data (is that a None ? Or a '' ? Maybe 0 ?)
You can't just throw in a None in a middle of a controller and hope it
works out (often trading an IndexError for an even harder to debug
'unsupported operand type for None'. That would be the PHP way. Easy
on beginners - yes, effect on code quality - terrible. But let's wait
on further comments.

On May 23, 5:42 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
> yes but we do this already for request.vars and request.env
>
> anyway, I am not sure about myself about this. Let's here a few
> comments about this can I can revert it.
>
> Massimo
>
> On May 23, 10:29 am, Alexey Nezhdanov <snak...@gmail.com> wrote:
>
> > On Saturday 23 May 2009 18:42:58 AchipA wrote:> Tt does break existing 
> > properly written python code (and is very non-
> > > pythonesque).
>
> > +1 except for harshness. Masking exceptions is a BAD THING (TM)
>
> > > Think:
>
> > > try: target = request.args[0]
> > > except:
> > >    response.flash = 'No target specified'
> > >    return
>
> > > do_something(target)
> > > If this is an issue for people, I think they should improve their
> > > python skills (learn exceptions, for arg in request.args constructs),
> > > and not fight the language by framework-specific workarounds. They
> > > will benefit from it much more on the long run (as they are bound to
> > > have the same IndexError or KeyError problem anyway, just someplace
> > > else). My 0.02c.
>
> > --
> > Sincerely yours
> > Alexey Nezhdanov
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@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