On Apr 5, 2012, at 6:20 AM, Cliff wrote:
> I can't understand why this isn't working.  The regular expressions seem to 
> work OK in an interactive Python session.  Details are below.
> Grateful thanks for any help.
> 
> My web site (still in development) has two applications.  The welcome app 
> will handle the marketing side, with links to demos, 'what we do' pages, 
> blogs, etc.  Another app, called operations, will host paid applications for 
> business users.
> 
> A url like mysite.com or www.mysite.com should go to the welcome app.  A url 
> with a subdomain, like yourcompany.mysite.comshould go to the operations app.
> 
> This set of routes almost works.  For example, localhost:8000 goes to 
> welcome.  'dc.localhost:8000/operations' goes to operations.  But 
> 'dc.localhost:8000' gives me http://dc.localhost:8000/.*://localhost.* which 
> goes to the welcome page.
> In routes:
> ## this first route should trap "dc.localhost:8000
> ## it does not
> ## I seem to remember the router stops at the first match
>   ('.*://(?P<any>[a-z][A-Z]+)\.localhost', 
>     '\g<any>operations'
>   ),
> ## this route traps "dc.localhost:8000/operations...."
>   ('.*://(?P<any>[a-z][A-Z]+)\.localhost(?P<anything>.*)', 
>     '\g<any>operations\g<anything>'
>   ),
> ## this route traps localhost:8000
>   ('.*://localhost.*', '/welcome/default/index'), # works
> ###############################################################
> Out routes
> ## not working, as above  
> ('(?P<any>[a-z][A-Z]+)operations', 
>     '.*://\g<any>localhost/operations',
>   ),
> ## works  
> ('(?P<any>[a-z][A-Z]+)operations(?P<anything>.*)', 
>     '.*://\g<any>localhost\g<anything>',
>   ),
> ## works
>   ('/welcome/default/index', '.*://localhost.*', ),

I think you might be misinterpreting some of your evidence. What you're 
labeling as "Out routes" don't look like out routes (you can't have things like 
.* in the second string of a routes tuple). Can you show the whole table 
definition?

And [a-z][A-Z]+ won't match 'dc'. You want [a-zA-Z]+

Reply via email to