Re: Web Framework Reviews

2005-07-20 Thread flupke
Dave Cook wrote:
 On 2005-07-19, [EMAIL PROTECTED] [EMAIL PROTECTED] 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/nevow/moin.cgi/FrequentlyAskedQuestions
 
 Dave Cook

One could use twisted.web2 also without the nevow part.
The docs @ http://twistedmatrix.com/projects/web2/documentation/ are 
very clear and it contains a good example at the end.

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


Re: Web Framework Reviews

2005-07-19 Thread Valentino Volonghi aka Dialtone
[EMAIL PROTECTED] [EMAIL PROTECTED] 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/u/iua1/python_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
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Web Framework Reviews

2005-07-19 Thread [EMAIL PROTECTED]
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.

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


Re: Web Framework Reviews

2005-07-19 Thread Valentino Volonghi aka Dialtone
[EMAIL PROTECTED] [EMAIL PROTECTED] 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/returns/a/page/inst/key_in_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
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Web Framework Reviews

2005-07-19 Thread Dave Cook
On 2005-07-19, [EMAIL PROTECTED] [EMAIL PROTECTED] 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/nevow/moin.cgi/FrequentlyAskedQuestions

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


Re: Web Framework Reviews

2005-07-19 Thread [EMAIL PROTECTED]
 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.

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


Re: Web Framework Reviews

2005-07-19 Thread Valentino Volonghi aka Dialtone
[EMAIL PROTECTED] [EMAIL PROTECTED] 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/prose/Meet%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
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Web Framework Reviews

2005-07-19 Thread John Ziniti
[EMAIL PROTECTED] 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/u/iua1/python_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
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Web Framework Reviews

2005-07-19 Thread Josef Meile
 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

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


Re: Web Framework Reviews

2005-07-19 Thread Tim Parkin
[EMAIL PROTECTED] 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(value))]
else:
yield T.p[value]
else:
yield T.p[T.strong['nothing uploaded']]

yield T.input(name=namer('value'),value=value,type='hidden')
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


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


Re: Web Framework Reviews

2005-07-19 Thread [EMAIL PROTECTED]
 don't see why this would have problems 'scaling' or would be
 more difficult to visualise than a the equivalent tag soup html.

I think the difficulties will arise from the inability to visually
track closing tags.
]]] versus /tr/tr/table

 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.

Oh yeah, now I remeber, I think this is a controversial idea.

Istvan.

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


Re: Web Framework Reviews

2005-07-19 Thread Valentino Volonghi aka Dialtone
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

 I think the difficulties will arise from the inability to visually
 track closing tags.
 ]]] versus /tr/tr/table

You can do things like:

t.html[
t.head[
t.title[Foobar]
],
t.body[
t.p[This is some content]
]
]

This is not harder than normal xhtml tags to follow. plus you don't have
to remember what tag you are closing :)

-- 
Valentino Volonghi aka Dialtone
Now Running MacOSX 10.4
Blog: http://vvolonghi.blogspot.com
http://weever.berlios.de
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Web Framework Reviews

2005-07-19 Thread Leif K-Brooks
[EMAIL PROTECTED] wrote:
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.
 
 Oh yeah, now I remeber, I think this is a controversial idea.

One important thing to realise about Nevow is that it doesn't forbid you
from putting logic in the template, it simply doesn't encourage it.
There's nothing stopping you from writing render_while and render_if
methods for Nevow -- in fact, it would be quite easy. But once you
really understand Nevow and how it works, you realize that you don't
need to put logic in the template, because there's a better way.
-- 
http://mail.python.org/mailman/listinfo/python-list