Dynamische Webinhalte -- Links und Hinweise

Django, Flask, Bottle, WSGI, CGI…
Antworten
Benutzeravatar
gerold
Python-Forum Veteran
Beiträge: 5555
Registriert: Samstag 28. Februar 2004, 22:04
Wohnort: Oberhofen im Inntal (Tirol)
Kontaktdaten:

HOWTO Use Python in the web
http://xivilization.net/pydocs/2.6/howt ... rvers.html


CGI
CGI steht für "Common Gateway Interface" und ist eine Schnittstelle, die es dem Webserver erlaubt, externe Prozesse (Programme) aufzurufen, Daten an die externen Prozesse zu übergeben und die Rückgabe dieser externen Programme an den Browser zurück zu schicken.

CGI hat den großen Nachteil, dass für jede Anfrage das CGI-Programm neu gestartet werden muss. Das macht CGI bei vielen gleichzeitigen Zugriffen fühlbar langsam. Für kleine Sachen ist es aber OK, da CGI von den Providern weitreichend unterstützt wird.

- http://docs.python.org/lib/module-cgi.html
- http://docs.python.org/lib/module-cgitb.html
- http://www.python-forum.de/post-42514.html#42514
- http://www.python-forum.de/post-27484.html#27484
- http://www.python-forum.de/post-36947.html#36947
- http://www.python-forum.de/post-66081.html#66081
- [wiki]Web-Skripte zum laufen bringen[/wiki]
- http://webpython.codepoint.net/
- [wiki]Python im Web[/wiki]
- [wiki]CGI[/wiki]
- http://wiki.python.org/moin/CgiScripts


FastCGI
FastCGI ist eine Schnittstelle zum Webserver. FastCGI versucht das Programm ständig am Laufen zu halten, damit nicht bei jeder Anfrage eines Browsers, das Programm neu gestartet werden muss. Dabei ist FastCGI aber nicht nur auf den Apache-Webserver und die Programmiersprache Python fixiert.

- http://www.fastcgi.com/
- http://de.wikipedia.org/wiki/FastCGI
- [wiki=Python_im_Web#FastCgi]Python im Web#FastCgi[/wiki]


mod_python
mod_python ist eine Schnittstelle zum Apachen.
Wie mir "Jerch" per PN mitgeteilt hat, wird mod_python nicht mehr weiterentwickelt. Die letzte Änderung im SVN wurde im August 2008 vorgenommen -- mir kommt das jetzt nicht so alt vor. Aber da mod_python sowiso nie die beste Wahl war --> nehmt stattdessen lieber mod_wsgi.

Man sollte mod_python in zukünftigen Projekten nicht mehr verwenden.

- http://www.modpython.org/
- http://de.wikipedia.org/wiki/Mod_python
- [wiki=Python_im_Web#ModPython]Python im Web#ModPython[/wiki]


WSGI
Durch die Fülle der unterschiedlichen Möglichkeiten der Web-Programmierung wurde vor einiger Zeit eine Schnittstelle entwickelt, damit sichergestellt ist, dass Anwendungen auf mehreren Server Gateway Interfaces laufen können. Dieses Interface heisst WSGI (Webserver Gateway Interface) und ist eine allgemeine Schnittstelle die in PEP 333 beschrieben wird. (Siehe: [wiki=Python_im_Web#Wsgi]Originaltext[/wiki])

- http://www.wsgi.org/wsgi
- [wiki=Python_im_Web#Wsgi]Python im Web#Wsgi[/wiki]
- [wiki=WSGI]WSGI[/wiki]
- [wiki=PEP_333]PEP 333[/wiki]
- http://www.python.org/dev/peps/pep-0333/
- http://code.google.com/p/modwsgi/


mod_wsgi
mod_wsgi ist eine standardisierte Schnittstelle zwischen dem Apachen und Python-Programmen.

The aim of mod_wsgi is to implement a simple to use Apache module which can host any Python application which supports the Python WSGI interface. The module would be suitable for use in hosting high performance production web sites, as well as your average self managed personal sites running on web hosting services.

- http://code.google.com/p/modwsgi/


Zope
Zope ist ein freier, stark objektorientierter Web-Applikationsserver. Zope stellt ein Framework zur Verfügung, das dem Programmierer von Websites einiges an Arbeit abnimmt. Unter anderem kümmert sich Zope um die Benutzer-Authentifizierung, die Verwaltung und Kontrolle der Berechtigungen, die Datenspeicherung oder um die Verwaltung von Sessiondaten.

Den größten Pluspunkt holt sich Zope aber durch die Integration von TAL (Template Attribute Language), einer Vorlagensprache, mit der auch WYSIWYG-Editoren klar kommen. TAL fügt sich so in die Struktur einer HTML-Seite ein, als ob es dazu gehören würde.

Themen zu Zope oder Plone sind im dafür eingerichteten Zope-Forum besser aufgehoben.

- http://zope.org
- http://zope.de

Beispiel:

Code: Alles auswählen

<html>
  <head>
    <title tal:content="template/title">Titel</title>
  </head>
  <body>
    <p>
      Hallo, <span tal:content="request/vorname | default">Welt</span>!
    </p>
  </body>
</html>
Plone
Plone ist ein Content Management System (CMS), das unter Zope läuft. Themen zu Zope oder Plone sind im dafür eingerichteten Zope-Forum besser aufgehoben.

- http://plone.org


Python Servlet Engine
PSE ist ein System das es ermöglicht, HTML-Vorlagenseiten mit Python zu erweitern. Dieses System kommt, meines Erachtens, ehemaligen PHP-Entwicklern ziemlich entgegen, erweitert das Konzept aber durch einfache Trennung von Vorlagen und Code.

- http://nick.borko.org/pse/

Beispiel Code (hallo.py):

Code: Alles auswählen

if pse.form.has_key('name'):
    name = pse.form['name']
else:
    name = 'Welt'
Beispiel Vorlage (hallo.pt):

Code: Alles auswählen

<html>
  <head>
    <title>Sample PSE Application</title>
  </head>
  <body>
    Hallo, <?=name ?>!
  </body>
</html>
Mehr Beispiele: http://nick.borko.org/pse/examples/tutorial.html


pyLucid
PyLucid ist ein leichtgewichtiges, OpenSource "Content Management System" (CMS). Zum Betrieb ist lediglich ein Standard Webserver mit Python (min. v2.2.1) CGI und MySQL nötig.

- http://www.pylucid.org/


Django
Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.

- http://www.djangoproject.com/

Beispiel (base.html):

Code: Alles auswählen

<html>
<head>
    <title>{% block title %}{% endblock %}</title>
</head>
<body>
    <img src="sitelogo.gif" alt="Logo" />
    {% block content %}{% endblock %}
</body>
</html>
Beispiel (article_detail.html):

Code: Alles auswählen

{% extends "base.html" %}

{% block title %}Articles for {{ year }}{% endblock %}

{% block content %}
<h1>Articles for {{ year }}</h1>

{% for article in article_list %}
<p>{{ article.headline }}</p>
<p>By {{ article.reporter.full_name }}</p>
<p>Published {{ article.pub_date|date:"F j, Y" }}</p>
{% endfor %}
{% endblock %}
TurboGears
Create a database-driven, ready-to-extend application in minutes. All with designer friendly templates, easy AJAX on the browser side and on the server side, not a single SQL query in sight with code that is as natural as writing a function.

- http://www.turbogears.org/
- http://files.turbogears.org/video/20MinuteWiki2nd.mov


Colubrid
Colubrid ist ein WSGI Publisher, der die Entwicklung von Webanwendungen vereinfacht. Colubrid übernimmt das Parsen von Formulardaten, URL Parametern und stellt Funktionen zum setzen und auslesen von Cookies sowie einen URL Dispatcher zur Verfügung.
Das Ziel des Projekte ist es komplett WSGI kompatibel zu sein und die Entwicklung von Webanwendungen zu vereinfachen.
Colubrid wurde für die Python Forensoftware Pocoo entwickelt und einiger Beispielcode kann man sich aus dem dort veröffentlichten Code entnehmen.

- http://wsgiarea.pocoo.org/colubrid/

Beispiel:

Code: Alles auswählen

from colubrid import BaseApplication, HttpResponse, execute

class Application(BaseApplication):

    def process_request(self):
        return HttpResponse('Hello World')

app = Application

if __name__ == '__main__':
    execute(app)
Spyce
Mit Spyce lässt sich Python, serverseitig, in HTML-Seiten einbetten. Ähnlich wie JSP mit Java.

- http://spyce.sourceforge.net/

Beispiel:

Code: Alles auswählen

<spy:parent title="Hello, world!" />

[[-- Spyce can embed chunks of Python code, like this. --]]
[[\
  import time
  t = time.ctime()
]]

[[-- 
  pull the count from the GET variable.
  the int cast is necessary since request stores everything as a string 
--]]
[[ for i in range(int(request.get1('count', 2))):{ ]]
<div>Hello, world!</div>
[[ } ]]

The time is now [[= t ]].
CherryPy
CherryPy is a pythonic, object-oriented web development framework.

- http://www.cherrypy.org/

Code: Alles auswählen

import cherrypy
class HelloWorld(object):
    def index(self):
        return "Hello World!"
    index.exposed = True

cherrypy.quickstart(HelloWorld())
web.py

- http://webpy.org/

Beispiel:

Code: Alles auswählen

import web

urls = (
    '/(.*)', 'hello'
)

class hello:
    def GET(self, name):
        i = web.input(times=1)
        if not name: name = 'world'
        for c in xrange(int(i.times)): print 'Hello,', name+'!'

if __name__ == "__main__": web.run(urls)
Cheetah
Cheetah is an open source template engine and code generation tool, written in Python. It can be used standalone or combined with other tools and frameworks. Web development is its principle use, but Cheetah is very flexible and is also being used to generate C++ game code, Java, sql, form emails and even Python code.

- http://www.cheetahtemplate.org/

Beispiel:

Code: Alles auswählen

#!/usr/bin/env python
# -*- coding: iso-8859-15 -*-

from Cheetah.Template import Template

html = """
<h2>$ueberschrift:</h2>
<ul>
  #for $person in $personen
    <li>$person</li>
  #end for
</ul>
"""

tmpl = Template(html)
tmpl.ueberschrift = "Teilnehmerliste"
tmpl.personen = ("Martin", "Bernhard", "Luggi", "Michael", "Franz")

print str(tmpl)
Ergebnis:

Code: Alles auswählen

<h2>Teilnehmerliste:</h2>
<ul>
    <li>Martin</li>
    <li>Bernhard</li>
    <li>Luggi</li>
    <li>Michael</li>
    <li>Franz</li>
</ul>
SimpleTAL
SimpleTAL is a stand alone Python implementation of the TAL, TALES and METAL specifications used in Zope to power HTML and XML templates. SimpleTAL is an independent implementation of TAL; there are no dependencies on Zope nor is any of the Zope work re-used.

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


Kid
Kid is a simple template language for XML based vocabularies written in Python. It was spawned as a result of a kinky love triangle between XSLT, TAL, and PHP.

- http://kid-templating.org/


Myghty
Myghty is a Python based web and templating framework originally based on HTML::Mason, the enterprise-level framework used by Amazon.com, del.icio.us and Salon.com, among many others. Myghty fully implements Mason's templating language, component-based architecture, and caching system, and goes beyond, adding new paradigms such the Module Components controller paradigm, full Python whitespace syntax, threading support, WSGI support, session support, and much more.

- http://www.myghty.org/index.myt

Beispiel:

Code: Alles auswählen

<%python>
  def somefunc():
    return True
</%python>

% if somefunc():
<p>
  hello!
</p>
% # end for
Pylons
Pylons combines the very best ideas from the worlds of Ruby, Python and Perl, providing a structured but extremely flexible Python web framework. It's also one of the first projects to leverage the emerging WSGI standard, which allows extensive re-use and flexibility — but only if you need it. Out of the box, Pylons aims to make web development fast, flexible and easy.

- http://pylonshq.com/


Karrigell
Karrigell ist ein einfaches Web-Framework. Es enthält einen eigenen Webserver, der vom Apachen aus per mod_rewrite mit Anfragen gefüttert wird. Was dieses Framework hervorhebt, ist die Art wie es gestartet werden kann. Siehe: http://karrigell.sourceforge.net/en/apache.htm

- http://karrigell.sourceforge.net/
- http://quentel.python-hosting.com/wiki/index.pih


Jinja 2
Jinja2 is a template engine written in pure Python. It provides a Django inspired non-XML syntax but supports inline expressions and an optional sandboxed environment.

- http://jinja.pocoo.org/
- http://pypi.python.org/pypi/Jinja2

Beispiel:

Code: Alles auswählen

{% extends 'base.html' %}
{% block title %}Memberlist{% endblock %}
{% block content %}
  <ul>
  {% for user in users %}
    <li><a href="{{ user.url }}">{{ user.username }}</a></li>
  {% endfor %}
  </ul>
{% endblock %}
Werkzeug
Werkzeug is a collection of various utilities for WSGI applications. It features request and response objects as well as a powerful url dispatcher and a debugging system.

- http://werkzeug.pocoo.org/


web2py (ehemals Gluon)
web2py is an open source full-stack Enterprise Framework for agile development of secure database-driven web-based applications, written and programmable in Python.

- http://mdp.cti.depaul.edu/
- http://mdp.cti.depaul.edu/examples/default/examples


Genshi
Genshi is a Python library that provides an integrated set of components for parsing, generating, and processing HTML, XML or other textual content for output generation on the web.

- http://genshi.edgewall.org/

Beispiel:

Code: Alles auswählen

<?python
  title = "A Genshi Template"
  fruits = ["apple", "orange", "kiwi"]
?>
<html xmlns:py="http://genshi.edgewall.org/">
  <head>
    <title py:content="title">This is replaced.</title>
  </head>
  <body>
    <p>These are some of my favorite fruits:</p>
    <ul>
      <li py:for="fruit in fruits">
        I like ${fruit}s
      </li>
    </ul>
  </body>
</html>

Mako
Mako is a template library written in Python. It provides a familiar, non-XML syntax which compiles into Python modules.

Philosophy: Python is a great scripting language. Don't reinvent the wheel...your templates can handle it !

- http://www.makotemplates.org/

Beispiel:

Code: Alles auswählen

<%inherit file="base.html"/>
<%
    rows = [[v for v in range(0,10)] for row in range(0,10)]
%>
<table>
    % for row in rows:
        ${makerow(row)}
    % endfor
</table>
   
<%def name="makerow(row)">
    <tr>
    % for name in row:
        <td>${name}</td>\
    % endfor
    </tr>
</%def>

Bottle
Bottle is a fast and simple WSGI web-framework for Python packed into a single file with no external dependencies.

- http://bottle.paws.de/

Beispiel:

Code: Alles auswählen

from bottle import route, run

@route('/')
def index():
    return 'Hello World!'

run(host='localhost', port=8080)

Flask
Flask is a microframework for Python based on Werkzeug, Jinja 2 and good intentions. And before you ask: It's BSD licensed!

- http://flask.pocoo.org/

Beispiel:

Code: Alles auswählen

from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello World!"

if __name__ == "__main__":
    app.run()


Texte, Links, Änderungs- oder Ergänzungswünsche bitte per PN an mich.


lg
Gerold
:-)
Zuletzt geändert von gerold am Montag 28. August 2006, 08:27, insgesamt 3-mal geändert.
http://halvar.at | Kleiner Bascom AVR Kurs
Wissen hat eine wunderbare Eigenschaft: Es verdoppelt sich, wenn man es teilt.
Antworten