to be honest I didnt expect answer, good you, thanks :)
 

> For dynamic things it's usually common to use the _lookup method to create 
> the subcontroller in charge of serving the request. For example in case of 
> a blog archive that has to serve the "/archive/2014/index" url, you might 
> want to create an ArchiveController with a _lookup method that return the 
> controller in charge of serving the posts for that year.
>
> Another option is to take at look at tgext.routes ( 
> https://pypi.python.org/pypi/tgext.routes ), it permits to attach custom 
> urls to subcontrollers using routes with variables and parameters, much 
> like Django and other framework do.
>
>
The main problem is, how to change routes structure without changing 
structure of code. At this point maybe it is little bit overhead and maybe 
your model will be enough for most of my cases. But sometimes there might 
be special cases. I have little bit experimented with config['routes.map']and 
put in gobals __init__ this
 
   map.connect('common', '/{controller}/{action}', 
controller='routes_placeholder', action='routes_placeholder',)
   map.connect('homeAction', '/{action}', controller='root', 
action='routes_placeholder',)
   map.connect('home', '/', controller='root', action='index',)

   config['routes.map'] = map

last to routes works, that is nice (/, /someAction ...). But there is 
problem with first one. I have HomeController with only one method (index). 
When I put url localhost:8080/home/index, according to my log, 
HomeController is created but I get this error TypeError: 'ErrorController' 
object is not callable maybe because there is this error = ErrorController()in 
RootControler. Or maybe there might be only one place-holder in map.connect.

 

> My suggestion is anyway to stick as much as possible to ObjectDispatch, it 
> has the great advantage of making clear where an URL is implemented when 
> working in a team and avoids the unnecessary need of fighting with regular 
> expressions.
>



How I said, I do not want to have harcoded routes in code, I do not want to 
routes be dictated by project structure, but I wantto have routes somewhere 
else in one place, usually route like {contoller} /{action}/{id} is enough.

Second question is. Its possible to somehow not explicitly define path to 
>> view in @expose((? lets say by convention? example for controller 
>> HomepageController and view index, will be searching for template in 
>> /template/homepage/index.jinja?
>>
>
> Yes, just provide the path to the template file. In case the exposed 
> template path ends with an extension (like .jinja) it will be loaded with 
> the plain file path loader instead of using the dotted names lookup. Just 
> keep in mind that dotted names lookup is usually a better solution as 
> promotes the division of controllers and their templates into separate 
> python packages which can be reused by multiple projects.
>


I know I can write it like @expose('myapp.templates.index), but its not 
clean, usually we have convention in controllers structure same as in 
templates structure. So there is always pattern where to search for 
template for given controller. Therefore "'myapp.templates.index" in 
@expose is redundant information I want to avoid. I think it will be nicer 
if the framework tries fist look up for the template by convention rather 
than hardoced path in @expose even if its in dot notation. I hope you 
understand me 
 

>
>> And if you read this, maybe last question. I have been making some apps 
>> which required localized urls (example for english "home/about" but for 
>> czech "domu/o-nas") is it possible in turbogear?
>>
>>
> Creating url aliases is usually as simple as assigning the same controller 
> to multiple properties with different names, the same happens for methods.
> If you need more complex handling you can again rely on the _lookup method 
> to serve the right subcontroller depending on the request.
>

_lookup seems to be answer to everything

Thank you, your project its great and you are great :)

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.

Reply via email to