Zope vs Php

Discussion in 'Python' started by Steve, Nov 17, 2005.

  1. Steve

    Steve Guest

    We are building a web app and the our backend is currently using python
    with php front end. We would like to do everything in python but php
    for our front end is so easy to use. We would like to use zope on our
    front end(no experience with it) can anyone provide any experience with
    this?

    >From what I can tell you can't just do

    <%
    #python code
    %>
    <title> some title</title>

    this is what we would like to do with session support and things that
    php provides?


    Steve
    Steve, Nov 17, 2005
    #1
    1. Advertising

  2. Steve

    Larry Bates Guest

    Zope doesn't really work like that. Zope page templates provide
    an environment that is something like you are accustomed to in
    php, but you can't just drop in python code. Zope is an entire
    application server that has a very extensive set of capabilities
    that are on the order of WebSphere or WebLogic.

    You may want to take a look at:

    http://karrigell.sourceforge.net/

    This DOES seem to do what you want, but I have not direct
    experience (just have seen the website).

    -Larry Bates

    Steve wrote:
    > We are building a web app and the our backend is currently using python
    > with php front end. We would like to do everything in python but php
    > for our front end is so easy to use. We would like to use zope on our
    > front end(no experience with it) can anyone provide any experience with
    > this?
    >
    >>From what I can tell you can't just do

    > <%
    > #python code
    > %>
    > <title> some title</title>
    >
    > this is what we would like to do with session support and things that
    > php provides?
    >
    >
    > Steve
    >
    Larry Bates, Nov 17, 2005
    #2
    1. Advertising

  3. Steve

    Peter Maas Guest

    Steve schrieb:
    >>From what I can tell you can't just do

    > <%
    > #python code
    > %>
    > <title> some title</title>
    >
    > this is what we would like to do with session support and things that
    > php provides?


    Google for "python web frame works". Most have session support, and
    some offer Python Code embedded in HTML (e.g. Webware, mod_python
    and Spyce). I never realized what's so great about this because

    <%
    #python code
    %>
    <title> some title</title>

    and

    print output(python-code) + "<title> some title</title>".

    are equivalent.

    Another approach is using Templates. Most web frameworks have
    Templates. My favorite is Cheetah.

    --
    -------------------------------------------------------------------
    Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0
    E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64')
    ------------------------------------------------------------------
    Peter Maas, Nov 17, 2005
    #3
  4. Steve

    Steve Guest

    I am going to go the mod_python route.

    as for why a person would go route one over route 2

    is that the number of lines of html/output vs python code are usually
    10 to 1 and it's much easier to encapsulate the python code than to
    quote and escape all the html/css/xml

    Thanks for the help

    <%
    #python code
    %>
    <title> some title</title>

    and

    print output(python-code) + "<title> some title</title>".

    are equivalent.
    Steve, Nov 17, 2005
    #4
  5. Steve a écrit :
    > We are building a web app and the our backend is currently using python
    > with php front end. We would like to do everything in python but php
    > for our front end is so easy to use. We would like to use zope on our
    > front end(no experience with it) can anyone provide any experience with
    > this?
    >
    >>From what I can tell you can't just do

    > <%
    > #python code
    > %>
    > <title> some title</title>


    Yuck.

    > this is what we would like to do with session support and things that
    > php provides?
    >


    I don't think Zope is the right solution for you. It's a world in itself...

    If you're looking for a PHP-like solution, the closer is probably
    mod_python + [Cheetah or PSP].

    My 2 cents...
    Bruno Desthuilliers, Nov 17, 2005
    #5
  6. Steve

    Mike Meyer Guest

    "Steve" <> writes:

    > I am going to go the mod_python route.
    >
    > as for why a person would go route one over route 2
    >
    > is that the number of lines of html/output vs python code are usually
    > 10 to 1 and it's much easier to encapsulate the python code than to
    > quote and escape all the html/css/xml


    It is? When doing that, I tend to write things like:

    html_data = """
    Lots of HTML text here, with the random %(name)s thrown in to insert values.
    """

    # Python code to put values in html_dictionary

    print html_data % html_dictionary

    The only quoting of the HTML is the two sets of triple-quotes to wrap
    the whole thing. The escaping is done in the python, to make sure the
    values in the dictionary are properly escaped.

    Usually, multiple such pieces get pasted together at the end of the
    function.

    That said, I have to confess that lately I've been using Cheetah
    templates, because the syntax for inserting values is simpler, and the
    way Cheetah templates work naturally in the Python inheritance
    hierarchy.

    <mike
    --
    Mike Meyer <> http://www.mired.org/home/mwm/
    Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
    Mike Meyer, Nov 17, 2005
    #6
  7. Steve

    Guest

    I believe Cheetah can do this kind of thing, Kid too.

    Personally, I like Kid more. And you can take a look at TurboGears
    which is a bag of tools (web server - cherrypy, template - Kid, ORM -
    SQLObject) glued together in a pretty nice way.
    Steve wrote:
    > We are building a web app and the our backend is currently using python
    > with php front end. We would like to do everything in python but php
    > for our front end is so easy to use. We would like to use zope on our
    > front end(no experience with it) can anyone provide any experience with
    > this?
    >
    > >From what I can tell you can't just do

    > <%
    > #python code
    > %>
    > <title> some title</title>
    >
    > this is what we would like to do with session support and things that
    > php provides?
    >
    >
    > Steve
    , Nov 18, 2005
    #7
  8. Steve

    Jorge Godoy Guest

    Mike Meyer <> writes:

    > That said, I have to confess that lately I've been using Cheetah
    > templates, because the syntax for inserting values is simpler, and the
    > way Cheetah templates work naturally in the Python inheritance
    > hierarchy.


    KID is also nice and can be used as he wants and in a cleaner way as well. ;-)
    It suits both worlds.

    --
    Jorge Godoy <>
    Jorge Godoy, Nov 18, 2005
    #8
  9. Jorge Godoy wrote:

    >Mike Meyer <> writes:
    >
    >
    >>That said, I have to confess that lately I've been using Cheetah
    >>templates, because the syntax for inserting values is simpler, and the
    >>way Cheetah templates work naturally in the Python inheritance
    >>hierarchy.
    >>

    In this article you will have a great overview about Zope and Zope 3.

    http://www.zopemag.com/Issue010/Section_Articles/article_WhyZope3.html

    Fernando Lujan
    Fernando Lujan, Nov 18, 2005
    #9
  10. Steve

    Mike Meyer Guest

    Jorge Godoy <> writes:
    > Mike Meyer <> writes:
    >> That said, I have to confess that lately I've been using Cheetah
    >> templates, because the syntax for inserting values is simpler, and the
    >> way Cheetah templates work naturally in the Python inheritance
    >> hierarchy.

    > KID is also nice and can be used as he wants and in a cleaner way as well. ;-)


    Since you didn't provide a URL, and KID is a pretty generic term to
    google for, I'll just ask:

    One of the things I really like about Cheetah - at least compared to
    other templating systems I've looked at - is that it's fully
    cooperative with the Python inheritance sydstem. A cheetah template
    can inherit from a python class, or a cheetah template, and a Python
    class can inherit from a cheetah template. This brings the full power
    of OO programming facilities to the templating system, and is simply
    blows away other templating systems, or trying to build that kind of
    flexibilty using "pure python". Does KID have have that kind of
    facility?

    While I'm at it - how does KID do for things that aren't HTML?
    Cheetah integrates with web servers, but can be used to generate
    nearly anything. I've found that using Cheetah scripts to build
    Makefiles that run Cheetah scripts to build a dynamically determinedj
    set of pages to be pretty handy.

    And finally - got a URL?

    thanks,
    <mike
    --
    Mike Meyer <> http://www.mired.org/home/mwm/
    Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
    Mike Meyer, Nov 18, 2005
    #10
  11. Lars Kellogg-Stedman, Nov 18, 2005
    #11
  12. > While I'm at it - how does KID do for things that aren't HTML?

    I've taken a brief look over the Kid documentation.

    It looks like Kid is in the same class of solutions as Zope's TAL (or
    Perl's Petal). In particular, a Kid template is always a valid XML
    document, so your designers can open a Kid template in their favorite
    HTML editor and it won't cause any weird errors. Similarly, you can
    open the template in a browser while you're working on layout, which
    I've certainly found useful working with Petal.

    There's a Kid language specification here:

    http://kid.lesscode.org/language.html

    There's a standlone Python TAL implementation here:

    http://www.owlfish.com/software/simpleTAL/

    -- Lars

    --
    Lars Kellogg-Stedman <>
    This email address will expire on 2005-11-23.
    Lars Kellogg-Stedman, Nov 18, 2005
    #12
  13. Steve

    Jorge Godoy Guest

    Mike Meyer <> writes:

    > Jorge Godoy <> writes:
    > > Mike Meyer <> writes:
    > >> That said, I have to confess that lately I've been using Cheetah
    > >> templates, because the syntax for inserting values is simpler, and the
    > >> way Cheetah templates work naturally in the Python inheritance
    > >> hierarchy.

    > > KID is also nice and can be used as he wants and in a cleaner way as well. ;-)

    >
    > Since you didn't provide a URL, and KID is a pretty generic term to
    > google for, I'll just ask:


    Sorry. http://kid.lesscode.org/

    > One of the things I really like about Cheetah - at least compared to
    > other templating systems I've looked at - is that it's fully
    > cooperative with the Python inheritance sydstem. A cheetah template
    > can inherit from a python class, or a cheetah template, and a Python
    > class can inherit from a cheetah template. This brings the full power
    > of OO programming facilities to the templating system, and is simply
    > blows away other templating systems, or trying to build that kind of
    > flexibilty using "pure python". Does KID have have that kind of
    > facility?


    I am beginning with it, but it does have it. You can "extend" from templates
    and use classes and methods inside your code as well. I'm using Kid with
    Apache (mod_python) and with CherryPy.

    > While I'm at it - how does KID do for things that aren't HTML?
    > Cheetah integrates with web servers, but can be used to generate
    > nearly anything. I've found that using Cheetah scripts to build
    > Makefiles that run Cheetah scripts to build a dynamically determinedj
    > set of pages to be pretty handy.


    Kid is for XML output. It won't work with non-HTML output...

    > And finally - got a URL?


    http://kid.lesscode.org/ ;-)


    Be seeing you,
    --
    Jorge Godoy <>
    Jorge Godoy, Nov 18, 2005
    #13
  14. Steve

    Guest

    Jorge Godoy wrote:
    > Kid is for XML output. It won't work with non-HTML output...
    >

    I believe someone patches it to output plain text, thus it is possible
    to do "makefile" like things. I don't have such a need so don't know
    the detail. It can output XML as well as HTML which I believe you
    already know.
    , Nov 18, 2005
    #14
  15. Steve

    Mike Meyer Guest

    Jorge Godoy <> writes:
    >> While I'm at it - how does KID do for things that aren't HTML?
    >> Cheetah integrates with web servers, but can be used to generate
    >> nearly anything. I've found that using Cheetah scripts to build
    >> Makefiles that run Cheetah scripts to build a dynamically determinedj
    >> set of pages to be pretty handy.

    > Kid is for XML output. It won't work with non-HTML output...
    >> And finally - got a URL?

    > http://kid.lesscode.org/ ;-)


    Thanks. It looks pretty spiffy. I like the idea of incorporating the
    templating system into the document via the py:* attributes.

    Unfortunately, my tools don't - which is another one of the things I
    like about Cheetah: it doesn't interfere with my X/HTML tools. For
    instance, I edit attributes by asking the editor to let me edit the
    current tags attributes. It opens window with a list of valid
    attributes, along with type information about those attributes. I edit
    the list, close the window, and it inserts the required attributes,
    appropriately quoted, into the tag. I couldn't use that for py:*
    attributes without tweaking the DTD for each language I wanted to
    edit. Similar problems crop up with the other features that depend on
    information from the DTD.

    Thanks,
    <mike
    --
    Mike Meyer <> http://www.mired.org/home/mwm/
    Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
    Mike Meyer, Nov 18, 2005
    #15
  16. Steve

    Jorge Godoy Guest

    Mike Meyer <> writes:

    > Unfortunately, my tools don't - which is another one of the things I
    > like about Cheetah: it doesn't interfere with my X/HTML tools. For
    > instance, I edit attributes by asking the editor to let me edit the
    > current tags attributes. It opens window with a list of valid
    > attributes, along with type information about those attributes. I edit
    > the list, close the window, and it inserts the required attributes,
    > appropriately quoted, into the tag. I couldn't use that for py:*
    > attributes without tweaking the DTD for each language I wanted to
    > edit. Similar problems crop up with the other features that depend on
    > information from the DTD.


    What DTD do you use to write Python code? ;-)

    I can use my "HTML writing tool" with the XHTML, HTML, etc. DTD specified and
    have it insert the tags for me. The Python namespace allows me to insert
    Python commands and still have valid (X)HTML output (at least tidy is very
    happy with them). After I have the mockup, with Python tags embedded, I send
    the files to the webdesigners and they do their art. :)

    For one project we are using a lot of CSS and JavaScript.

    But, as you can see with TurboGears, it's possible to do even more with it.

    --
    Jorge Godoy <>
    Jorge Godoy, Nov 18, 2005
    #16
  17. Steve wrote:
    > I am going to go the mod_python route.
    >
    > as for why a person would go route one over route 2
    >
    > is that the number of lines of html/output vs python code are usually
    > 10 to 1 and it's much easier to encapsulate the python code than to
    > quote and escape all the html/css/xml
    >
    >
    > <%
    > #python code
    > %>
    > <title> some title</title>
    >
    > and
    >
    > print output(python-code) + "<title> some title</title>".
    >
    > are equivalent.


    Yes, but this was *not* what I suggested.

    There are a lot of HTML templating languages for Python, some being more
    or less PHP-like (PSP, Cheetah, ...), some being way more
    presentation-oriented (TAL, Kid, ...). I prefer the second category. I
    share your opinion about html in code, but I also dislike code in html...



    --
    bruno desthuilliers
    python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
    p in ''.split('@')])"
    bruno at modulix, Nov 18, 2005
    #17
  18. Mike Meyer wrote:
    > Jorge Godoy <> writes:
    >
    >>Mike Meyer <> writes:
    >>

    (snip)
    >
    > While I'm at it - how does KID do for things that aren't HTML?


    It doesn't. Kid is explicitely for XML/HTML templating.


    --
    bruno desthuilliers
    python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
    p in ''.split('@')])"
    bruno at modulix, Nov 18, 2005
    #18
    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. Shane Hathaway
    Replies:
    2
    Views:
    315
    Michael Hudson
    Aug 29, 2003
  2. Ken Guest
    Replies:
    2
    Views:
    276
    Ken Guest
    Jan 6, 2006
  3. Ted Zeng
    Replies:
    4
    Views:
    474
    Tim Arnold
    Oct 3, 2006
  4. Ted Zeng
    Replies:
    0
    Views:
    603
    Ted Zeng
    Oct 13, 2006
  5. Rajive Narain
    Replies:
    0
    Views:
    1,548
    Rajive Narain
    Sep 18, 2009
Loading...

Share This Page