>
> ... in router.example.py? In my case default_application = 'init', 
> default_controller = 'default' and default_function = 'index'  What do you 
> mean by 'and specify the list of available functions in the default router' 
> . My application contains 15 controllers and almost 100 functions, do I 
> have to list them all in functions = '' or do I have to just list the 
> functions in default_controller = 'default', controllers = 'DEFAULT',
>

Instead of

    functions=None,

do

    functions=['index', 'func1', 'func2']  # list all the functions in the 
default controller

When the router sees /code/shortname, it will know "code" is not a 
controller and also not one of the functions in the default controller, and 
it will therefore assume it is an arg.
 

> then in http://yourdomain.com/code/shortname, code and shortname will be 
>> interpreted as request.args[1:2], with the request being routed to the 
>> default app, controller, and function.
>
>
> In my case init/default/index which implies that in the index function I 
> have to do something like:
>
>
> def index():
>     if request.args(0)==code:
>         
> row=db(db.auth_user.shortname==request.args(1)).select(db.auth_user.nodeID).first()
>         
> account=db(db.NodeAccount.nodeID==row.nodeID).select(db.NodeAccount.accountID).first()
>         if account.accountID==BASICACCOUNTID:
>             redirect(URL('vcard',args=row.nodeID))
>         elif account.accountID==ADVANCEDACCOUNTID:
>             redirect(URL('site','index',args=row.nodeID))
>         elif account.accountID==HUBACCOUNTID:
>             redirect(URL('hub','index',args=row.nodeID))
>     else:
>         return dict()
>

Yes, though technically you don't have to do it in the index function. 
Instead, in a model file, you could do:

if request.controller == 'default' and request.function == 'index' andrequest
.args(0) == 'code':
    [check the db and do a redirect]

Anthony 

Reply via email to