I suppose you could set a global default constructor and default
function (in db.py?).  If not set then the behaviour would be exactly
as before.  Other people would probably have a better idea of this
than me.

Bill

On Jan 21, 5:27 pm, Timothy Farrell <[email protected]> wrote:
> Well, would this be considered breaking backward compatibility?  Since
> before, if something wasn't there, it would automatically error, but now
> it looks somewhere else?  If someone had a default function already in
> their controller, this could cause undesired effects.
>
> I'm generally in favor of this behavior.  It has the potential to clean
> up things for a lot people and reduce the dependency on routes and
> error_routing.
>
> -tim
>
>
>
> mdipierro wrote:
> > Let's hear some pros/cons from other users.
>
> > On Jan 21, 8:36 am, billf <[email protected]> wrote:
>
> >> I'm interested in different forms of url's and had a read about
> >> routes.py.  But the manual tells me my app shouldn't rely on routes.py
> >> being present.  So I thought of the following approach  (it's the
> >> result of all of 15 minutes thinking/code/test so don't expect too
> >> much).
>
> >> * I want to be able to 
> >> recognisehttp://myserver/myapp/anytable/an_optional_id
>
> >> * let's assume I have a table 'user' and a controller 'default.py'
> >> that contains a function 'default()'
>
> >> * in compileapp.py the code identifies (or not) the controller and
> >> function and outputs 'invalid controller' or 'invalid function' as
> >> appropriate
>
> >> * my change  basically says: if you don't find the controller try
> >> again with a default value 'default' before failing and if you don't
> >> find the function try again with the value 'default' before failing
>
> >> * in addition, each time it defaults it pushes the lower element to
> >> args[]
>
> >> * so when I enterhttp://myserver/myapp/user/1controlis passed to
> >> the default() function of the default.py controller and the two args
> >> are 'user' and '1'
>
> >> The code changes in compileapp.py start at line 190 and are marked
> >> below (new stuff):
>
> >>     else:
> >>         filename=os.path.join(folder,'controllers/%s.py' % controller)
> >>         if not os.path.exists(filename):
> >>             # new stuff
> >>             default_controller='default'
> >>             filename = os.path.join(folder,'controllers/%s.py' %
> >> default_controller)
> >>             if os.path.exists(filename):
> >>                 request=environment['request']
> >>                 request.args.insert(0,function)
> >>                 request.function=request.controller
> >>                 request.controller=default_controller
> >>             else:
> >>             # end of new stuff
> >>                 raise HTTP(400,error_message_custom % 'invalid
> >> controller',
> >>                            web2py_error='invalid controller')
> >>         code=open(filename,'r').read()
> >>         exposed=regex_expose.findall(code)
> >>         if not function in exposed:
> >>             # new stuff
> >>             default_function='default'
> >>             function=default_function
> >>             if function in exposed:
> >>                 request=environment['request']
> >>                 request.args.insert(0,request.function)
> >>                 request.function=default_function
> >>             else:
> >>             # end of new stuff
> >>                 raise HTTP(400,error_message_custom % 'invalid
> >> function',
> >>                            web2py_error='invalid function')
>
> >> Enjoy!
>
> --
> Timothy Farrell <[email protected]>
> Computer Guy
> Statewide General Insurance Agency (www.swgen.com)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to