PHP + TinyButStrong Python replacement

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • pistacchio

    PHP + TinyButStrong Python replacement

    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=begi n] [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 ">>>
    makePagesFromTh isDatabase()".
    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
  • Mike Driscoll

    #2
    Re: PHP + TinyButStrong Python replacement

    On May 7, 6:12 am, pistacchio <pistacc...@gma il.comwrote:
    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=begi n] [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 ">>>
    makePagesFromTh isDatabase()".
        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.






    Maybe those links will get you going.

    Mike

    Comment

    • pistacchio

      #3
      Re: PHP + TinyButStrong Python replacement

      Mike Driscoll ha scritto:
      On May 7, 6:12 am, pistacchio <pistacc...@gma il.comwrote:
      >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=begi n] [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 ">>>
      >makePagesFromT hisDatabase()".
      > 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
      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!"
      kid seems to have a non-linear approach, but i may give it a try
      cheetah was something that i already considered using. have i to
      "install" it or can i just import it?
      same problem as with django!
      >
      Maybe those links will get you going.
      >
      Mike

      Comment

      • Diez B. Roggisch

        #4
        Re: PHP + TinyButStrong Python replacement

        pistacchio wrote:
        Mike Driscoll ha scritto:
        >On May 7, 6:12 am, pistacchio <pistacc...@gma il.comwrote:
        >>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=begi n] [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 ">>>
        >>makePagesFrom ThisDatabase()" .
        >> 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
        >>
        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!">
        kid seems to have a non-linear approach, but i may give it a try
        >>
        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

        Comment

        • pistacchio

          #5
          Re: PHP + TinyButStrong Python replacement

          Diez B. Roggisch ha scritto:
          pistacchio wrote:
          >
          >Mike Driscoll ha scritto:
          >>On May 7, 6:12 am, pistacchio <pistacc...@gma il.comwrote:
          >>>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=begi n] [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,
          >>>conditiona l 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 ">>>
          >>>makePagesFro mThisDatabase() ".
          >>> 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
          >>>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!">kid seems to have a non-linear approach, but i may give it a try
          >>>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

          Comment

          • George Sakkis

            #6
            Re: PHP + TinyButStrong Python replacement

            On May 7, 9:40 am, pistacchio <pistacc...@gma il.comwrote:
            Diez B. Roggisch ha scritto:
            >
            >
            >
            pistacchio wrote:
            >
            Mike Driscoll ha scritto:
            >On May 7, 6:12 am, pistacchio <pistacc...@gma il.comwrote:
            >>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=begi n] [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 ofa
            >>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 ">>>
            >>makePagesFrom ThisDatabase()" .
            >>    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 ?
            "Installati on" 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

            Comment

            • pistacchio

              #7
              Re: PHP + TinyButStrong Python replacement

              George Sakkis ha scritto:
              On May 7, 9:40 am, pistacchio <pistacc...@gma il.comwrote:
              >
              >Diez B. Roggisch ha scritto:
              >>
              >>
              >>
              >>pistacchio wrote:
              >>>Mike Driscoll ha scritto:
              >>>>On May 7, 6:12 am, pistacchio <pistacc...@gma il.comwrote:
              >>>>>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=begi n] [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,
              >>>>>conditiona l 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 ">>>
              >>>>>makePagesF romThisDatabase ()".
              >>>>> 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.
              >>Extendabili ty 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 ?
              "Installati on" 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

              Comment

              • python@bdurham.com

                #8
                Re: PHP + TinyButStrong Python replacement

                Pistacchio,

                Templite


                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

                Comment

                • Terry Reedy

                  #9
                  Re: PHP + TinyButStrong Python replacement


                  "pistacchio " <pistacchio@gma il.comwrote in message
                  news:fvsdlh$8l3 $1@aioe.org...

                  | 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




                  Comment

                  • bruno.desthuilliers@gmail.com

                    #10
                    Re: PHP + TinyButStrong Python replacement

                    On 7 mai, 16:17, pistacchio <pistacc...@gma il.comwrote:
                    George Sakkis ha scritto:
                    (snip)
                    What does it matter if it's a single file or a dozen under a package ?
                    "Installati on" 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.

                    Comment

                    • pistacchio

                      #11
                      Re: PHP + TinyButStrong Python replacement

                      bruno.desthuill iers@gmail.com ha scritto:
                      On 7 mai, 16:17, pistacchio <pistacc...@gma il.comwrote:
                      >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 "installati on" 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.rend er()

                      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}<t r>
                      % 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

                      Comment

                      • Jeroen Ruigrok van der Werven

                        #12
                        Re: PHP + TinyButStrong Python replacement

                        -On [20080507 15:06], Mike Driscoll (kyosohma@gmail .com) wrote:Add the following to that list:




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

                        Comment

                        • Bruno Desthuilliers

                          #13
                          Re: PHP + TinyButStrong Python replacement

                          pistacchio a écrit :
                          bruno.desthuill iers@gmail.com ha scritto:
                          >On 7 mai, 16:17, pistacchio <pistacc...@gma il.comwrote:
                          >>George Sakkis ha scritto:
                          >(snip)
                          >>>What does it matter if it's a single file or a dozen under a package ?
                          >>>"Installatio n" 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 "installati on" 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.rend er()
                          >
                          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) ?-)



                          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}<t r>
                          % 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.

                          Comment

                          Working...