Python 微型web框架:Morepath

jopen 9年前

Morepath是具有强大的能力的Python 微型web框架。Morepath是一个Python WSGI微型框架。他使用路由,但是是针对模型的路由。Morepath是一个模型驱动,灵活的框架,这使得它富有表达力。

import morepath    class App(morepath.App):      pass    class Document(object):      def __init__(self, id):          self.id = id    @App.path(path='')  class Root(object):      pass    @App.path(path='documents/{id}', model=Document)  def get_document(id):      return Document(id)  # query for doc    @App.html(model=Root)  def hello_root(self, request):      return '<a href="%s">Go to doc</a>' % request.link(Document('foo'))    @App.html(model=Document)  def hello_doc(self, request):      return '<p>Hello document: %s!</p>' % self.id    if __name__ == '__main__':      config = morepath.setup()      config.scan()      config.commit()      morepath.run(App())

项目主页:http://www.open-open.com/lib/view/home/1426559976992