pistacchio a écrit :
[EMAIL PROTECTED] ha scritto:
On 7 mai, 16:17, pistacchio <[EMAIL PROTECTED]> wrote:
George Sakkis ha scritto:
(snip)
What does it matter if it's a single file or a dozen under a package ?
"Installation" for pure Python packages can be as simple as copying
the package under any directory in your PYTHONPATH.
well, it doesn't matter if it's a single file or a package, but it
_does_ matter if you have to put them under the path where python is
installed because, in a typical shared web hosting environment (such the
one that i use) you don't have access to system directories.

You *never* have to install anything in the default path - install
your python libs wherever you want, and just make sure this wherever
is in your python path (usually via the PYTHONPATH environment
variable).


again, in a shared environment, you don't have access to environment variables.

Depends on the "shared environment". But even if you can't set PYTHONPATH, you can always import sys and append (or prepend) to sys.path before doing any other import.

> all you can do is copy files in your own little directory,
and that's it. this directory is never something like /share/python, but something like /home/averagejoe. and /home/averagejoe is not usually in the PYTHONPATH

Check out Mako (http://www.makotemplates.org/), it's pretty powerful
and fast.
woudl you suggest mako over cheetah?


As far as I'm concerned, I would.  Now if you're looking for a
somewhat barebone MVC framework, you may want to have a look at
web.py.


i've tried mako. sees to work fine for me, both for its potential and for its "installation" method. in fact i just copied it under my own directory

/home/averagejoe
  test.py
  /mako
    mako stuff

and the following testcase worked well:

from mako.template import Template
mytemplate = Template("hello world!")
print mytemplate.render()

can i do the same with web.py?

Can't tell, never used it. But how to deploy it is very certainly documented on the project's page.

mind that i work under an apache environment (mod_python).

mod_python ? Fine. And, if I may ask, did you actually took time to read the FineManual(tm) ?-)

http://www.modpython.org/live/mod_python-3.3.1/doc-html/dir-other-pp.html


now, back to mako. can you provide an example of blocks and nested blocks in mako? the documentation doesn't seem to be too clear in this reguard.

for example, if i want to show a table with a list of restaurants (gathered from a db query), i can construct a template like this:

<table>
% for rest in restaurants:
  <tr>${rest}<tr>
% endfor
</table>

but what if if each restaurant has a list of dishes (pasta, pizza, meat, pie)

Depends... What kind of object is 'rest' ? How is this list named ?

and some (or each) dish has the ingrediets?

Same question.

is it just like embedding pure python into the template ( like $(rest['dish']) and $rest['dish']['ingredient']) )?

What goes inside ${} are ordinary Python expressions, yes.

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to