Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Web Framework Reviews

Reply
Thread Tools

Web Framework Reviews

 
 
istvan.albert@gmail.com
Guest
Posts: n/a
 
      07-19-2005
Hello All,

I thought it would make sense to write up some of my experiences with
python based web frameworks:

http://www.personal.psu.edu/staff/i/...n_reviews.html

best,

Istvan.

 
Reply With Quote
 
 
 
 
Valentino Volonghi aka Dialtone
Guest
Posts: n/a
 
      07-19-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) <(E-Mail Removed)> wrote:

> I thought it would make sense to write up some of my experiences with
> python based web frameworks:
>
> http://www.personal.psu.edu/staff/i/...n_reviews.html


You've never used Nevow, have you?
Comparing it to Cheetah or ZPT means that you never used it.

Nevow is exactly what you define as a web framework, and it would be
quite interesting to know why you didn't put it in that section.

--
Valentino Volonghi aka Dialtone
Now Running MacOSX 10.4
Blog: http://vvolonghi.blogspot.com
http://weever.berlios.de
 
Reply With Quote
 
 
 
 
istvan.albert@gmail.com
Guest
Posts: n/a
 
      07-19-2005
I have not used Nevow but I have seen a few examples of how it works
and I kept track of it over the years.

It used to be very similar to how Cheetah or ZPT does its job. You had
a template, and you filled it with data to produce an output. It seems
that it has now more features such a form submission and validation.

On the other hand I even in its current form I don't see how I would to
the simple things that I need every day. Create a session, set a
cookie, redirect to another url, perform HTTP autentication, create
filter, use another templating language? This is also integral part of
the functionality that I expect from an web framework. Web specific
things exposed in some python ic way.

To avoid any negative feelings I'll remove all remarks to what I think
is not a web framework.

Istvan.

 
Reply With Quote
 
Valentino Volonghi aka Dialtone
Guest
Posts: n/a
 
      07-19-2005
(E-Mail Removed) <(E-Mail Removed)> wrote:

> I have not used Nevow but I have seen a few examples of how it works
> and I kept track of it over the years.
>
> It used to be very similar to how Cheetah or ZPT does its job. You had
> a template, and you filled it with data to produce an output. It seems
> that it has now more features such a form submission and validation.


Formless has been part of nevow since the very beginning. It has also
been part of woven (Nevow predecessor), just like liveevil (now enhanced
and called livepage).

The only part of nevow that you can compare to ZPT or Cheetah is its
xmlfile template language. There is no way you can run Nevow on top of
any other framework.

Also you don't pass data to the templating engine. It's nevow that
parses the template and iterates over it to render the page. The
template is very stupid in nevow and everything is done in
nevow.flat.flattenFactory called by nevow.rend.Page.

> On the other hand I even in its current form I don't see how I would to
> the simple things that I need every day. Create a session, set a
> cookie, redirect to another url, perform HTTP autentication, create
> filter, use another templating language? This is also integral part of
> the functionality that I expect from an web framework. Web specific
> things exposed in some python ic way.


Sessions are handled by default with twisted.web:

from twisted.application import service, strports
from nevow import appserver

from nevow import rend, loaders, tags as t, inevow

class RootPage(rend.Page):
addSlash = True
def display_session(self, ctx, data):
return inevow.ISession(ctx).uid

docFactory = loaders.stan(
t.html[t.head[t.title["Session example"]],
t.body[display_session]]
)

application = service.Application('Foobar')
site = appserver.NevowSite(RootPage())
server = strports.service('8080', site)
server.setServiceParent(application)

Save this in a .py or .tac and run it with twistd -noy filename.tac/.py
and open http://localhost:8080/ in your browser to see your session uid.

If you want autentication:
http://nevowexamples.adytum.us/sources/guarded.py
http://nevowexamples.adytum.us/sources/guarded2.py
There are 2 examples (in the standard nevow distribution) that show how
to handle authentication in an application transparent way (you don't
have to touch your application by any means to add user authentication,
which means you can write everything without taking care of this aspect
of the app and then add it later).

To redirect to another url just call IRequest(ctx).redirect(newurl)
before the rendering begins (like in rend.Page.beforeRender) or in
rend.Page.locateChild.

HTTPAuthentication is easily handled:
http://nevowexamples.adytum.us/sources/http_auth.py
just use that class as a base class for your blocked page.
(this example is part of the standard nevow distribution).

Nevow doesn't have filters because they are handled by twisted.web or
twisted.web2 (which is, hopefully soon, going to be one of the required
webservers to run nevow, the others are lighttpd, apache, any WSGI
application server, nevow was in fact the first framework to support
WSGI servers).

If you want to use a different templating language you just need to
write a custom loader. Somebody did this in the past (I don't recall the
url of the project) that used cheetah-like templates.

Then for the last point:
you can expose directories or files using
nevow.static.File

exposed objects are:
those set as a value in rend.Page.children dict, you can reach them with
an url like:
http://www.example.com/url/that/retu..._children_dict
Or assign an object to a child_foobar attribute like:

p = rend.Page()
p.child_foobar = static.File('/etc/')

Or return an object from a child_foobar method.

Or override rend.Page.childFactory(self, ctx, segment) to return an
object in a dynamic way depending on the value of the segment argument.

It seems to me that you really never tracked Nevow, your information is
very incomplete. I think you should complete it before talking about
Nevow .

--
Valentino Volonghi aka Dialtone
Now Running MacOSX 10.4
Blog: http://vvolonghi.blogspot.com
http://weever.berlios.de
 
Reply With Quote
 
Dave Cook
Guest
Posts: n/a
 
      07-19-2005
On 2005-07-19, (E-Mail Removed) <(E-Mail Removed)> wrote:

> On the other hand I even in its current form I don't see how I would to
> the simple things that I need every day. Create a session, set a
> cookie, redirect to another url, perform HTTP autentication, create
> filter, use another templating language? This is also integral part of
> the functionality that I expect from an web framework. Web specific
> things exposed in some python ic way.


Take a look at the Nevow FAQ and examples. Also, Nevow sits on top of
Twisted, so you have all of Twisted's features available.

http://divmod.org/users/wiki.twistd/...AskedQuestions

Dave Cook
 
Reply With Quote
 
istvan.albert@gmail.com
Guest
Posts: n/a
 
      07-19-2005
> It seems to me that you really never tracked Nevow, your information is
> very incomplete. I think you should complete it before talking about Nevow


I think you should take what you posted above and put it up on your
main site, because right now there is no way to find any information
like this. Your entire intro is about templating and leaves one with
no clues as to what else is there.

One remark regarding stan. For me it is inconceivable that one would
build (and debug) any complicated webpage as stan does it, one element
at a time:

docFactory = loaders.stan(
t.html[t.head[t.title["Session example"]],
t.body[display_session]]
)

The pages that I have to build invariably contain multiple nested html
tables etc. I shudder to think that I would ever have to build them
like that. I know you have an "inverse" ZPT like templates those are a
lot friendlier on the eyes. For someone who is does not know what Nevow
is seeing an example of Stan is very scary because IMO it does not
scale at all. This again is just an opinion.

Thanks for the explanations.

Istvan.

 
Reply With Quote
 
Valentino Volonghi aka Dialtone
Guest
Posts: n/a
 
      07-19-2005
(E-Mail Removed) <(E-Mail Removed)> wrote:

> I think you should take what you posted above and put it up on your
> main site, because right now there is no way to find any information
> like this. Your entire intro is about templating and leaves one with
> no clues as to what else is there.


Right now there are at least 2 web sites:
http://divmod.org/users/exarkun/nevow-api/ + file inevow.py in nevow.
http://divmod.org/users/mg/nevow-doc/

And a new one:
http://dictator.kieranholland.com/pr...et%20Stan.html

And the page I linked in my previous post:
http://nevowexamples.adytum.us/
this is a living site with the living examples distributed with nevow.
at least one example of formless does not work right now because of
changes that we are doing in trunk right now (only formless has some
problems, all the others work pretty well).

There are really a lot of examples, and you can learn a lot of stuff
from them. More documentation will be useful for sure, but by just
coming in the irc channel #twisted.web on freenode you would have
obtained all the answers you wanted to write a better review paper .

> One remark regarding stan. For me it is inconceivable that one would
> build (and debug) any complicated webpage as stan does it, one element
> at a time:
>
> docFactory = loaders.stan(
> t.html[t.head[t.title["Session example"]],
> t.body[display_session]]
> )
>
> The pages that I have to build invariably contain multiple nested html
> tables etc. I shudder to think that I would ever have to build them
> like that. I know you have an "inverse" ZPT like templates those are a
> lot friendlier on the eyes. For someone who is does not know what Nevow
> is seeing an example of Stan is very scary because IMO it does not
> scale at all. This again is just an opinion.


I have a little project, developed during my little free time that is
linked in my signature (weever). It has over 2000 lines of xhtml
templates and you can see a living example here:
http://vercingetorix.dyndns.org:20080/

I can guarantee you that when templates begin to be a bit too complex
stan is what saves the day. I usually use xhtml for everything (and
nevow has the best templating engine out there thanks to its flexibility
and simplicity, there are only 3 special tags and 3 attributes, and we
are working to make it even easier than that) but when xhtml gets
complicated stan is incredibly useful.

Anyway stan is also incredibly useful to write little examples without
requiring a new xhtml file (ok... you may use loaders.xmlstr but...)

And it does scale well anyway (Quotient is entirely built using stan and
it's very big).
Templating engines like ZPT prefer to put some code in the template,
Nevow prefers to put code in python and allow you to write some xhtml in
python too. python is easier to manage and less likely to be screwed by
any designer that doesn't know what python is.

> Thanks for the explanations.


np

--
Valentino Volonghi aka Dialtone
Now Running MacOSX 10.4
Blog: http://vvolonghi.blogspot.com
http://weever.berlios.de
 
Reply With Quote
 
John Ziniti
Guest
Posts: n/a
 
      07-19-2005
(E-Mail Removed) wrote:
> I thought it would make sense to write up some of my experiences with
> python based web frameworks:
>
> http://www.personal.psu.edu/staff/i/...n_reviews.html
>


From the web-page:

"""
Zope - Generation Z

....

Weakness: Not pythonic. In fact you can barely use python with it!
Ad-hoc lookup rules, competing standards DHTML vs ZPT. Can only be used
with these two! The Z shaped thingy.

"""

"barely use python with it" and "can only be used with these two" are
not entirely true. Zope development can be done in a through-the-web
(TTW) fashion or via filesystem products. When developing TTW, it
is true that you are somewhat limited in the amount of Python that
you will be able to use.

When you graduate to filesystem products, though, Zope becomes more of
a set of APIs and a persistence layer for your objects and methods
that are coded entirely in Python, with very little DTML (not DHTML)
and ZPTs. IMHO, this is when Zope development becomes powerful.

Maybe this is the Z-shaped learning curve you speak of: it takes a
while developing in Zope to even know what all of the options are!

HTH,
JZ
 
Reply With Quote
 
Josef Meile
Guest
Posts: n/a
 
      07-19-2005
> "barely use python with it" and "can only be used with these two" are
> not entirely true. Zope development can be done in a through-the-web
> (TTW) fashion or via filesystem products. When developing TTW, it
> is true that you are somewhat limited in the amount of Python that
> you will be able to use.

I just want to add that ZPT and DTML are only intended for the
presentation and not for the logic, which can be done all using python.
However, as you may see, there are some zope developers that use it
wrong and do lots of logic stuff within dtml or zpt.

Regards,
Josef

 
Reply With Quote
 
Tim Parkin
Guest
Posts: n/a
 
      07-19-2005
(E-Mail Removed) wrote:
> One remark regarding stan. For me it is inconceivable that one would
> build (and debug) any complicated webpage as stan does it, one element
> at a time:
>
> docFactory = loaders.stan(
> t.html[t.head[t.title["Session example"]],
> t.body[display_session]]
> )
>
> The pages that I have to build invariably contain multiple nested html
> tables etc. I shudder to think that I would ever have to build them
> like that. I know you have an "inverse" ZPT like templates those are a
> lot friendlier on the eyes. For someone who is does not know what Nevow
> is seeing an example of Stan is very scary because IMO it does not
> scale at all. This again is just an opinion.


Firstly, I don't know of anyone who has built whole sites out of stan
(it's not what it was created for). Although if built in a modular
fashion I don't see why this would have problems 'scaling' or would be
more difficult to visualise than a the equivalent tag soup html.

Also it depends on what you mean by scale. We built a site for one of
the biggest rugby sites in the world (over 300 requests per second).
This uses a combination of stan and xhtml templates. Before we rebuilt
the site using CSS layout (which you really should be looking at using
to avoid the multiple nested tables you mention - which I presume are
layout related) we were using client supplied html which was nested more
than 10 levels deep.

Most of this we were able to leave in the html and allow the client to
manage via ftp. The bits that were dynamic were 'templated up' by
putting slots and renderers. Nevow avoids any programmatic logic in the
templates which means that all logic is directly in your python code
(avoiding one of templating languages biggest faults - that of
implementing *another* language just for templates).

Templates now become a repository of html which is marked up with insert
points, replacement points, patterns to reuse, etc. Sometimes you need
to generate some dynamic html that won't easily and clearly fit into
this 'extract patterns, replace sections, etc' pattern. When this
happens you can either include bits of html as strings (yeuch!) *or* use
stan.

Stan enables you to create small sections of dynamic html without
recourse to templating languages or marking up tiny fragments of html
for re-use.

This section of code from the nevow forms library (this is a widget for
file uploads).

if name:
if self.preview == 'image':
yield T.p[value,T.img(src=self.fileHandler.getUrlForFile(val ue))]
else:
yield T.p[value]
else:
yield T.p[T.strong['nothing uploaded']]

yield T.input(name=namer('value'),value=value,type='hidd en')
yield T.input(name=key, id=keytocssid(ctx.key),type='file')

In other systems, this would have to be part of the template (via inline
python or some alternative programming syntax), marked up as html in
string elements (liable to validation errors and difficult to manage) or
small fragments of html would have to be marked up as patterns and then
manipulated in some fashion. The last is possible using nevow and the
manipulation can be done directly on the produced html -- or via stan!!
(think of manipulating a dom'ish like object).

Tim Parkin


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cell phone reviews, All mobile reviews, Nokia all models princes Digital Photography 0 05-12-2007 12:31 PM
cell phone reviews, All mobile reviews, Nokia all models princess Computer Support 0 05-12-2007 10:52 AM
Installing 1.1 Framework and 2.0 Framework on the same web server Mark ASP .Net 4 11-17-2005 03:30 PM
Reviews website, any design ideas? and your views on reviews. Sims HTML 1 05-06-2004 10:34 PM
Webcam 4 WinXP reviews....Any site reviews or suggestion for purchase? Arawak Computer Support 0 08-20-2003 07:11 PM



Advertisments