On May 1, 11:39 am, Remy Blank <[email protected]> wrote:
> Emmanuel Blot wrote:
> > Yes, that's right the environment name, not the project name.
> > "myenv" in your example.
>
> Ok, then no, I don't see how you could do it in the current state. Time
> to add:
>
> project.dir = os.basename(self.env.path)
>
> or possibly:
>
> project.path = self.env.path
>
> in Chrome!
>
My first question is to ask what you are actually trying to achieve -
ie. what could you need the disk folder name for?
The disk location can be read from req.environ, specifically either
req.environ['trac.env_parent_dir'] or req.environ['trac.env_path']
depending on your setup. If you run a parent setup then the project
folder name should be the last item of req.base_path (depending on how
you have mounted trac in your url).
But, again, why you need the disk folder name is still not clear to
me.... :-) However, I'd be fine with extending project dict with a
project.path - looks harmless, and simplifies the logic of looking it
up.
As I spent quite a few months struggling with my production Trac last
year, hunting down some error that turned out to be a plugin that
accidentally held on to a db connection forever, I fear the
consequences of code opening db, file and repos connections somewhere
as frail as template rendering - and certainly when we consider
current and future strategies for caching on the rendering side.
I think the age-old philosophy of separating logic and design still
holds, and I would be -1 on passing the env as default.
However, it is Python after all, and all is possible - especially
seeing built-in __import__() function is available to templates...:
<div py:with="env = __import__('trac.env', {}, {},
['open_environment]).open_environment('/path/to/trac')">
<!--! Use 'env' here.... -->
</div>
Or, use plugin code or general post_process_request to add self.env to
the template data dict (recommended approach of course).
:::simon
https://www.coderesort.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Trac
Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/trac-dev?hl=en
-~----------~----~----~----~------~----~------~--~---