请输入您要查询的百科知识:

 

词条 karrigell
释义

Karrigell is a flexible Python web framework, with a clear and intuitive syntax. It is independant from any database, ORM or templating engine, and lets the programmer choose between a variety of coding styles

The package includes a powerful built-in web server, so there's no need to download, install and configure a separate one, and a pure-Python database engine, buzhug, which is used for the demos

Karrigell can be configured to work with external web servers (Apache, Xitami, LightTPD) ; the scripts can use all the databases for which a Python API exists (sqlite, mySql, PostGreSQL, ZODB, etc)

A new application, InstantSite, is provided to easily create and edit MySQL databases and generate scripts that handle the usual CRUD operations on database tables. Take a look at the online Flash demo

To create dynamic pages, all you need to know is HTML and Python. You have the choice between different ways of mixing them. The "Hello world" program can be programmed in one of the 5 forms below :

Python script (hello.py) Karrigell service (hello.ks)

print "Hello, world !" def index():

print "Hello, world !"

HTML Inside Python (hello.hip) Python Inside HTML (hello.pih)

"Hello, world !" Hello, world !

CGI script (hello.py

in folder cgi-bin)

print "Content-type: text/html"

print

print "Hello, world !"

If you want to insert pieces of Python code, for instance to print the squares of the numbers from 0 to 9:

Python script Karrigell service

print "<h1>Squares</h1>"for i in range(10): print "%s :<b>%s</b>" %(i,i*i)

def index(): print "<h1>Squares</h1>" for i in range(10): print "%s :<b>%s</b>" %(i,i*i)

HTML Inside Python Python Inside HTML

"<h1>Squares</h1>"for i in range(10): "%s :<b>%s</b>" %(i,i*i)

<h1>Squares</h1><%for i in range(10): print "%s :<b>%s</b>" %(i,i*i)%>

CGI script

print 'Content-type: text/html'printprint "<h1>Squares</h1>"for i in range(10): print "%s :<b>%s</b>" %(i,i*i)

In short : you can use ordinary Python scripts Karrigell services are Python scripts where each function matches a different URL : foo.ks/bar matches the function bar() in the script foo.ks (if no function is specified, the function index() is used) HTML inside Python is another form of Python script, where lines beginning by a string are sent to the browser as if there were a print statement Python Inside HTML is very much like PHP or JSP, HTML pages with Python code inserted between the tags <% and %> You can use plain CGI scripts : see the documentation for the cgi module in the standard documentation

Python code is executed in a "clean" namespace including HTTP environment, form fields and custom exceptions. When a form includes the field <INPUT name="myfield">, the value is available in the script under the name _myfield

For authentication and session, two functions (unsurprisingly named Authentication and Session) can be used in scripts. Authentication takes an authentication test function as first argument, which checks if the AUTH_USER and AUTH_PASSWORD are accepted. Session() is used to initialize or retrieve a session object to which attributes can be set or read

The Include(file_or_script) function inserts the output of the script or file inside the output of current script ; this is useful for headers or footers for instance. If it's a script it is executed in the current namespace

Karrigell comes with a detailed documentation (en français), and a set of demo files, including a minimal Wiki server

If my home PC is online you can see Karrigell in action !

Go to the Sourceforge project page or follow the Download link above to get the latest stable version. You can also download the current, unstable development version

See the article in Linux Gazette : Dynamic Web Content with Karrigell

随便看

 

百科全书收录594082条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。

 

Copyright © 2004-2023 Cnenc.net All Rights Reserved
更新时间:2024/12/19 2:15:13