Tom, you cannot mix usage of the parameter-based and pattern-based routing 
systems, even if one is in the global routes.py and one is in an 
app-specific routes.py. You have to pick one system or the other, for now 
anyway.
 
Anthony

On Thursday, March 24, 2011 1:59:33 PM UTC-4, Tom A wrote:

> Thanks for this suggestion Massimo - it's the closest to what I'm looking 
> for.  I've tried to get it to work but no joy. 
>
> I've changed my global routes.py to use parameter based routing sand put 
> the first part of your code in the application specific routes.py.
>
> I've then put the 2nd part of your code into the default controller.  But 
> if you go to:
>
> myapp.com/Supersite/users
>
> I get:
>
> invalid controller (Supersite/users)
>
> I've tried but can't figure out a solution...
>
>
>
> On 23 March 2011 13:46, Massimo Di Pierro <massimo....@gmail.com> wrote:
>
>> yes. For example: 
>>
>> routes_in = [
>>   ('/$yoursitename/users','/init/default/users/$yoursitename'),
>> ]
>>
>> the optionally
>>
>> @request.restful()
>> def users():
>>       def GET(yoursitename):
>>              return dict(message='your site name is: '+yoursitename)
>>       return locals() 
>>  
>>
>>
>>
>>
>>  On Mar 23, 2011, at 8:31 AM, Anthony wrote:
>>
>>  Massimo, I think Tom was referring to Flask's ability to include an arg 
>> at an arbitrary place in the URL path (e.g., '/<yoursitename>/users'), not 
>> the ability to specify the routes via decorators. I think the former *can* 
>> be achieved in web2py using the pattern-based rewrite system, right?
>>  
>> Anthony
>>
>> On Wednesday, March 23, 2011 9:17:31 AM UTC-4, Massimo Di Pierro wrote:
>>
>>> This is not an option in web2py because the controller is executed 
>>> after the requests arrives not imported before (as in Flask). Anyway, 
>>> that works better for simple apps but becomes a mess if you have many 
>>> functions because the routing info is scattered all over the place. 
>>> Moreover - when it comes to rest - it requires that you use the same 
>>> function for multiple methods (GET/POST/etc) by using multiple 
>>> decorators or that you use different functions with different names to 
>>> handle different names (I do not like that). 
>>>
>>> On Mar 22, 3:13 am, Tom Atkins <min...@gmail.com> wrote: 
>>> > I might be being naive here but in Flask I can do: 
>>> > 
>>> > @app.route('/<yoursitename>/users') 
>>> > ... def editusers(yoursitename): pass 
>>> > 
>>> > print url_for('editprofile', yoursitename='Supersite') 
>>> > 
>>> > gives: 
>>> > 
>>> > /Supersite/users 
>>> > 
>>> > On 22 March 2011 05:23, Jonathan Lundell <jlu...@pobox.com> wrote: 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > > On Mar 21, 2011, at 7:44 PM, Indra Gunawan wrote: 
>>> > 
>>> > > Agree, Flask way looks more elegant (see Variable Rules). It could be 
>>> nice 
>>> > > if this way also exists on Web2Py. 
>>> > 
>>> > > On 22 March 2011 06:05, Tom Atkins <min...@gmail.com> wrote: 
>>> > 
>>> > >> I was playing with Flask and I have to say its solution to routing 
>>> is very 
>>> > >> nice: 
>>> > 
>>> > >>http://flask.pocoo.org/docs/quickstart/#routing 
>>> > 
>>> > >> The use of variable names anywhere within the URL structure is very 
>>> handy. 
>>> > >> Anything like this possible in web2py? 
>>> > 
>>> > > Flask doesn't really allow variable names anywhere; near as I can 
>>> tell 
>>> > > they're a considerably restricted version of web2py's args list.
>>
>>
>>
>

Reply via email to