While I generally agree that it is a slow down in writing code, I think
that it has the positive effect of making really easy to extract parts of
the application as pluggable apps as their templates already refer to a
specific package. That provides a consistent behaviour between the
templates you load inside your application and the template you load in
partials or pluggable apps.

At least if we consider .templates.something as
APPPACKAGE.templates.something.

I would be more in favor of .templates.something being an alias to
os.basedir(Controller.__module__.__file__)/templates/something but in that
case we would break the assumption of TG apps having all their templates
inside apppackage/templates




On Tue, Jun 25, 2013 at 7:10 PM, Christoph Zwerschke <[email protected]> wrote:

> It sometimes bothers me how often the package name of a TG project is
> repeated in a controller module, both in import statements like "from
> mylongpackagename.model import MyModelClass" and in expose decorators like
> @expose("mylongpackagename.**templates.mypage").
>
> So I thought about changing the quickstart templates to use relative
> imports, but I found two problems:
>
> 1) Relative imports do not work for Genshi (generally dotted notation) in
> @expose any more (they used to work in TG1), so we would first need to add
> that feature back.
>
> 2) I read e.g. in PEP8 that relative imports are considered bad practice,
> not only the old implicit relative imports (which is obvious), but even the
> newer explicit relative imports. Unfortunately no rationale is given, I can
> only guess that it's about "explicit better than implicit" (since explicit
> relative imports are only explicit about being relative, the location is
> still implicit). I'm not sure whether "explicit better than implicit"
> overtrumps DRY here. And I don't understand why explicit relative imports
> have been introduced in Python 2 and not been removed from Python 3 if they
> are really so bad.
>
> Opinions?
>
> -- Christoph
>
> --
> You received this message because you are subscribed to the Google Groups
> "TurboGears Trunk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to 
> turbogears-trunk+unsubscribe@**googlegroups.com<turbogears-trunk%[email protected]>
> .
> To post to this group, send email to 
> turbogears-trunk@googlegroups.**com<[email protected]>
> .
> Visit this group at 
> http://groups.google.com/**group/turbogears-trunk<http://groups.google.com/group/turbogears-trunk>
> .
> For more options, visit 
> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
> .
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears Trunk" 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-trunk.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to