Web框架评论 [英] Web Framework Reviews

查看:63
本文介绍了Web框架评论的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello All,


我认为用

基于python的web框架写下我​​的一些经验是有意义的:

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


最好,

Istvan。

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.

推荐答案

是** *********@gmail.com <是*********** @ gmail.com>写道:
is***********@gmail.com <is***********@gmail.com> wrote:
我认为用基于python的web框架写下我​​的一些经验是有意义的:

http://www.personal.psu.edu/staff/i /...n_reviews.html
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




你从来没有使用过Nevow,对吗?

比较它与Cheetah或ZPT意味着你从未使用它。


Nevow正是你所定义的一个网络框架,它将是非常有趣的知道为什么你并没有把它放在那个部分。


-

华伦天奴Volonghi又名Dialtone

现在运行MacOSX 10.4

博客: http://vvolonghi.blogspot.com http://weever.berlios.de


我有没有使用过Nevow,但我看过几个如何工作的例子

多年来我一直跟踪它。


过去非常相似猎豹或ZPT如何发挥作用。你有一个模板的
,你用数据填充它来产生一个输出。它似乎现在有更多的功能,例如表单提交和验证。


另一方面,我甚至以目前的形式我不是看看我如何每天都需要的简单事情。创建一个会话,设置一个

cookie,重定向到另一个URL,执行HTTP身份验证,创建

过滤器,使用另一个模板语言?这也是我期望从Web框架中获得的功能的一部分。网络具体

以某种方式暴露的东西。


为了避免任何负面情绪,我会删除所有的评论,我认为

不是一个网络框架。


Istvan。

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.


是*********** @ gmail.com <是********* **@gmail.com>写道:
is***********@gmail.com <is***********@gmail.com> wrote:
我没有使用过Nevow,但我已经看到了一些如何工作的例子
我多年来一直在跟踪它。


Formless从一开始就是nevow的一部分。它也是编织(Nevow前身)的一部分,就像liveevil(现在增强了

并称为livepage)。


你可以与ZPT或Cheetah比较的唯一部分是它的

xmlfile模板语言。你无法在任何其他框架上运行Nevow




你也不能将数据传递给模板引擎。这是有道理的,

解析模板并迭代它以呈现页面。

模板在nevow中非常愚蠢,一切都在由nevow.rend.Page调用的
nevow.flat.flattenFactory中完成。

On另一方面,即使是现在的形式,我也不知道自己每天都需要做的简单事情。创建一个会话,设置一个
cookie,重定向到另一个URL,执行HTTP autentication,创建
过滤器,使用另一个模板语言?这也是我期望从Web框架中获得的功能的组成部分。 Web特定的东西以一些python方式暴露。
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.




会话默认使用twisted.web处理:

$ b来自twisted.application导入服务的$ b,来自nevow导入appserver的


来自nevow import rend的
,加载器,标签为t,inevow


类RootPage(rend.Page):

addSlash = True

def display_session(self,ctx,data):

return inevow.ISession(ctx).uid


docFactory = loaders.stan(

t.body [display_session]]




application = service.Application( ''Foobar'')

site = appserver.NevowSite(RootPage())

server = strports.service(''8080'',site)

server.setServiceParent(application)


将它保存在.py或.tac中并使用twistd -noy filename.tac / .py运行它

并打开 http:// localhost:8080 / 查看你的会话uid。


如果您想要进行身份验证:
http://nevowexamples.adytum.us/ sources / guarded.py
http:// nevowexamples .adytum.us / sources / guarded2.py

有两个例子(在标准的nevow发行版中)显示如何处理应用程序中的身份验证

透明的方式(你不要...... b $ b必须以任何方式触摸你的应用程序来添加用户身份验证,

这意味着你可以在不处理这方面的情况下编写所有内容

应用程序然后再添加它。)

要重定向到另一个URL,只需调用IRequest(ctx).redirect(newurl)
$渲染开始前的b $ b(如在rend.Page.beforeRender中)或在

rend.Page.locateChild。


HTTPAuthentication易于处理:
http://nevowexamples.adytum.us/sources/http_auth.py

只使用该类作为阻止页面的基类。

(此示例是标准nevow发行版的一部分)。


Nevow没有过滤器,因为它们是由twisted.web或

twisted.web2处理(希望很快,这将成为运行nevow所需的

网络服务器之一,其他是lighttpd,apache ,任何WSGI

应用服务器,nevow实际上是第一个支持

WSGI服务器的框架。


如果你想要使用你需要的另一种模板语言

写一个自定义加载器。过去有人这样做了(我不记得那个项目的

url)使用了类似猎豹的模板。


然后是最后一个点:

您可以使用

nevow.static.File公开目录或文件

暴露的对象是:

那些在rend.Page.children dict中设置的值,你可以用

到达它们的网址如下:
http://www.example.com/url/that/retu..._children_dict

或者将一个对象分配给child_foobar属性,例如:


p = rend.Page()

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


或者从chi​​ld_foobar方法返回一个对象。


或覆盖rend.Page。 childFactory(self,ctx,segment)以动态方式返回一个

对象,具体取决于segment参数的值。


在我看来你真的没跟踪过Nevow,你的信息是非常不完整的。我想你应该在谈论

Nevow :)之前完成它。


-

Valentino Volonghi又名Dialtone

现在运行MacOSX 10.4
博客: http:// vvolonghi .blogspot.com
http://weever.berlios.de



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


这篇关于Web框架评论的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆