On Thu, Mar 6, 2014 at 10:20 PM, Marek Salat <[email protected]>wrote:

> Hi,
> I am new in turbogear. I was looking for good python web mvc framework
> quite long time, hopefully I have found it ;) I do not like django because
> its more mtv than mvc. And I like sqlalchemy (not possible in django) and
> jinja. So turbogear was my choice.
>
> But I used to from different mvc web frameworks (like asp .net mvc, nette,
> symphony) to different routing system (maybe this is why I do not like
> django). Is in turbo gear possible to make custom routes like
> "{controller}/{action}/{id}" with default parameters "home/index"? I am
> used to for this and its really cool when you can choose controller
> depending on url (for example rest api or custom administration). And also
> it is good, because you can choose how routes will look at the end of
> developing or you can change it whenever you like on running web in one
> place without changing structure of project. Now its more like that
> structure of project is saying how urls will look like.
>
>
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.

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.


> 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.


>
> 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.

-- 
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/groups/opt_out.

Reply via email to