PHP + TinyButStrong Python replacement

Discussion in 'Python' started by pistacchio, May 7, 2008.

  1. pistacchio

    pistacchio Guest

    hi! i'm a php user and a python programmer. i'd love to use python for
    my server side needs but i can't seem to find what i'm looking for. for
    most of my php work i use mysql and tinyButStrong
    (http://www.tinybutstrong.com) which is a very lightweight template
    engine that offers powerful functionalities. you insert TBS tags in web
    pages like:

    <div align="center" class="title-page"> [var.x] </div>

    and it replaces [var.x] with the value of global variable x. it also
    makes blocks (and nested blocks) easy to implement:

    <p class="text-example2"> [blk1;block=begin] [blk1.val]<br>
    [blk1;block=end] </p>

    in the previous code it cycles throu all the values of the array blk1.

    it does many more things, like htlm escaping, url and js encoding etc,
    conditional displaying etc, but it is not more confusing that inserting
    pieces of code into the HTML (aka: littering the code and kissing
    goodbye to the code/presentation separation). it comes in the form of a
    single file with a single class that you can easily include in the code
    and go.

    now, i've searched the net and it seems full of python-based frameworks
    for doing server side scripting and templating, but none that suits my
    needs.

    1. i like writing code and i like control. i mean, open up the
    simplest text editor and write in it. i don't want something that is
    command-line driven or that writes code for me like ">>>
    makePagesFromThisDatabase()".
    2. i want something very lightweight. i don't want dozen of options,
    pre-made blogging parts ecc. i just need a good non invasive template
    engine and the basic functions for server side scripting, like session
    managing, request parsing, functions to manipulate html code (encodings etc)
    3. i don't want to beg my hosting provider to install the libraries.
    a simple include file should do the work.
    4. object oriented programming is not required (better: i prefer
    plain old procedural programming).

    any help? thanks in advance
    pistacchio, May 7, 2008
    #1
    1. Advertising

  2. On May 7, 6:12 am, pistacchio <> wrote:
    > hi! i'm a php user and a python programmer. i'd love to use python for
    > my server side needs but i can't seem to find what i'm looking for. for
    > most of my php work i use mysql and tinyButStrong
    > (http://www.tinybutstrong.com) which is a very lightweight template
    > engine that offers powerful functionalities. you insert TBS tags in web
    > pages like:
    >
    > <div align="center" class="title-page"> [var.x] </div>
    >
    > and it replaces [var.x] with the value of global variable x. it also
    > makes blocks (and nested blocks) easy to implement:
    >
    > <p class="text-example2"> [blk1;block=begin] [blk1.val]<br>
    > [blk1;block=end] </p>
    >
    > in the previous code it cycles throu all the values of the array blk1.
    >
    > it does many more things, like htlm escaping, url and js encoding etc,
    > conditional displaying etc, but it is not more confusing that inserting
    > pieces of code into the HTML (aka: littering the code and kissing
    > goodbye to the code/presentation separation). it comes in the form of a
    > single file with a single class that you can easily include in the code
    > and go.
    >
    > now, i've searched the net and it seems full of python-based frameworks
    > for doing server side scripting and templating, but none that suits my
    > needs.
    >
    >     1. i like writing code and i like control. i mean, open up the
    > simplest text editor and write in it. i don't want something that is
    > command-line driven or that writes code for me like ">>>
    > makePagesFromThisDatabase()".
    >     2. i want something very lightweight. i don't want dozen of options,
    > pre-made blogging parts ecc. i just need a good non invasive template
    > engine and the basic functions for server side scripting, like session
    > managing, request parsing, functions to manipulate html code (encodings etc)
    >     3. i don't want to beg my hosting provider to install the libraries.
    > a simple include file should do the work.
    >     4. object oriented programming is not required (better: i prefer
    > plain old procedural programming).
    >
    > any help? thanks in advance


    Did you look at TurboGears or Django? TG uses Kid in the 1.x series
    and Genshi in 2.x (I think) for templating purposes. There's also
    Cheetah, one of the more powerful Python templating engines out there.

    http://genshi.edgewall.org/
    http://www.kid-templating.org/
    http://www.cheetahtemplate.org/
    http://turbogears.org/

    Maybe those links will get you going.

    Mike
    Mike Driscoll, May 7, 2008
    #2
    1. Advertising

  3. pistacchio

    pistacchio Guest

    Mike Driscoll ha scritto:
    > On May 7, 6:12 am, pistacchio <> wrote:
    >> hi! i'm a php user and a python programmer. i'd love to use python for
    >> my server side needs but i can't seem to find what i'm looking for. for
    >> most of my php work i use mysql and tinyButStrong
    >> (http://www.tinybutstrong.com) which is a very lightweight template
    >> engine that offers powerful functionalities. you insert TBS tags in web
    >> pages like:
    >>
    >> <div align="center" class="title-page"> [var.x] </div>
    >>
    >> and it replaces [var.x] with the value of global variable x. it also
    >> makes blocks (and nested blocks) easy to implement:
    >>
    >> <p class="text-example2"> [blk1;block=begin] [blk1.val]<br>
    >> [blk1;block=end] </p>
    >>
    >> in the previous code it cycles throu all the values of the array blk1.
    >>
    >> it does many more things, like htlm escaping, url and js encoding etc,
    >> conditional displaying etc, but it is not more confusing that inserting
    >> pieces of code into the HTML (aka: littering the code and kissing
    >> goodbye to the code/presentation separation). it comes in the form of a
    >> single file with a single class that you can easily include in the code
    >> and go.
    >>
    >> now, i've searched the net and it seems full of python-based frameworks
    >> for doing server side scripting and templating, but none that suits my
    >> needs.
    >>
    >> 1. i like writing code and i like control. i mean, open up the
    >> simplest text editor and write in it. i don't want something that is
    >> command-line driven or that writes code for me like ">>>
    >> makePagesFromThisDatabase()".
    >> 2. i want something very lightweight. i don't want dozen of options,
    >> pre-made blogging parts ecc. i just need a good non invasive template
    >> engine and the basic functions for server side scripting, like session
    >> managing, request parsing, functions to manipulate html code (encodings etc)
    >> 3. i don't want to beg my hosting provider to install the libraries.
    >> a simple include file should do the work.
    >> 4. object oriented programming is not required (better: i prefer
    >> plain old procedural programming).
    >>
    >> any help? thanks in advance

    >


    hi, thanks for replaying

    > Did you look at TurboGears or Django? TG uses Kid in the 1.x series
    > and Genshi in 2.x (I think) for templating purposes. There's also
    > Cheetah, one of the more powerful Python templating engines out there.
    >


    django is exacly the kind of giant i'm trying to avoid

    > http://genshi.edgewall.org/


    the first lines of the tutorial read:
    "First, make sure you have CherryPy 3.0.x installed"
    Now, cherrypy is something that is not properly "include a file and get
    going!"

    > http://www.kid-templating.org/


    kid seems to have a non-linear approach, but i may give it a try

    > http://www.cheetahtemplate.org/


    cheetah was something that i already considered using. have i to
    "install" it or can i just import it?

    > http://turbogears.org/


    same problem as with django!

    >
    > Maybe those links will get you going.
    >
    > Mike
    pistacchio, May 7, 2008
    #3
  4. pistacchio wrote:

    > Mike Driscoll ha scritto:
    >> On May 7, 6:12 am, pistacchio <> wrote:
    >>> hi! i'm a php user and a python programmer. i'd love to use python for
    >>> my server side needs but i can't seem to find what i'm looking for. for
    >>> most of my php work i use mysql and tinyButStrong
    >>> (http://www.tinybutstrong.com) which is a very lightweight template
    >>> engine that offers powerful functionalities. you insert TBS tags in web
    >>> pages like:
    >>>
    >>> <div align="center" class="title-page"> [var.x] </div>
    >>>
    >>> and it replaces [var.x] with the value of global variable x. it also
    >>> makes blocks (and nested blocks) easy to implement:
    >>>
    >>> <p class="text-example2"> [blk1;block=begin] [blk1.val]<br>
    >>> [blk1;block=end] </p>
    >>>
    >>> in the previous code it cycles throu all the values of the array blk1.
    >>>
    >>> it does many more things, like htlm escaping, url and js encoding etc,
    >>> conditional displaying etc, but it is not more confusing that inserting
    >>> pieces of code into the HTML (aka: littering the code and kissing
    >>> goodbye to the code/presentation separation). it comes in the form of a
    >>> single file with a single class that you can easily include in the code
    >>> and go.
    >>>
    >>> now, i've searched the net and it seems full of python-based frameworks
    >>> for doing server side scripting and templating, but none that suits my
    >>> needs.
    >>>
    >>> 1. i like writing code and i like control. i mean, open up the
    >>> simplest text editor and write in it. i don't want something that is
    >>> command-line driven or that writes code for me like ">>>
    >>> makePagesFromThisDatabase()".
    >>> 2. i want something very lightweight. i don't want dozen of options,
    >>> pre-made blogging parts ecc. i just need a good non invasive template
    >>> engine and the basic functions for server side scripting, like session
    >>> managing, request parsing, functions to manipulate html code (encodings
    >>> etc)
    >>> 3. i don't want to beg my hosting provider to install the libraries.
    >>> a simple include file should do the work.
    >>> 4. object oriented programming is not required (better: i prefer
    >>> plain old procedural programming).
    >>>
    >>> any help? thanks in advance

    >>

    >
    > hi, thanks for replaying
    >
    >> Did you look at TurboGears or Django? TG uses Kid in the 1.x series
    >> and Genshi in 2.x (I think) for templating purposes. There's also
    >> Cheetah, one of the more powerful Python templating engines out there.
    >>

    >
    > django is exacly the kind of giant i'm trying to avoid
    >
    >> http://genshi.edgewall.org/

    >
    > the first lines of the tutorial read:
    > "First, make sure you have CherryPy 3.0.x installed"
    > Now, cherrypy is something that is not properly "include a file and get
    > going!"
    >> http://www.kid-templating.org/

    >
    > kid seems to have a non-linear approach, but i may give it a try
    >
    >> http://www.cheetahtemplate.org/

    >
    > cheetah was something that i already considered using. have i to
    > "install" it or can i just import it?


    You will need to install any of these. It is part of how python is designed.
    Extendability comes with a price-tag.

    I don't know for sure, but I guess the cherrypy-requirement of genshi is
    more for the tutorial, not for the templating itself.

    Diez
    Diez B. Roggisch, May 7, 2008
    #4
  5. pistacchio

    pistacchio Guest

    Diez B. Roggisch ha scritto:
    > pistacchio wrote:
    >
    >> Mike Driscoll ha scritto:
    >>> On May 7, 6:12 am, pistacchio <> wrote:
    >>>> hi! i'm a php user and a python programmer. i'd love to use python for
    >>>> my server side needs but i can't seem to find what i'm looking for. for
    >>>> most of my php work i use mysql and tinyButStrong
    >>>> (http://www.tinybutstrong.com) which is a very lightweight template
    >>>> engine that offers powerful functionalities. you insert TBS tags in web
    >>>> pages like:
    >>>>
    >>>> <div align="center" class="title-page"> [var.x] </div>
    >>>>
    >>>> and it replaces [var.x] with the value of global variable x. it also
    >>>> makes blocks (and nested blocks) easy to implement:
    >>>>
    >>>> <p class="text-example2"> [blk1;block=begin] [blk1.val]<br>
    >>>> [blk1;block=end] </p>
    >>>>
    >>>> in the previous code it cycles throu all the values of the array blk1.
    >>>>
    >>>> it does many more things, like htlm escaping, url and js encoding etc,
    >>>> conditional displaying etc, but it is not more confusing that inserting
    >>>> pieces of code into the HTML (aka: littering the code and kissing
    >>>> goodbye to the code/presentation separation). it comes in the form of a
    >>>> single file with a single class that you can easily include in the code
    >>>> and go.
    >>>>
    >>>> now, i've searched the net and it seems full of python-based frameworks
    >>>> for doing server side scripting and templating, but none that suits my
    >>>> needs.
    >>>>
    >>>> 1. i like writing code and i like control. i mean, open up the
    >>>> simplest text editor and write in it. i don't want something that is
    >>>> command-line driven or that writes code for me like ">>>
    >>>> makePagesFromThisDatabase()".
    >>>> 2. i want something very lightweight. i don't want dozen of options,
    >>>> pre-made blogging parts ecc. i just need a good non invasive template
    >>>> engine and the basic functions for server side scripting, like session
    >>>> managing, request parsing, functions to manipulate html code (encodings
    >>>> etc)
    >>>> 3. i don't want to beg my hosting provider to install the libraries.
    >>>> a simple include file should do the work.
    >>>> 4. object oriented programming is not required (better: i prefer
    >>>> plain old procedural programming).
    >>>>
    >>>> any help? thanks in advance

    >> hi, thanks for replaying
    >>
    >>> Did you look at TurboGears or Django? TG uses Kid in the 1.x series
    >>> and Genshi in 2.x (I think) for templating purposes. There's also
    >>> Cheetah, one of the more powerful Python templating engines out there.
    >>>

    >> django is exacly the kind of giant i'm trying to avoid
    >>
    >>> http://genshi.edgewall.org/

    >> the first lines of the tutorial read:
    >> "First, make sure you have CherryPy 3.0.x installed"
    >> Now, cherrypy is something that is not properly "include a file and get
    >> going!"
    >>> http://www.kid-templating.org/

    >> kid seems to have a non-linear approach, but i may give it a try
    >>
    >>> http://www.cheetahtemplate.org/

    >> cheetah was something that i already considered using. have i to
    >> "install" it or can i just import it?

    >
    > You will need to install any of these. It is part of how python is designed.
    > Extendability comes with a price-tag.
    >


    well, the problema is exacly that i'm looking for a python module, not
    for a python library.
    most of the tasks i need are just:
    1. on the shoulders of the existing standard cgi modules, automate an
    render easier the handling of things such as sessions and requests
    2. on the shoulders of the existing standard regex module, have a simple
    but complete templating engine and html-related encoder
    pistacchio, May 7, 2008
    #5
  6. On May 7, 9:40 am, pistacchio <> wrote:

    > Diez B. Roggisch ha scritto:
    >
    >
    >
    > > pistacchio wrote:

    >
    > >> Mike Driscoll ha scritto:
    > >>> On May 7, 6:12 am, pistacchio <> wrote:
    > >>>> hi! i'm a php user and a python programmer. i'd love to use python for
    > >>>> my server side needs but i can't seem to find what i'm looking for. for
    > >>>> most of my php work i use mysql and tinyButStrong
    > >>>> (http://www.tinybutstrong.com) which is a very lightweight template
    > >>>> engine that offers powerful functionalities. you insert TBS tags in web
    > >>>> pages like:

    >
    > >>>> <div align="center" class="title-page"> [var.x] </div>

    >
    > >>>> and it replaces [var.x] with the value of global variable x. it also
    > >>>> makes blocks (and nested blocks) easy to implement:

    >
    > >>>> <p class="text-example2"> [blk1;block=begin] [blk1.val]<br>
    > >>>> [blk1;block=end] </p>

    >
    > >>>> in the previous code it cycles throu all the values of the array blk1..

    >
    > >>>> it does many more things, like htlm escaping, url and js encoding etc,
    > >>>> conditional displaying etc, but it is not more confusing that inserting
    > >>>> pieces of code into the HTML (aka: littering the code and kissing
    > >>>> goodbye to the code/presentation separation). it comes in the form of a
    > >>>> single file with a single class that you can easily include in the code
    > >>>> and go.

    >
    > >>>> now, i've searched the net and it seems full of python-based frameworks
    > >>>> for doing server side scripting and templating, but none that suits my
    > >>>> needs.

    >
    > >>>>     1. i like writing code and i like control. i mean, open up the
    > >>>> simplest text editor and write in it. i don't want something that is
    > >>>> command-line driven or that writes code for me like ">>>
    > >>>> makePagesFromThisDatabase()".
    > >>>>     2. i want something very lightweight. i don't want dozen of options,
    > >>>> pre-made blogging parts ecc. i just need a good non invasive template
    > >>>> engine and the basic functions for server side scripting, like session
    > >>>> managing, request parsing, functions to manipulate html code (encodings
    > >>>> etc)
    > >>>>     3. i don't want to beg my hosting provider to install the libraries.
    > >>>> a simple include file should do the work.
    > >>>>     4. object oriented programming is not required (better: i prefer
    > >>>> plain old procedural programming).

    >
    > >>>> any help? thanks in advance
    > >> hi, thanks for replaying

    >
    > >>> Did you look at TurboGears or Django? TG uses Kid in the 1.x series
    > >>> and Genshi in 2.x (I think) for templating purposes. There's also
    > >>> Cheetah, one of the more powerful Python templating engines out there.

    >
    > >> django is exacly the kind of giant i'm trying to avoid

    >
    > >>>http://genshi.edgewall.org/
    > >> the first lines of the tutorial read:
    > >> "First, make sure you have CherryPy 3.0.x installed"
    > >> Now, cherrypy is something that is not properly "include a file and get
    > >> going!"
    > >>>http://www.kid-templating.org/
    > >> kid seems to have a non-linear approach, but i may give it a try

    >
    > >>>http://www.cheetahtemplate.org/
    > >> cheetah was something that i already considered using. have i to
    > >> "install" it or can i just import it?

    >
    > > You will need to install any of these. It is part of how python is designed.
    > > Extendability comes with a price-tag.

    >
    > well, the problema is exacly that i'm looking for a python module, not
    > for a python library.


    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.

    Check out Mako (http://www.makotemplates.org/), it's pretty powerful
    and fast.

    George
    George Sakkis, May 7, 2008
    #6
  7. pistacchio

    pistacchio Guest

    George Sakkis ha scritto:
    > On May 7, 9:40 am, pistacchio <> wrote:
    >
    >> Diez B. Roggisch ha scritto:
    >>
    >>
    >>
    >>> pistacchio wrote:
    >>>> Mike Driscoll ha scritto:
    >>>>> On May 7, 6:12 am, pistacchio <> wrote:
    >>>>>> hi! i'm a php user and a python programmer. i'd love to use python for
    >>>>>> my server side needs but i can't seem to find what i'm looking for. for
    >>>>>> most of my php work i use mysql and tinyButStrong
    >>>>>> (http://www.tinybutstrong.com) which is a very lightweight template
    >>>>>> engine that offers powerful functionalities. you insert TBS tags in web
    >>>>>> pages like:
    >>>>>> <div align="center" class="title-page"> [var.x] </div>
    >>>>>> and it replaces [var.x] with the value of global variable x. it also
    >>>>>> makes blocks (and nested blocks) easy to implement:
    >>>>>> <p class="text-example2"> [blk1;block=begin] [blk1.val]<br>
    >>>>>> [blk1;block=end] </p>
    >>>>>> in the previous code it cycles throu all the values of the array blk1.
    >>>>>> it does many more things, like htlm escaping, url and js encoding etc,
    >>>>>> conditional displaying etc, but it is not more confusing that inserting
    >>>>>> pieces of code into the HTML (aka: littering the code and kissing
    >>>>>> goodbye to the code/presentation separation). it comes in the form of a
    >>>>>> single file with a single class that you can easily include in the code
    >>>>>> and go.
    >>>>>> now, i've searched the net and it seems full of python-based frameworks
    >>>>>> for doing server side scripting and templating, but none that suits my
    >>>>>> needs.
    >>>>>> 1. i like writing code and i like control. i mean, open up the
    >>>>>> simplest text editor and write in it. i don't want something that is
    >>>>>> command-line driven or that writes code for me like ">>>
    >>>>>> makePagesFromThisDatabase()".
    >>>>>> 2. i want something very lightweight. i don't want dozen of options,
    >>>>>> pre-made blogging parts ecc. i just need a good non invasive template
    >>>>>> engine and the basic functions for server side scripting, like session
    >>>>>> managing, request parsing, functions to manipulate html code (encodings
    >>>>>> etc)
    >>>>>> 3. i don't want to beg my hosting provider to install the libraries.
    >>>>>> a simple include file should do the work.
    >>>>>> 4. object oriented programming is not required (better: i prefer
    >>>>>> plain old procedural programming).
    >>>>>> any help? thanks in advance
    >>>> hi, thanks for replaying
    >>>>> Did you look at TurboGears or Django? TG uses Kid in the 1.x series
    >>>>> and Genshi in 2.x (I think) for templating purposes. There's also
    >>>>> Cheetah, one of the more powerful Python templating engines out there.
    >>>> django is exacly the kind of giant i'm trying to avoid
    >>>>> http://genshi.edgewall.org/
    >>>> the first lines of the tutorial read:
    >>>> "First, make sure you have CherryPy 3.0.x installed"
    >>>> Now, cherrypy is something that is not properly "include a file and get
    >>>> going!"
    >>>>> http://www.kid-templating.org/
    >>>> kid seems to have a non-linear approach, but i may give it a try
    >>>>> http://www.cheetahtemplate.org/
    >>>> cheetah was something that i already considered using. have i to
    >>>> "install" it or can i just import it?
    >>> You will need to install any of these. It is part of how python is designed.
    >>> Extendability comes with a price-tag.

    >> well, the problema is exacly that i'm looking for a python module, not
    >> for a python library.

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

    > Check out Mako (http://www.makotemplates.org/), it's pretty powerful
    > and fast.


    woudl you suggest mako over cheetah?

    >
    > George
    pistacchio, May 7, 2008
    #7
  8. pistacchio

    Guest

    Pistacchio,

    Templite
    http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496702

    A light-weight (~40 lines), fully functional, general purpose templating
    engine, allowing you to embed python code directly into your text. This
    engine is suitable for any templating (not only HTML/XML), and is
    minimal (40 lines of code!) and fast (all preprocessing is done in
    "compile time")

    Quote: "Very nice. That's just the right amount of markup for embedding
    Python into html documents."

    Malcolm
    , May 7, 2008
    #8
  9. pistacchio

    Terry Reedy Guest

    "pistacchio" <> wrote in message
    news:fvsdlh$8l3$...

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

    When you do an import, the *first* place the interpreter looks is the
    *current* directory, which usually is the directory containing the main
    file. That is because the first entry in sys.path is ''. So put
    'template.py' in the same directory as my_web_code.py. If necessary, one
    can add an entry to the beginning of sys.path.

    No need to touch the site-packages directory. The only reason to put
    something there is to make modules available to any code in any directory
    without putting a copy in each directory containing python files.

    tjr
    Terry Reedy, May 7, 2008
    #9
  10. pistacchio

    Guest

    On 7 mai, 16:17, pistacchio <> 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).

    > > 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.
    , May 7, 2008
    #10
  11. pistacchio

    pistacchio Guest

    ha scritto:
    > On 7 mai, 16:17, pistacchio <> 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. 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? mind that i work under an apache
    environment (mod_python).

    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) and some (or each) dish has the ingrediets? is it just like
    embedding pure python into the template ( like $(rest['dish']) and
    $rest['dish']['ingredient']) )?

    thanks for you interest
    pistacchio, May 8, 2008
    #11
  12. -On [20080507 15:06], Mike Driscoll () wrote:
    >http://genshi.edgewall.org/
    >http://www.kid-templating.org/
    >http://www.cheetahtemplate.org/
    >http://turbogears.org/


    Add the following to that list:

    http://jinja.pocoo.org/
    http://www.makotemplates.org/

    I think Jinja and Mako are currently two of the fastest around.

    --
    Jeroen Ruigrok van der Werven <asmodai(-at-)in-nomine.org> / asmodai
    イェルーン ラウフロック ヴァン デル ウェルヴェン
    http://www.in-nomine.org/ | http://www.rangaku.org/ | GPG: 2EAC625B
    If Winter comes, can Spring be far behind..?
    Jeroen Ruigrok van der Werven, May 8, 2008
    #12
  13. pistacchio a écrit :
    > ha scritto:
    >> On 7 mai, 16:17, pistacchio <> 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.
    Bruno Desthuilliers, May 9, 2008
    #13
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Cameron Laird
    Replies:
    3
    Views:
    367
    Giles Brown
    Mar 3, 2004
  2. Erik Johnson

    Python as replacement for PHP?

    Erik Johnson, Feb 27, 2004, in forum: Python
    Replies:
    56
    Views:
    1,103
    Geoff Berrow
    Mar 7, 2004
  3. Ted Zeng
    Replies:
    4
    Views:
    471
    Tim Arnold
    Oct 3, 2006
  4. Rajive Narain
    Replies:
    0
    Views:
    1,488
    Rajive Narain
    Sep 18, 2009
  5. Cameron Laird
    Replies:
    3
    Views:
    96
    Giles Brown
    Mar 3, 2004
Loading...

Share This Page