added tagcloud

This commit is contained in:
Massimo Di Pierro
2011-11-23 01:14:19 -06:00
parent 332c53c5e3
commit e9fadbc40b
132 changed files with 6645 additions and 1 deletions
@@ -0,0 +1,8 @@
{{extend 'layout.html'}}
<form>
<input type="button" onclick="fade('test',-0.2);" value="fade down"/>
<input type="button" onclick="fade('test',+0.2);" value="fade up"/>
</form>
<div id="test">{{='Hello World '*100}}</div>
@@ -0,0 +1,12 @@
{{extend 'layout.html'}}
<p>Type something and press the button.
The last 10 entries will appear sorted in a table below.</p>
<form>
<INPUT type="text" id="q" name = "q" value="web2py"/>
<INPUT type="button" value="submit"
onclick="ajax('{{=URL('data')}}',['q'],'target');"/>
</form>
<br/>
<div id="target"></div>
+233
View File
@@ -0,0 +1,233 @@
{{extend 'layout.html'}}
<script><!--
jQuery(document).ready(function(){
jQuery("table.sortable tbody tr").mouseover( function() {
jQuery(this).addClass("highlight"); }).mouseout( function() {
jQuery(this).removeClass("highlight"); });
jQuery('table.sortable tbody tr:odd').addClass('odd');
jQuery('table.sortable tbody tr:even').addClass('even');
});
//--></script>
{{if request.function=='index':}}
<h1>{{=T("Available databases and tables")}}</h1>
{{if not databases:}}{{=T("No databases in this application")}}{{pass}}
{{for db in sorted(databases):}}
{{for table in databases[db].tables:}}
{{qry='%s.%s.id>0'%(db,table)}}
{{tbl=databases[db][table]}}
{{if hasattr(tbl,'_primarykey'):}}
{{if tbl._primarykey:}}
{{firstkey=tbl[tbl._primarykey[0]]}}
{{if firstkey.type in ['string','text']:}}
{{qry='%s.%s.%s!=""'%(db,table,firstkey.name)}}
{{else:}}
{{qry='%s.%s.%s>0'%(db,table,firstkey.name)}}
{{pass}}
{{else:}}
{{qry=''}}
{{pass}}
{{pass}}
<h2>{{=A("%s.%s" % (db,table),_href=URL('select',args=[db],vars=dict(query=qry)))}}
</h2>
[ {{=A(str(T('insert new'))+' '+table,_href=URL('insert',args=[db,table]))}} ]
<br /><br />
{{pass}}
{{pass}}
{{elif request.function=='select':}}
<h1>{{=XML(str(T("database %s select"))%A(request.args[0],_href=URL('index'))) }}
</h1>
{{if table:}}
[ {{=A(str(T('insert new %s'))%table,_href=URL('insert',args=[request.args[0],table]))}} ]<br/><br/>
<h2>{{=T("Rows in table")}}</h2><br/>
{{else:}}
<h2>{{=T("Rows selected")}}</h2><br/>
{{pass}}
{{=form}}
<p>{{=T('The "query" is a condition like "db.table1.field1==\'value\'". Something like "db.table1.field1==db.table2.field2" results in a SQL JOIN.')}}<br/>
{{=T('Use (...)&(...) for AND, (...)|(...) for OR, and ~(...) for NOT to build more complex queries.')}}<br/>
{{=T('"update" is an optional expression like "field1=\'newvalue\'". You cannot update or delete the results of a JOIN')}}</p>
<br/><br/>
<h3>{{=nrows}} {{=T("selected")}}</h3>
{{if start>0:}}[ {{=A(T('previous 100 rows'),_href=URL('select',args=request.args[0],vars=dict(start=start-100)))}} ]{{pass}}
{{if stop<nrows:}}[ {{=A(T('next 100 rows'),_href=URL('select',args=request.args[0],vars=dict(start=start+100)))}} ]{{pass}}
{{if rows:}}
<div style="overflow: auto;" width="80%">
{{linkto=URL('update',args=request.args[0])}}
{{upload=URL('download',args=request.args[0])}}
{{=SQLTABLE(rows,linkto,upload,orderby=True,_class='sortable')}}
</div>
{{pass}}
<br/><br/><h2>{{=T("Import/Export")}}</h2><br/>
[ <a href="{{=URL('csv',args=request.args[0],vars=dict(query=query))}}">{{=T("export as csv file")}}</a> ]
{{if table:}}
{{=FORM(str(T('or import from csv file'))+" ",INPUT(_type='file',_name='csvfile'),INPUT(_type='hidden',_value=table,_name='table'),INPUT(_type='submit',_value='import'))}}
{{pass}}
{{elif request.function=='insert':}}
<h1>{{=T("database")}} {{=A(request.args[0],_href=URL('index'))}}
{{if hasattr(table,'_primarykey'):}}
{{fieldname=table._primarykey[0]}}
{{dbname=request.args[0]}}
{{tablename=request.args[1]}}
{{cond = table[fieldname].type in ['string','text'] and '!=""' or '>0'}}
{{=T("table")}} {{=A(tablename,_href=URL('select',args=dbname,vars=dict(query='%s.%s.%s%s'%(dbname,tablename,fieldname,cond))))}}
{{else:}}
{{=T("table")}} {{=A(request.args[1],_href=URL('select',args=request.args[0],vars=dict(query='%s.%s.id>0'%tuple(request.args[:2]))))}}
{{pass}}
</h1>
<h2>{{=T("New Record")}}</h2><br/>
{{=form}}
{{elif request.function=='update':}}
<h1>{{=T("database")}} {{=A(request.args[0],_href=URL('index'))}}
{{if hasattr(table,'_primarykey'):}}
{{fieldname=request.vars.keys()[0]}}
{{dbname=request.args[0]}}
{{tablename=request.args[1]}}
{{cond = table[fieldname].type in ['string','text'] and '!=""' or '>0'}}
{{=T("table")}} {{=A(tablename,_href=URL('select',args=dbname,vars=dict(query='%s.%s.%s%s'%(dbname,tablename,fieldname,cond))))}}
{{=T("record")}} {{=A('%s=%s'%request.vars.items()[0],_href=URL('update',args=request.args[:2],vars=request.vars))}}
{{else:}}
{{=T("table")}} {{=A(request.args[1],_href=URL('select',args=request.args[0],vars=dict(query='%s.%s.id>0'%tuple(request.args[:2]))))}}
{{=T("record id")}} {{=A(request.args[2],_href=URL('update',args=request.args[:3]))}}
{{pass}}
</h1>
<h2>{{=T("Edit current record")}}</h2><br/><br/>{{=form}}
{{elif request.function=='state':}}
<h1>{{=T("Internal State")}}</h1>
<h2>{{=T("Current request")}}</h2>
{{=BEAUTIFY(request)}}
<br/><h2>{{=T("Current response")}}</h2>
{{=BEAUTIFY(response)}}
<br/><h2>{{=T("Current session")}}</h2>
{{=BEAUTIFY(session)}}
{{elif request.function == 'ccache':}}
<h1>Cache</h1>
<div class="wrapper">
<div class="list">
<div class="list-header">
<h2>Statistics</h2>
</div>
<div class="content">
<h3>Overview</h3>
<p>Number of entries: <strong>{{=total['entries']}}</strong>
{{if total['entries'] > 0:}}
<p>
Hit Ratio:
<strong>{{=total['ratio']}}%</strong>
(<strong>{{=total['hits']}}</strong> hits
and <strong>{{=total['misses']}}</strong> misses)
</p>
<p>
Size of cache:
{{if object_stats:}}
<strong>{{=total['objects']}}</strong> items,
<strong>{{=total['bytes']}}</strong> bytes
{{if total['bytes'] > 524287:}}
(<strong>{{="%.0d" % (total['bytes'] / 1048576)}} MB</strong>)
{{pass}}
{{else:}} <strong>not available</strong> (requires the Python <a href="http://pypi.python.org/pypi/guppy/" target="_blank">guppy</a> library)
{{pass}}
</p>
<p>
Cache contains items up to
<strong>{{="%02d" % total['oldest'][0]}}</strong> hours
<strong>{{="%02d" % total['oldest'][1]}}</strong> minutes
<strong>{{="%02d" % total['oldest'][2]}}</strong> seconds old.
</p>
{{=BUTTON(T('Cache Keys'), _onclick='jQuery("#all_keys").toggle();')}}
<div class="hidden" id="all_keys">
{{=total['keys']}}
</div>
<br />
{{pass}}
<h3>RAM</h3>
<p>Number of entries: <strong>{{=ram['entries']}}</strong>
{{if ram['entries'] > 0:}}
<p>
Hit Ratio:
<strong>{{=ram['ratio']}}%</strong>
(<strong>{{=ram['hits']}}</strong> hits
and <strong>{{=ram['misses']}}</strong> misses)
</p>
<p>
Size of cache:
{{if object_stats:}}
<strong>{{=ram['objects']}}</strong> items,
<strong>{{=ram['bytes']}}</strong> bytes
{{if ram['bytes'] > 524287:}}
(<strong>{{=ram['bytes'] / 1048576}} MB</strong>)
{{pass}}
{{else:}} <strong>not available</strong> (requires the Python <a href="http://pypi.python.org/pypi/guppy/" target="_blank">guppy</a> library)
{{pass}}
</p>
<p>
RAM contains items up to
<strong>{{="%02d" % ram['oldest'][0]}}</strong> hours
<strong>{{="%02d" % ram['oldest'][1]}}</strong> minutes
<strong>{{="%02d" % ram['oldest'][2]}}</strong> seconds old.
</p>
{{=BUTTON(T('RAM Cache Keys'), _onclick='jQuery("#ram_keys").toggle();')}}
<div class="hidden" id="ram_keys">
{{=ram['keys']}}
</div>
<br />
{{pass}}
<h3>DISK</h3>
<p>Number of entries: <strong>{{=disk['entries']}}</strong>
{{if disk['entries'] > 0:}}
<p>
Hit Ratio:
<strong>{{=disk['ratio']}}%</strong>
(<strong>{{=disk['hits']}}</strong> hits
and <strong>{{=disk['misses']}}</strong> misses)
</p>
<p>
Size of cache:
{{if object_stats:}}
<strong>{{=disk['objects']}}</strong> items,
<strong>{{=disk['bytes']}}</strong> bytes
{{if disk['bytes'] > 524287:}}
(<strong>{{=disk['bytes'] / 1048576}} MB</strong>)
{{pass}}
{{else:}} <strong>not available</strong> (requires the Python <a href="http://pypi.python.org/pypi/guppy/" target="_blank">guppy</a> library)
{{pass}}
</p>
<p>
DISK contains items up to
<strong>{{="%02d" % disk['oldest'][0]}}</strong> hours
<strong>{{="%02d" % disk['oldest'][1]}}</strong> minutes
<strong>{{="%02d" % disk['oldest'][2]}}</strong> seconds old.
</p>
{{=BUTTON(T('Disk Cache Keys'), _onclick='jQuery("#disk_keys").toggle();')}}
<div class="hidden" id="disk_keys">
{{=disk['keys']}}
</div>
<br />
{{pass}}
</div>
<div class="list-header">
<h2>Manage Cache</h2>
</div>
<div class="content">
<p>
{{=form}}
</p>
</div>
</div>
<div class="clear"></div>
</div>
{{pass}}
@@ -0,0 +1,7 @@
{{extend 'layout_examples/layout_civilized.html'}}
<h1>Purchase form</h1>
{{=form}}
[ {{=A('reset purchased',_href=URL('reset_purchased'))}} |
{{=A('delete purchased',_href=URL('delete_purchased'))}} ]<br/>
<h2>Current purchases (SQL JOIN!)</h2>
<p>{{=records}}</p>
@@ -0,0 +1,6 @@
{{extend 'layout_examples/layout_civilized.html'}}
<h1>Dog registration form</h1>
{{=form}}
<h2>Current dogs</h2>
{{=records}}
@@ -0,0 +1,6 @@
{{extend 'layout_examples/layout_civilized.html'}}
<h1>Product registration form</h1>
{{=form}}
<h2>Current products</h2>
{{=records}}
@@ -0,0 +1,6 @@
{{extend 'layout_examples/layout_civilized.html'}}
<h1>User registration form</h1>
{{=form}}
<h2>Current users</h2>
{{=records}}
@@ -0,0 +1,5 @@
{{extend 'layout.html'}}
<div class="contentleft">
{{=changelog}}
</div>
@@ -0,0 +1,12 @@
{{extend 'layout.html'}}
<div class="contentleft">
<div >
{{=get_content('main')}}
</div>
{{=get_content('official')}}
{{=get_content('community')}}
{{=get_content('more')}}
</div>
@@ -0,0 +1,100 @@
{{response.files.append(URL('static','css/artwork.css'))}}
{{extend 'layout.html'}}
{{import os}}
{{version = request.env.web2py_version}}
<h2>web2py<sup style="font-size:0.5em;">TM</sup> Download</h2>
<center>
<table class="downloads">
<tr>
<th>Current ({{="%s.%s.%s %s" % (version[0],version[1],version[2],version[4])}})</th>
<th>Nightly Build (for testers)</th>
<th>Trunk (for developers)</th>
<th>plugin_wiki (add-on)</th>
</tr>
<tr>
<td><a class="button" href="http://www.web2py.com/examples/static/web2py_win.zip">For Windows</a></td>
<td><a class="button" href="http://www.web2py.com/examples/static/nightly/web2py_win.zip">For Windows</a></td>
<td><a class="button" href="http://code.google.com/p/web2py/" target="_blank">Mercurial Repository</a></td>
<td><a class="button" href="http://web2py.com/examples/static/web2py.plugin.wiki.w2p">Download</a></td>
</tr>
<tr>
<td><a class="button" href="http://www.web2py.com/examples/static/web2py_osx.zip">For Mac</a></td>
<td><a class="button" href="http://www.web2py.com/examples/static/nightly/web2py_osx.zip">For Mac</a></td>
<td><a class="button" href="http://code.google.com/p/web2py/issues/list" target="_blank">Issue Tracker</a></td>
<td><a class="button" href="http://code.google.com/p/cube2py/" target="_blank">Mercurial Repository</a>
</tr>
<tr>
<td><a class="button" href="http://www.web2py.com/examples/static/web2py_src.zip">Source Code</a></td>
<td><a class="button" href="http://www.web2py.com/examples/static/nightly/web2py_src.zip">Source Code</a></td>
<td><a class="button" href="{{=URL('static', 'epydoc/index.html')}}" target="_blank">Source Code Docs</a></td>
<td><a class="button" href="http://vimeo.com/13485916" target="_blank">What is plugin_wiki?</a></td>
</tr>
<tr>
<td><a class="button" href="{{=URL('changelog')}}">Change Log</a></td>
<td><a class="button" href="http://www.web2py.com/examples/static/nightly/tests.log">Unittest Log</a></td>
<td></td><td></td>
</tr>
</table>
</center>
<p style="text-align:left;">
The source code version works on all supported platforms, including Linux, but it requires Python 2.5, 2.6, or 2.7.
It runs on Windows and most Unix systems, including <b>Linux</b> and <b>BSD</b>.
</p>
<h3>Instructions</h3>
<p>After download, unzip it and click on web2py.exe (windows) or web2py.app (osx).
To run from source, type:</p>
{{=CODE("python2.5 web2py.py",language=None,counter='>',_class='boxCode')}}
<p>or for more info type:</p>
{{=CODE("python2.5 web2py.py -h",language=None,counter='>',_class='boxCode')}}
<h3>Caveats</h3>
<p>After installation, every time you run it, web2py asks you to choose a password. This password is your administrative password. If the password is left blank, the administrative interface is disabled. The administrative interface /admin/default/index is only accessible via localhost and always requires a password.</p>
<p>Any url /a/b/c maps into a call to application a, controller b.py and function c in that controller.</p>
<p>You are strongly advised to also use Apache with mod_proxy or mod_wsgi to access applications in the framework. This allows better security and concurrency.</p>
<h3 id="license">License</h3>
<p>Web2py code is released under <a href="http://www.gnu.org/licenses/lgpl.html">LGPLv3 License</a>. This license does not extend to third party libraries distributed with web2py (which can be MIT, BSD or Apache type licenses) nor does it extend to applications built with web2py (under the terms of the LGPL.</p>
<p>Applications built with web2py can be released under any license the author wishes as long they do not contain web2py code. They can link unmodified web2py libraries and they can be distributed with official web2py binaries. In particular web2py applications can be distributed in closed source. The admin interface provides a button to byte-code compile.</p>
<p>It is fine to distribute web2py (source or compiled) with your applications as long as you make it clear in the license where your application ends and web2py starts.</p>
<p>web2py is copyrighted by Massimo Di Pierro. The web2py trademark is owned by Massimo Di Pierro.</p>
[<a href="{{=URL('license')}}">read more</a>]
<h3>Artwork</h3>
<center>
<a href="{{=URL('static', 'images/logo_lb.png')}}"><img src="{{=URL('static', 'images/logo_lb.png')}}" width="200px"/></a>
<a href="{{=URL('static', 'images/logo_db.png')}}"><img src="{{=URL('static', '\
images/logo_db.png')}}" width="200px"/></a>
<a href="{{=URL('static', 'images/logo_bw.png')}}"><img src="{{=URL('static', '\
images/logo_bw.png')}}" width="200px"/></a>
</center>
<h3>Stickers</h3>
<center>
<a href="{{=URL('static', 'images/Stickers1.png')}}"><img src="{{=URL('static', 'images/Stickers1.png')}}" /></a>
<a href="{{=URL('static', 'images/Stickers2.png')}}"><img src="{{=URL('static', 'images/Stickers2.png')}}" /></a>
<a href="{{=URL('static', 'images/Stickers3.png')}}"><img src="{{=URL('static', 'images/Stickers3.png')}}" /></a>
<a href="{{=URL('static', 'images/Stickers4.png')}}"><img src="{{=URL('static', 'images/Stickers4.png')}}" /></a>
<a href="{{=URL('static', 'images/Stickers5.png')}}"><img src="{{=URL('static', 'images/Stickers5.png')}}" /></a>
<a href="{{=URL('static', 'images/Stickers6.png')}}"><img src="{{=URL('static', 'images/Stickers6.png')}}" /></a>
<a href="{{=URL('static', 'images/Stickers7.png')}}"><img src="{{=URL('static', 'images/Stickers7.png')}}" /></a>
<a href="{{=URL('static', 'images/Stickers8.png')}}"><img src="{{=URL('static', 'images/Stickers8.png')}}" /></a>
</center>
<p>
<a href="{{=URL('static', 'artwork.tar.gz')}}" >Download WEB2PY artwork pack in editable .png format</a>
</p>
<p>
Logo, Stickers and Layout developed by <a target="_blank" href="http://twitter.com/josev2010">José V. Sousa</a> and <a target="_blank" href="http://twitter.com/rochacbruno">Bruno Rocha</a> (at <a target="_blank" href="http://www.blouweb.com">Blouweb</a>) All rights reserved by <a target="_blank" href="http://mycti.cti.depaul.edu/people/facultyInfo_mycti.asp?id=343">Massimo Di Pierro</a> &copy; 2010
</p>
<p>
Favicon and HTML5 compatibility by <a target="_blank" href="">Martin Mulone</a>
</p>
<p>
Icon set made by <a href="http://chrfb.deviantart.com">Christian Burprich</a> licensed under a <a rel="license" target="_blank" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 License</a>
</p>
{{block sidebar}}{{end}}
{{block leftbadges}}{{end}}
@@ -0,0 +1,685 @@
{{extend 'layout.html'}}
{{import os}}
<div class="onecolcontent">
<h2>web2py<sup style="font-size:0.5em;">TM</sup> Examples</h2>
<div id="navigation">
<a href="#simple_examples">simple</a> |
<a href="#session_examples">session</a> |
<a href="#template_examples">template</a> |
<a href="#layout_examples">layout</a> |
<a href="#form_examples">form</a> |
<a href="#database_examples">database</a> |
<a href="#cache_examples">cache</a> |
<a href="#ajax_examples">ajax</a> |
<a href="#testing_examples">testing</a> |
<a href="#streaming_examples">streaming</a> |
<a href="#xmlrpc_examples">xmlrpc</a> |
<a href="http://www.web2py.com/book/default/chapter/06">dal</a> |
<a href="http://www.web2py.com/book/default/chapter/07">crud</a> |
<a href="http://www.web2py.com/book/default/chapter/08">auth</a>
</div>
<div id="scrollhere">
<h2 id="simple_examples">Simple Examples</h2>
<p><i>Here are some working and complete examples that explain the basic syntax of the framework.<br/>
You can click on the web2py keywords (in the highlighted code!) to get documentation.</i></p>
<h3>Example {{c=1}}{{=c}}{{c+=1}}</h3><b>In controller: simple_examples.py</b>
{{=CODE("""
def hello1():
return "Hello World"
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>If the controller function returns a string, that is the body of the rendered page.<br/>Try it here: <a href="/{{=request.application}}/simple_examples/hello1">hello1</a></p>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: simple_examples.py</b>
{{=CODE("""
def hello2():
return T("Hello World")
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>The function T() marks strings that need to be translated. Translation dictionaries can be created at /admin/default/design<br/>Try it here: <a href="/{{=request.application}}/simple_examples/hello2">hello2</a></p>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: simple_examples.py</b>
{{=CODE("""
def hello3():
return dict(message=T("Hello World"))
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<b>and view: simple_examples/hello3.html</b>
{{=CODE(open(os.path.join(request.folder,'views/simple_examples/hello3.html'),'r').read(),language='html',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>If you return a dictionary, the variables defined in the dictionery are visible to the view (template).
<br/>Try it here: <a href="/{{=request.application}}/simple_examples/hello3.html">hello3</a></p>
<p>Actions can also be be rendered in other formsts like JSON, <a href="/{{=request.application}}/simple_examples/hello3.json">hello3.json</a>, and XML, <a href="/{{=request.application}}/simple_examples/hello3.xml">hello3.xml</a></p>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: simple_examples.py</b>
{{=CODE("""
def hello4():
response.view='simple_examples/hello3.html'
return dict(message=T("Hello World"))
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>You can change the view, but the default is /[controller]/[function].html. If the default is not found web2py tries to render the page using the generic.html view.
<br/>Try it here: <a href="/{{=request.application}}/simple_examples/hello4">hello4</a></p>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: simple_examples.py</b>
{{=CODE("""
def hello5():
return HTML(BODY(H1(T('Hello World'),_style="color: red;"))).xml() # .xml to serialize
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>You can also generate HTML using helper objects HTML, BODY, H1, etc. Each of these tags is a class and the views know how to render the corresponding objects. The method .xml() serializes them and produce html/xml code for the page.
Each tag, DIV for example, takes three types of arguments:</p>
<ul>
<li>unnamed arguments, they correspond to nested tags</li>
<li>named arguments and name starts with '_'. These are mapped blindly into tag attributes and the '_' is removed. attributes without value like "READONLY" can be created with the argument "_readonly=ON".</li>
<li>named arguments and name does not start with '_'. They have a special meaning. See "value=" for INPUT, TEXTAREA, SELECT tags later.
</ul>
<p>Try it here: <a href="/{{=request.application}}/simple_examples/hello5">hello5</a></p>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: simple_examples.py</b>
{{=CODE("""
def hello6():
response.flash=T("Hello World in a flash!")
return dict(message=T("Hello World"))
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>response.flash allows you to flash a message to the user when the page is returned. Use session.flash instead of response.flash to display a message after redirection. With default layout, you can click on the flash to make it disappear.
<br/>Try it here: <a href="/{{=request.application}}/simple_examples/hello6">hello6</a></p>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: simple_examples.py</b>
{{=CODE("""
def status():
return dict(request=request,session=session,response=response)
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>Here we are showing the request, session and response objects using the generic.html template.
<br/>Try it here: <a href="/{{=request.application}}/simple_examples/status">status</a></p>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: simple_examples.py</b>
{{=CODE("""
def redirectme():
redirect(URL('hello3'))
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>You can do redirect.
<br/>Try it here: <a href="/{{=request.application}}/simple_examples/redirectme">redirectme</a></p>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: simple_examples.py</b>
{{=CODE("""
def raisehttp():
raise HTTP(400,"internal error")
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>You can raise HTTP exceptions to return an error page.
<br/>Try it here: <a href="/{{=request.application}}/simple_examples/raisehttp">raisehttp</a></p>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: simple_examples.py</b>
{{=CODE("""
def raiseexception():
1/0
return 'oops'
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>If an exception occurs (other than HTTP) a ticket is generated and the event is logged for the administrator. These tickets and logs can be accessed, reviewed and deleted at any later time.
<br/>Try it here: <a href="/{{=request.application}}/simple_examples/raiseexception">raiseexception</a></p>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: simple_examples.py</b>
{{=CODE("""
def servejs():
import gluon.contenttype
response.headers['Content-Type']=gluon.contenttype.contenttype('.js')
return 'alert("This is a Javascript document, it is not supposed to run!");'
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>You can serve other than HTML pages by changing the contenttype via the response.headers. The gluon.contenttype module can help you figure the type of the file to be served. NOTICE: this is not necessary for static files unless you want to require authorization.
<br/>Try it here: <a href="/{{=request.application}}/simple_examples/servejs">servejs</a></p>
<h3 id="example_json">Example {{=c}}{{c+=1}}</h3><b>In controller: simple_examples.py</b>
{{=CODE("""
def makejson():
return response.json(['foo', {'bar': ('baz', None, 1.0, 2)}])
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>If you are into Ajax, web2py includes gluon.contrib.<a href="http://cheeseshop.python.org/pypi/simplejson">simplejson</a>, developed by Bob Ippolito. This module provides a fast and easy way to serve asynchronous content to your Ajax page. gluon.simplesjson.dumps(...) can serialize most Python types into <a href="http://www.json.org">JSON</a>. gluon.contrib.simplejson.loads(...) performs the reverse operation.
<br/>Try it here: <a href="/{{=request.application}}/simple_examples/makejson">makejson</a></p>
<p>New in web2py 1.63: Any normal action returning a dict is automatically serialized in JSON if '.json' is appended to the URL.</p>
<h3 id="example_rtf">Example {{=c}}{{c+=1}}</h3><b>In controller: simple_examples.py</b>
{{=CODE("""
def makertf():
import gluon.contrib.pyrtf as q
doc=q.Document()
section=q.Section()
doc.Sections.append(section)
section.append('Section Title')
section.append('web2py is great. '*100)
response.headers['Content-Type']='text/rtf'
return q.dumps(doc)
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>web2py also includes gluon.contrib.<a href="http://pyrtf.sourceforge.net/">pyrtf</a>, developed by Simon Cusack and revised by Grant Edwards. This module allows you to generate Rich Text Format documents including colored formatted text and pictures.<br/>Try it here: <a href="/{{=request.application}}/simple_examples/makertf">makertf</a></p>
<h3 id="example_rss">Example {{=c}}{{c+=1}}</h3><b>In controller: simple_examples.py</b>
{{=CODE("""
def rss_aggregator():
import datetime
import gluon.contrib.rss2 as rss2
import gluon.contrib.feedparser as feedparser
d = feedparser.parse("http://rss.slashdot.org/Slashdot/slashdot/to")
rss = rss2.RSS2(title=d.channel.title,
link = d.channel.link,
description = d.channel.description,
lastBuildDate = datetime.datetime.now(),
items = [
rss2.RSSItem(
title = entry.title,
link = entry.link,
description = entry.description,
# guid = rss2.Guid('unkown'),
pubDate = datetime.datetime.now()) for entry in d.entries]
)
response.headers['Content-Type']='application/rss+xml'
return rss2.dumps(rss)
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>web2py includes gluon.contrib.<a href="http://www.dalkescientific.com/Python/PyRSS2Gen.html">rss2</a>, developed by Dalke Scientific Software, which generates RSS2 feeds, and
gluon.contrib.<a href="http://www.feedparser.org/">feedparser</a>, developed by Mark Pilgrim, which collects RSS and ATOM feeds. The above controller collects a slashdot feed and makes new one.
<br/>Try it here: <a href="/{{=request.application}}/simple_examples/rss_aggregator">rss_aggregator</a></p>
<h3 id="example_wiki">Example {{=c}}{{c+=1}}</h3><b>In controller: simple_examples.py</b>
{{=CODE("""
def ajaxwiki():
form=FORM(TEXTAREA(_id='text',_name='text'),
INPUT(_type='button',_value='markmin',
_onclick="ajax('ajaxwiki_onclick',['text'],'html')"))
return dict(form=form,html=DIV(_id='html'))
def ajaxwiki_onclick():
return MARKMIN(request.vars.text).xml()
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>The markmin wiki markup is described <a href="{{=URL(r=request,c='static',f='markmin.html')}}">here</a>.
web2py also includes gluon.contrib.<a href="http://code.google.com/p/python-markdown2/">markdown</a>.WIKI helper (markdown2) which converts WIKI markup to HTML following <a href="http://en.wikipedia.org/wiki/Markdown">this syntax</a>. In this example we added a fancy ajax effect.<br/>Try it here: <a href="/{{=request.application}}/simple_examples/ajaxwiki">ajaxwiki</a></p>
<h2 id="session_examples">Session Examples</h2>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: session_examples.py </b>
{{=CODE("""
def counter():
if not session.counter: session.counter=0
session.counter+=1
return dict(counter=session.counter)
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}<b>and view: session_examples/counter.html</b>
{{=CODE(open(os.path.join(request.folder,'views/session_examples/counter.html'),'r').read(),language='html',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>Click to count. The session.counter is persistent for this user and application. Every applicaiton within the system has its own separate session management.
<br/>Try it here: <a href="/{{=request.application}}/session_examples/counter">counter</a></p>
<h2 id="template_examples">Template Examples</h2>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: template_examples.py</b>
{{=CODE("""
def variables(): return dict(a=10, b=20)
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}<b>and view: template_examples/variables.html</b>
{{=CODE(open(os.path.join(request.folder,'views/template_examples/variables.html'),'r').read(),language='html',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>A view (also known as template) is just an HTML file with &#123;&#123;...&#125;&#125; tags. You can put ANY python code into the tags, no need to indent but you must use pass to close blocks. The view is transformed into a python code and then executed. &#123;&#123;=a&#125;&#125; prints a.xml() or escape(str(a)).
<br/>Try it here: <a href="/{{=request.application}}/template_examples/variables">variables</a></p>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: template_examples.py </b>
{{=CODE("""
def test_for(): return dict()
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}<b>and view: template_examples/test_for.html</b>
{{=CODE(open(os.path.join(request.folder,'views/template_examples/test_for.html'),'r').read(),language='html',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>You can do for and while loops.
<br/>Try it here: <a href="/{{=request.application}}/template_examples/test_for">test_for</a></p>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: template_examples.py </b>
{{=CODE("""
def test_if(): return dict()
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}<b>and view: template_examples/test_if.html</b>
{{=CODE(open(os.path.join(request.folder,'views/template_examples/test_if.html'),'r').read(),language='html',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>You can do if, elif, else.
<br/>Try it here: <a href="/{{=request.application}}/template_examples/test_if">test_if</a></p>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: template_examples.py </b>
{{=CODE("""
def test_try(): return dict()
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}<b>and view: template_examples/test_try.html</b>
{{=CODE(open(os.path.join(request.folder,'views/template_examples/test_try.html'),'r').read(),language='html',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>You can do try, except, finally.
<br/>Try it here: <a href="/{{=request.application}}/template_examples/test_try">test_try</a></p>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: template_examples.py </b>
{{=CODE("""
def test_def(): return dict()
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}<b>and view: template_examples/test_def.html</b>
{{=CODE(open(os.path.join(request.folder,'views/template_examples/test_def.html'),'r').read(),language='html',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>You can write functions in HTML too.
<br/>Try it here: <a href="/{{=request.application}}/template_examples/test_def">test_def</a></p>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: template_examples.py </b>
{{=CODE("""
def escape(): return dict(message='<h1>text is escaped</h1>')
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}<b>and view: template_examples/escape.html</b>
{{=CODE(open(os.path.join(request.folder,'views/template_examples/escape.html'),'r').read(),language='html',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>The argument of &#123;&#123;=...&#125;&#125; is always escaped unless it is an object with a .xml() method such as link, A(...), a FORM(...), a XML(...) block, etc.
<br/>Try it here: <a href="/{{=request.application}}/template_examples/escape">escape</a></p>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: template_examples.py </b>
{{=CODE("""
def xml():
return dict(message=XML('<h1>text is not escaped</h1>'))
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}<b>and view: template_examples/xml.html</b>
{{=CODE(open(os.path.join(request.folder,'views/template_examples/xml.html'),'r').read(),language='html',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>If you do not want to escape the argument of &#123;&#123;=...&#125;&#125; mark it as XML.
<br/>Try it here: <a href="/{{=request.application}}/template_examples/xml">xml</a></p>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: template_examples.py </b>
{{=CODE("""
def beautify(): return dict(message=BEAUTIFY(request))
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}<b>and view: template_examples/beautify.html</b>
{{=CODE(open(os.path.join(request.folder,'views/template_examples/beautify.html'),'r').read(),language='html',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>You can use BEAUTIFY to turn lists and dictionaries into organized HTML.
<br/>Try it here: <a href="/{{=request.application}}/template_examples/beautify">beautify</a></p>
<h2 id="layout_examples">Layout Examples</h2>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: layout_examples.py </b>
{{=CODE("""
def civilized():
response.menu=[['civilized',True,URL('civilized')],
['slick',False,URL('slick')],
['basic',False,URL('basic')]]
response.flash='you clicked on civilized'
return dict(message="you clicked on civilized")
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}<b>and view: layout_examples/civilized.html</b>
{{=CODE(open(os.path.join(request.folder,'views/layout_examples/civilized.html'),'r').read(),language='html',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>You can specify the layout file at the top of your view. civilized Layout file is a view that somewhere in the body contains &#123;&#123;include&#125;&#125;.
<br/>Try it here: <a href="/{{=request.application}}/layout_examples/civilized">civilized</a></p>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: layout_examples.py </b>
{{=CODE("""
def slick():
response.menu=[['civilized',False,URL('civilized')],
['slick',True,URL('slick')],
['basic',False,URL('basic')]]
response.flash='you clicked on slick'
return dict(message="you clicked on slick")
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}<b>and view: layout_examples/slick.html</b>
{{=CODE(open(os.path.join(request.folder,'views/layout_examples/slick.html'),'r').read(),language='html',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>Same here, but using a different template.<br/>Try it here: <a href="/{{=request.application}}/layout_examples/slick">slick</a></p>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: layout_examples.py </b>
{{=CODE("""
def basic():
response.menu=[['civilized',False,URL('civilized')],
['slick',False,URL('slick')],
['basic',True,URL('basic')]]
response.flash='you clicked on basic'
return dict(message="you clicked on basic")
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}<b>and view: layout_examples/basic.html</b>
{{=CODE(open(os.path.join(request.folder,'views/layout_examples/basic.html'),'r').read(),language='html',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>'layout.html' is the default template, every application has a copy of it.
<br/>Try it here: <a href="/{{=request.application}}/layout_examples/basic">basic</a></p>
<h2 id="form_examples">Form Examples</h2>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: form_examples.py</b>
{{=CODE("""
def form():
form=FORM(TABLE(TR("Your name:",INPUT(_type="text",_name="name",requires=IS_NOT_EMPTY())),
TR("Your email:",INPUT(_type="text",_name="email",requires=IS_EMAIL())),
TR("Admin",INPUT(_type="checkbox",_name="admin")),
TR("Sure?",SELECT('yes','no',_name="sure",requires=IS_IN_SET(['yes','no']))),
TR("Profile",TEXTAREA(_name="profile",value="write something here")),
TR("",INPUT(_type="submit",_value="SUBMIT"))))
if form.accepts(request,session):
response.flash="form accepted"
elif form.errors:
response.flash="form is invalid"
else:
response.flash="please fill the form"
return dict(form=form,vars=form.vars)
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>You can use HTML helpers like FORM, INPUT, TEXTAREA, OPTION, SELECT to build forms. The "value=" attribute sets the initial value of the field (works for TEXTAREA and OPTION/SELECT too) and the requires attribute sets the validators.
FORM.accepts(..) tries to validate the form and, on success, stores vars into form.vars. On failure the error messages are stored into form.errors and shown in the form.
<br/>Try it here: <a href="/{{=request.application}}/form_examples/form">form</a></p>
<h2 id="database_examples">Database Examples</h2>
<p>You can find more examples of the web2py Database Abstraction Layer <a href="http://www.web2py.com/book/default/chapter/06">here</a></p>
<p>Let's create a simple model with users, dogs, products and purchases (the database of an animal store). Users can have many dogs (ONE TO MANY), can buy many products and every product can have many buyers (MANY TO MANY).</p>
<h3>Example {{=c}}{{c+=1}}</h3><b>in model: db.py</b>
{{=CODE("""
db=DAL('sqlite://storage.db')
db.define_table('users',
Field('name'),
Field('email'))
# ONE (users) TO MANY (dogs)
db.define_table('dogs',
Field('owner_id',db.users),
Field('name'),
Field('type'),
Field('vaccinated','boolean',default=False),
Field('picture','upload',default=''))
db.define_table('products',
Field('name'),
Field('description','text'))
# MANY (users) TO MANY (products)
db.define_table('purchases',
Field('buyer_id',db.users),
Field('product_id',db.products),
Field('quantity','integer'))
purchased=((db.users.id==db.purchases.buyer_id)&(db.products.id==db.purchases.product_id))
db.users.name.requires=IS_NOT_EMPTY()
db.users.email.requires=[IS_EMAIL(), IS_NOT_IN_DB(db,'users.email')]
db.dogs.owner_id.requires=IS_IN_DB(db,'users.id','users.name')
db.dogs.name.requires=IS_NOT_EMPTY()
db.dogs.type.requires=IS_IN_SET(['small','medium','large'])
db.purchases.buyer_id.requires=IS_IN_DB(db,'users.id','users.name')
db.purchases.product_id.requires=IS_IN_DB(db,'products.id','products.name')
db.purchases.quantity.requires=IS_INT_IN_RANGE(0,10)
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>
Tables are created if they do not exist (try... except).
Here "purchased" is an SQLQuery object, "db(purchased)" would be a SQLSet objects. A SQLSet object can be selected, updated, deleted. SQLSets can also be intersected. Allowed field types are string, integer, password, text, blob, upload, date, time, datetime, references(*), and id(*). The id field is there by default and must not be declared. references are for one to many and many to many as in the example above. For strings you should specify a length or you get length=32.<br/><br/>
You can use db.tablename.fieldname.requires= to set restrictions on the field values. These restrictions are automatically converted into widgets when generating forms from the table with SQLFORM(db.tablename).
<br/><br/>
define_tables creates the table and attempts a migration if table has changed or if database name has changed since last time. If you know you already have the table in the database and you do not want to attempt a migration add one last argument to define_table <tt>migrate=False</tt>.</p>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: database_examples.py </b>
{{=CODE("""
response.menu=[['Register User',False,URL('register_user')],
['Register Dog',False,URL('register_dog')],
['Register Product',False,URL('register_product')],
['Buy product',False,URL('buy')]]
def register_user():
### create an insert form from the table
form=SQLFORM(db.users)
### if form is correct, perform the insert
if form.accepts(request,session):
response.flash='new record inserted'
### and get a list of all users
records=SQLTABLE(db().select(db.users.ALL))
return dict(form=form,records=records)
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}<b>and view: database_examples/register_user.html</b>
{{=CODE(open(os.path.join(request.folder,'views/database_examples/register_user.html'),'r').read(),language='html',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>This is a simple user registration form. SQLFORM takes a table and returns the corresponding entry form with validators, etc. SQLFORM.accepts is similar to FORM.accepts but, if form is validated, the corresponding insert is also performed. SQLFORM can also do update and edit if a record is passed as its second argument.
SQLTABLE instead turns a set of records (result of a select) into an HTML table with links as specified by its optional parameters.
The response.menu on top is just a variable used by the layout to make the navigation menu for all functions in this controller.<br/>
Try it here: <a href="/{{=request.application}}/database_examples/register_user">register_user</a></p>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: database_examples.py </b>
{{=CODE("""
def register_dog():
form=SQLFORM(db.dogs)
if form.accepts(request,session):
response.flash='new record inserted'
download=URL('download') # to see the picture
records=SQLTABLE(db().select(db.dogs.ALL),upload=download)
return dict(form=form,records=records)
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}<b>and view: database_examples/register_dog.html</b>
{{=CODE(open(os.path.join(request.folder,'views/database_examples/register_dog.html'),'r').read(),language='html',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>Here is a dog registration form. Notice that the "image" (type "upload") field is rendered into a &lt;INPUT type="file"&gt; html tag. SQLFORM.accepts(...) handles the upload of the file into the uploads/ folder.
<br/>Try it here: <a href="/{{=request.application}}/database_examples/register_dog">register_dog</a></p>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: database_examples.py </b>
{{=CODE("""
def register_product():
form=SQLFORM(db.products)
if form.accepts(request,session):
response.flash='new record inserted'
records=SQLTABLE(db().select(db.products.ALL))
return dict(form=form,records=records)
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}<b>and view: database_examples/register_product.html</b>
{{=CODE(open(os.path.join(request.folder,'views/database_examples/register_product.html'),'r').read(),language='html',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>Nothing new here.
<br/>Try it here: <a href="/{{=request.application}}/database_examples/register_product">register_product</a></p>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: database_examples.py </b>
{{=CODE("""
def buy():
form=FORM(TABLE(TR("Buyer id:",INPUT(_type="text",_name="buyer_id",requires=IS_NOT_EMPTY())),
TR("Product id:",INPUT(_type="text",_name="product_id",requires=IS_NOT_EMPTY())),
TR("Quantity:",INPUT(_type="text",_name="quantity",requires=IS_INT_IN_RANGE(1,100))),
TR("",INPUT(_type="submit",_value="Order"))))
if form.accepts(request,session):
### check if user is in the database
if len(db(db.users.id==form.vars.buyer_id).select())==0:
form.errors.buyer_id="buyer not in database"
### check if product is in the database
if len(db(db.products.id==form.vars.product_id).select())==0:
form.errors.product_id="product not in database"
### if no errors
if len(form.errors)==0:
### get a list of same purchases by same user
purchases=db((db.purchases.buyer_id==form.vars.buyer_id)&
(db.purchases.product_id==form.vars.product_id)).select()
### if list contains a record, update that record
if len(purchases)>0:
purchases[0].update_record(quantity=purchases[0].quantity+form.vars.quantity)
### or insert a new record in table
else:
db.purchases.insert(buyer_id=form.vars.buyer_id,
product_id=form.vars.product_id,
quantity=form.vars.quantity)
response.flash="product purchased!"
if len(form.errors): response.flash="invalid valus in form!"
### now get a list of all purchases
records=db(purchased).select(db.users.name,db.purchases.quantity,db.products.name)
return dict(form=form,records=SQLTABLE(records),vars=form.vars,vars2=request.vars)
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}<b>and view: database_examples/buy.html</b>
{{=CODE(open(os.path.join(request.folder,'views/database_examples/buy.html'),'r').read(),language='html',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>Here is a rather sophisticated buy form. It checks that the buyer and the product are in the database and updates the corresponding record or inserts a new purchase. It also does a JOIN to list all purchases.
<br/>Try it here: <a href="/{{=request.application}}/database_examples/buy">buy</a></p>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: database_examples.py</b>
{{=CODE("""
def delete_purchased():
db(db.purchases.id>0).delete()
redirect(URL('buy'))
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}Try it here: <a href="/{{=request.application}}/database_examples/delete_purchased">delete_purchased</a>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: database_examples.py</b>
{{=CODE("""
def reset_purchased():
db(db.purchases.id>0).update(quantity=0)
redirect(URL('buy'))
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>This is an update on an SQLSet. (db.purchase.id>0 identifies the set containing only table db.purchases.)
<br/>Try it here: <a href="/{{=request.application}}/database_examples/reset_purchased">reset_purchased</a></p>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: database_examples.py</b>
{{=CODE("""
def download():
return response.download(request,db)
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>This controller allows users to download the uploaded pictures of the dogs.
Remember the upload=URL(...'download'...) statement in the register_dog function. Notice that in the URL path /application/controller/function/a/b/etc a, b, etc are passed to the controller as request.args[0], request.args[1], etc. Since the URL is validated request.args[] always contain valid filenames and no '~' or '..' etc. This is useful to allow visitors to link uploaded files.</p>
<h2 id="cache_examples">Cache Examples</h2>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: cache_examples.py </b>
{{=CODE("""
def cache_in_ram():
import time
t=cache.ram('time',lambda:time.ctime(),time_expire=5)
return dict(time=t,link=A('click to reload',_href=URL(r=request)))
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>The output of <tt>lambda:time.ctime()</tt> is cached in ram for 5 seconds. The string 'time' is used as cache key.
<br/>Try it here: <a href="/{{=request.application}}/cache_examples/cache_in_ram">cache_in_ram</a></p>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: cache_examples.py </b>
{{=CODE("""
def cache_on_disk():
import time
t=cache.disk('time',lambda:time.ctime(),time_expire=5)
return dict(time=t,link=A('click to reload',_href=URL(r=request)))
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>The output of <tt>lambda:time.ctime()</tt> is cached on disk (using the shelve module) for 5 seconds.
<br/>Try it here: <a href="/{{=request.application}}/cache_examples/cache_on_disk">cache_on_disk</a></p>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: cache_examples.py </b>
{{=CODE("""
def cache_in_ram_and_disk():
import time
t=cache.ram('time',lambda:cache.disk('time',
lambda:time.ctime(),time_expire=5),time_expire=5)
return dict(time=t,link=A('click to reload',_href=URL(r=request)))
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>The output of <tt>lambda:time.ctime()</tt> is cached on disk (using the shelve module) and then in ram for 5 seconds. web2py looks in ram first and if not there it looks on disk. If it is not on disk it calls the function. This is useful in a multiprocess type of environment. The two times do not have to be the same.
<br/>Try it here: <a href="/{{=request.application}}/cache_examples/cache_in_ram_and_disk">cache_in_ram_and_disk</a></p>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: cache_examples.py </b>
{{=CODE("""
@cache(request.env.path_info,time_expire=5,cache_model=cache.ram)
def cache_controller_in_ram():
import time
t=time.ctime()
return dict(time=t,link=A('click to reload',_href=URL(r=request)))""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>Here the entire controller (dictionary) is cached in ram for 5 seconds. The result of a select cannot be cached unless it is first serialized into a table <tt>lambda:SQLTABLE(db().select(db.users.ALL)).xml()</tt>. You can read below for an even better way to do it.
<br/>Try it here: <a href="/{{=request.application}}/cache_examples/cache_controller_in_ram">cache_controller_in_ram</a></p>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: cache_examples.py </b>
{{=CODE("""
@cache(request.env.path_info,time_expire=5,cache_model=cache.disk)
def cache_controller_on_disk():
import time
t=time.ctime()
return dict(time=t,link=A('click to reload',_href=URL(r=request)))
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>Here the entire controller (dictionary) is cached on disk for 5 seconds. This will not work if the dictionary contains unpickleable objects.
<br/>Try it here: <a href="/{{=request.application}}/cache_examples/cache_controller_on_disk">cache_controller_on_disk</a></p>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: cache_examples.py </b>
{{=CODE("""
@cache(request.env.path_info,time_expire=5,cache_model=cache.ram)
def cache_controller_and_view():
import time
t=time.ctime()
d=dict(time=t,link=A('click to reload',_href=URL(r=request)))
return response.render(d)
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p><tt>response.render(d)</tt> renders the dictionary inside the controller, so everything is cached now for 5 seconds. This is best and fastest way of caching!
<br/>Try it here: <a href="/{{=request.application}}/cache_examples/cache_controller_and_view">cache_controller_and_view</a></p>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: cache_examples.py </b>
{{=CODE("""
def cache_db_select():
import time
db.users.insert(name='somebody',email='gluon@mdp.cti.depaul.edu')
records=db().select(db.users.ALL,cache=(cache.ram,5))
if len(records)>20: db(db.users.id>0).delete()
return dict(records=records)
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>The results of a select are complex unpickleable objects that cannot be cached using the previous method, but the select command takes an argument <tt>cache=(cache_model,time_expire)</tt> and will cache the result of the query accordingly. Notice that the key is not necessary since key is generated based on the database name and the select string.
<br/>Try it here: <a href="/{{=request.application}}/cache_examples/cache_db_select">cache_db_select</a></p>
<h2 id="ajax_examples">Ajax Examples</h2>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: ajax_examples.py</b>
{{=CODE("""
def index():
return dict()
def data():
if not session.m or len(session.m)==10: session.m=[]
if request.vars.q: session.m.append(request.vars.q)
session.m.sort()
return TABLE(*[TR(v) for v in session.m]).xml()
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<b>In view: ajax_examples/index.html</b>
{{=CODE(open(os.path.join(request.folder,'views/ajax_examples/index.html'),'r').read(),language='html',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>The javascript function "ajax" is provided in "web2py_ajax.html" and included by "layout.html". It takes three arguments, a url, a list of ids and a target id. When called, it sends to the url (via a get) the values of the ids and display the response in the value (of innerHTML) of the target id.
<br/>Try it here: <a href="/{{=request.application}}/ajax_examples/index">index</a></p>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: ajax_examples.py </b>
{{=CODE("""
def flash():
response.flash='this text should appear!'
return dict()
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>Try it here: <a href="/{{=request.application}}/ajax_examples/flash">flash</a></p>
<h3>Example {{=c}}{{c+=1}}</h3><b>In controller: ajax_examples.py </b>
{{=CODE("""
def fade():
return dict()
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<b>In view: ajax_examples/fade.html </b><br/>
{{=CODE(open(os.path.join(request.folder,'views/ajax_examples/fade.html'),'r').read(),language='html',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>Try it here: <a href="/{{=request.application}}/ajax_examples/fade">fade</a></p>
<h3>Excel-like spreadsheet via Ajax</h3>
Web2py includes a widget that acts like an Excel-like spreadsheet and can be used to build forms
[<a href="{{=URL(r=request,c='spreadsheet',f='index')}}">read more</a>].
<h2 id="testing_examples">Testing Examples</h2>
<h3>Example {{=c}}{{c+=1}}</h3>
<p>Using the Python doctest notation it is possible to write tests for all controller functions. Tests are then run via the administrative interface which generates a report. Here is an example of a test in the code:
{{=CODE("""
def index():
'''
This is a docstring. The following 3 lines are a doctest:
>>> request.vars.name='Max'
>>> index()
{'name': 'Max'}
'''
return dict(name=request.vars.name)
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p></p>
<h2 id="streaming_examples">Streaming Examples</h2>
<h3 id="example_stream">Example {{=c}}{{c+=1}}</h3>
<p>It is very easy in web2py to stream large files. Here is an example of a controller that does so:</p>
{{=CODE("""
def streamer():
import os
path=os.path.join(request.folder,'private','largefile.mpeg4')
return response.stream(open(path,'rb'),chunk_size=4096)
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
<p>By default all static files and files stored in 'upload' fields in the database are streamed when larger than 1MByte.</p>
</p>web2py automatically and transparently handles PARTIAL_CONTENT and RANGE requests.</p>
<h2 id="xmlrpc_examples">XML-RPC Examples</h2>
<h3>Example {{=c}}{{c+=1}}</h3>
<p>Web2py has native support for the XMLRPC protocol. Below is a controller function "handler" that exposes two functions, "add" and "sub" via XMLRPC. The controller "tester" executes the two function remotely via xmlrpc.</p>
{{=CODE("""
from gluon.tools import Service
service = Service(globals())
@service.xmlrpc
def add(a,b): return a+b
@service.xmlrpc
def sub(a,b): return a-b
def call(): return service()
def tester():
import xmlrpclib
server=xmlrpclib.ServerProxy('http://hostname:port/app/controller/call/xmlrpc')
return str(server.add(3,4)+server.sub(3,4))
""".strip(),language='web2py',link=URL(r=request,c='global',f='vars'),_class='boxCode')}}
</div>
</div>
{{block sidebar}}{{end}}
@@ -0,0 +1,54 @@
{{right_sidebar_enabled=True}}
{{extend 'layout.html'}}
<h3>WEB2PY<sup>TM</sup> WEB FRAMEWORK</h3>
<p>Free open source full-stack framework for rapid development of fast, scalable, <a href="http://www.web2py.com/book/default/chapter/01#security" target="_blank">secure</a> and portable database-driven web-based applications. Written and programmable in <a href="http://www.python.org" target="_blank">Python</a>. <a href="http://www.gnu.org/licenses/lgpl.html">LGPLv3 License</a></p>
<center>
<img src="{{=URL('static','images/tag-cloud-color-small.png')}}"/>
</center>
{{block extra}}
<div class="container">
<div class="sixteen columns">
<div class="five columns">
<h3><a href="{{=URL('about')}}">BATTERIES INCLUDED</a></h3>
<p>Everything you need in one package including fast multi-threaded web server, SQL database and web-based interface. No third party dependencies but works with <a href={{=URL('what')}}>third party tools</a>.</p>
</div>
<div class="five columns">
<h3><a href="http://web2py.com/demo_admin">WEB-BASED IDE</a></h3>
<p>Create, modify, deploy and manage application from anywhere using your browser. One web2py instance can run multiple web sites using different databases. Try the <a href="http://web2py.com/demo_admin">interactive demo</a>.</p>
</div>
<div class="five columns">
<h3><a href="{{=URL('documentation')}}">EXTENSIVE DOCS</a></h3>
<p>Start with some <a href="{{=URL('examples')}}">quick examples</a>, then read the <a href="http://web2py.com/book">reference manual</a>, watch <a href="http://vimeo.com/album/178500">videos</a>, and join a <a href="{{=URL('default', 'usergroups')}}">user group</a> for discussion. Take advantage of the <a href="http://web2py.com/layouts">layouts</a>, <a href="http://dev.s-cubism.com/web2py_plugins">plugins</a>, and <a href="http://web2pyslices.com">recipes</a>.</p>
</div>
</div>
</div>
<div class="container">
<div class="sixteen columns">
<img src="{{=URL('static','images/shadow-bottom.png')}}" width="100%"/>
{{for k,quote in enumerate(quotes[:3]):}}
<div class="five columns">
<em>
<p>{{=quote[0]}}</p>
</em>
<span class="right">
<a href="{{=quote[2]}}"><em>{{=quote[1]}}</em></a>
</span>
</div>
{{pass}}
</div>
</div>
{{end}}
{{block right_sidebar}}
<center>
<a class="button" href="{{=URL('download')}}">DOWNLOAD NOW<br/>
{{="%s.%s.%s (%s) %s" % request.env.web2py_version}}
</a>
<br/>
<a href="http://web2py.com/book"><img src="{{=URL('static','images/tablet.png')}}" alt="Tablet" /></a>
</center>
{{end}}
@@ -0,0 +1,7 @@
{{extend 'layout.html'}}
<div class="onecolcontent">
<h2>web2py License Agreement</h2>
{{=license}}
</div>
@@ -0,0 +1,35 @@
{{extend 'layout.html'}}
<div class="contentleft">
<h2>Support for web2py<sup style="font-size:0.5em;">TM</sup></h2>
<p>You can get a lot of free support by joining our <a href="{{=URL('default', 'usergroups')}}">mailing list</a>.</p>
<h3>Affiliated Companies</h3>
<p>For long term professional support, code review, and contract work, you can contact our core developers:</p>
<ul>
<li><a href="http://experts4solutions.com">experts4solutions</a> (worldwide)</li>
</ul>
<p>For professional support, you can also contact one of the companies below:</p>
<ul>
<li><a target="_blank" href="http://www.metacryption.com">MetaCryption, LLC</a> (USA)</li>
<li><a target="_blank" href="http://www.blouweb.com">Blouweb Consultoria Digital</a> (Brasil)</li>
<li><a target="_blank" href="http://www.tecnodoc.com.ar">Tecnodoc</a> (Argentina)</li>
<li><a target="_blank" href="http://www.onemewebservices.com">OneMeWebServices</a> (Canada)</li>
<li><a target="_blank" href="http://www.budgetbytes.nl">BudgetBytes</a> (The Netherlands)</li>
<li><a target="_blank" href="http://www.androsoft.pl">ANDROSoft</a> (Poland)</li>
<li><a target="_blank" href="http://emotionull.com">Emotionull</a> (Greece and Cyprus)</li>
<li><a target="_blank" href="http://zarealye.com/ca/Collect_Advantage">Zarealye, Ltd.</a> (Russia)</li>
<li><a target="_blank" href="http://www.vsa-services.com/">VSA Services</a> (Singapore)</li>
<li><a target="_blank" href="http://www.albendas.com">Albendas</a> (Spain)</li>
<li><a target="_blank" href="https://loadinfo-net.appspot.com">LoadInfo</a> (Bulgaria)</li>
<li><a target="_blank" href="http://www.appliedobjects.com">Applied Objects</a> (New Zealand)</li>
<li><a target="_blank" href="http://www.sistemasagiles.com.ar/">Sistemas Ágiles</a> ("Agile Systems") (Argentina)</li>
</ul>
</div>
{{block leftbadges}}{{end}}
@@ -0,0 +1,9 @@
{{extend 'layout.html'}}
<div class="contentleft">
<div>
{{=get_content('grouplist')}}
</div>
</div>
@@ -0,0 +1,16 @@
{{extend 'layout.html'}}
<br /><br />
<div class="contentleft" style="z-index:0;text-align:center;">
<h2>{{=T('web2py videos')}}</h2>
<div id="vimeo" >
<object style="z-index:0" type="application/x-shockwave-flash" width="500" height="400" data="http://vimeo.com/hubnut/?user_id=user1959410&amp;color=00adef&amp;background=000000&amp;fullscreen=1&amp;slideshow=0&amp;stream=channel&amp;id=139244&amp;server=vimeo.com">
<param name="quality" value="best" />
<param name="allowfullscreen" value="true" />
<param name="allowscriptaccess" value="always" />
<param name="scale" value="showAll" />
<param name="movie" value="http://vimeo.com/hubnut/?user_id=user1959410&amp;color=00adef&amp;background=000000&amp;fullscreen=1&amp;slideshow=0&amp;stream=channel&amp;id=139244&amp;server=vimeo.com" />
</object>
</div>
</div>
@@ -0,0 +1,28 @@
{{right_sidebar_enabled = True}}
{{extend 'layout.html'}} {{import os}}
{{=get_content('whyweb2py')}}
{{block right_sidebar}}
<center>
<h3 class="feature-title">SITES POWERED BY WEB2PY</h3>
<a href="http://web2py.com/poweredby"><img class="frame" id="img1" width="200px"/></a>
<a href="http://web2py.com/poweredby"><img class="frame" id="img2" width="200px"/></a>
<a href="http://web2py.com/poweredby"><img class="frame" id="img3" width="200px"/></a>
<a href="http://web2py.com/poweredby"><img class="frame" id="img4" width="200px"/></a>
<a href="http://web2py.com/poweredby"><img class="frame" id="img5" width="200px"/></a>
<a href="http://web2py.com/poweredby"><img class="frame" id="img6" width="200px"/></a>
<a href="http://web2py.com/poweredby"><img class="frame" id="img7" width="200px"/></a>
<a href="http://web2py.com/poweredby"><img class="frame" id="img8" width="200px"/></a>
</div>
</center>
<script>
function showimages() {
var images = {{=images}};
rotation = Math.floor(Math.random()*(images.length-8));
for(var i=0; i<8; i++)
jQuery('#img'+(i+1)).attr('src',images[i+rotation]);
}
jQuery(function(){showimages();});
</script>
{{end}}
@@ -0,0 +1,157 @@
{{extend 'layout.html'}}
<div class="contentleft">
<h2>
The web2py&trade; Team
</h2>
<h3>
Lead Developer
</h3>
<ul>
<li>
<a target="_blank" href="http://mycti.cti.depaul.edu/people/facultyinfo_mycti.asp?id=343">Massimo Di Pierro</a>
(Associate Professor in Computer Science at DePaul University in Chicago)
</li>
</ul>
<h3>
Contributor Agreement
</h3>
<p>
By contributing to web2py you implicitly agree to the
<a target="_blank" href="{{=URL(r=request,c='static',f='web2py_contributor_agreement.pdf')}}">web2py contributor agreement</a>.
Please also send us a signed copy by fax or, scanned, by email.
<p/>
<h3>
Main Contributors
</h3>
<ul>
<li>Alexey Nezhdanov (GAE and database performance)
</li><li>Alvaro Justen (dynamical translations)
</li><li>Andrew Willimott (documentation)
</li><li>Angelo Compagnucci (mobile devices)
</li><li>Anthony Bastardi (book, poweredby site, multiple contributions)
</li><li>Arun K. Rajeevan (plugin_wiki)
</li><li>Attila Csipa (cron job)
</li><li>Bill Ferrett (modular DAL design)
</li><li>Boris Manojlovic (ajax edit)
</li><li>Branko Vukelic (new admin app)
</li><li>Brian Meredyk (SQLite, executesql and scheduler)
</li><li><a href="http://www.blouweb.com">Bruno Rocha</a> (book, new website, better forms, grid layout)
</li><li>Carlos Galindo
</li><li>Carsten Haese (Informix)
</li><li>Chris Clark (Ingres, Jython support)
</li><li>Chris Steel
</li><li>Christian Foster Howes (GAE support)
</li><li>Christopher Smiga (Informix)
</li><li>CJ Lazell (tester)
</li><li>Craig Younkins (Security)
</li><li>Daniel Lin (Taiwanese internationalization)
</li><li>Dave Stoll (DowCommerce payment API)
</li><li>David Wagner (security and cryptography expert)
</li><li>Denes Lengyel (validators, DB2 support, DAL, custom forms, legacy table support)
</li><li>Douglas Soares de Andrade (2.4 and 2.6 compliance, docstrings)
</li><li>Eric Vicenti (email with ssl)
</li><li>Falko Krause (mysql support)
</li><li><a href="http://Ourway.ir">Farsheed Ashouri</a>
</li><li>Fran Boon (authorization and authentication)
</li><li>Francisco Gama (bug fixing)
</li><li>Fred Yanowski (XHTML compliance)
</li><li><a href="https://github.com/contatogilsonsbf">Gilson Filho</a>
</li><li>Graham Dumpleton (WSGI)
</li><li>Gyuris Szabolcs (PGP Mail)
</li><li>Hamdy Abdel-Badeea (crud)
</li><li>Hans Donner (GAE support, Google login, widgets, Sphinx documentation)
</li><li>Hans Murx (Database support)
</li><li>Hans C. v. Stockhausen (OpenID, Google Wave)
</li><li>Ian Reinhart Geiser (html helpers)
</li><li>Jan Beilicke (markmin)
</li><li>Jonathan Benn (is_url validator and tests)
</li><li>Jonathan Lundell (multiple contributions)
</li><li>Josh Goldfoot (xaml/html sanitizer)
</li><li>Jose Jachuf (Firebird support)
</li><li>José L. Redrejo Rodríguez (Debian Package, pyfpdf)
</li><li>Josh Jaques (web2py_ajax)
</li><li>José Vicente de Sousa (Layout for new website)
</li><li>Keith Yang (openid)
</li><li><a href="http://dev.s-cubism.com/web2py_plugins">Kenji Hosoda</a> (plugins)
</li><li>Kyle Smith (javascript)
</li><li><a href="http://blog.donews.com/limodou/">Limodou</a> (winservice)
</li><li><a href="https://github.com/lucasdavila">Lucas D'Ávila</a>
</li><li><a href="http://www.mlsystems.ch">Marcel Leuthi</a> (Oracle support)
</li><li>Marcel Hellkamp (Bottle developer, multiple web server support)
</li><li>Marcello Della Longa (italian translation)
</li><li>Mariano Reingart (pysoaplib)
</li><li>Mark Larsen (taskbar widget)
</li><li>Mark Moore (databases and daemon scripts)
</li><li>Markus Gritsch (bug fixing)
</li><li>Martin Hufsky (expressions in DAL)
</li><li><a href="http://martin.tecnodoc.com.ar/">Martin Mulone</a> (new welcome app, grid)
</li><li>Mateusz Banach (stickers, IS_EMAIL, IS_IMAGE, contenttype)
</li><li>Michael Willis (shell)
</li><li>Michele Comitini (faceboook)
</li><li>Nathan Freeze (admin design, IS_STRONG, DAL features, <a href="http://web2pyslices.com">web2pyslices.com</a>)
</li><li>Niall Sweeny (MSSQL support)
</li><li>Niccolo Polo (epydoc)
</li><li>Nicolas Bruxer (memcache support)
</li><li>Olaf Ferger (Informix support)
</li><li>Omi Chiba (DB2, MSSQL support and Japanese translation)
</li><li>Ondrej Such (MSSQL support)
</li><li>Ovidio Marinho Falcao Neto (tests and plugins)
</li><li>Pai (internationalization)
</li><li>Paolo Caruccio (SQLFORM.grid query)
</li><li>Patrick Breitenbach
</li><li><a href="mailto:phyo.arkarlwin@star-nix.net">Phyo Arkar Lwin</a> (web hosting and Jython tester)
</li><li>Pierre Thibault (<a href="http://code.google.com/p/neo-web2py2eclipse/">Eclipse integration</a> and custom import)
</li><li><a href="http://robinbhattacharyya.com/">Robin Bhattacharyya</a> (Google App Engine support)
</li><li>Ross Peoples (MSSQL, multiple contributions)
</li><li>Ruijun Luo (a.k.a. Iceberg) (setup_exe.py)
</li><li>Ryan Seto (template.py)
</li><li>Scott Roberts (testing, book)
</li><li>Sergey Podlesnyi (Oracle and migrations tester)
</li><li>Sharriff Aina (tester and PyAMF integration)
</li><li>Simone Bizzotto (scheduler, redis)
</li><li>Sriram Durbha (book)
</li><li>Sterling Hankins (tester, book)
</li><li>Stuart Rackham (MSSQL support)
</li><li>Telman Yusupov (Oracle support)
</li><li>Thadeus Burgess (validators)
</li><li>Tim Michelsen (Sphinx documentation)
</li><li>Timothy Farrell (python 2.6 compliance, windows support)
</li><li>Yair Eshel (internationalizaiton)
</li><li>Yarko Tymciurak (design, Sphinx documentation)
</li><li>Younghyun Jo (internationalization)
</li><li>Vidul Nikolaev Petrov (captcha)
</li><li>Vinicius Assef
</li><li>Zahariash (memory management)
</li>
</ul>
<h3>
Third party software included in web2py
</h3>
<ul>
<li><a href="http://www.python.org">Python</a> created by Guido van Rossum.</li>
<li>Rocket Web Server developed by Timothy Farrell.</li>
<li><a href="http://www.cdolivet.com/index.php?page=editArea">EditArea</a> developed by Christophe Dolivet</li>
<li><a href="http://nicedit.com">nicEdit</a> developed by <a href="http://bkirchoff.com">Brian Kirchoff</a></li>
<li><a href="http://cheeseshop.python.org/pypi/simplejson">simplejson</a> developed by Bob Ippolito</li>
<li><a href="http://pyrtf.sourceforge.net/">PyRTF</a> developed by Simon Cusack and revised by Grant Edwards</li>
<li><a href="http://www.dalkescientific.com/Python/PyRSS2Gen.html">PyRSS2Gen</a> developed by Dalke Scientific Software</li>
<li><a href="http://www.feedparser.org/">feedparser</a> developed by Mark Pilgrim</li>
<li><a href="http://code.google.com/p/python-markdown2/">markdown2</a> developed by Trent Mick</li>
<li><a href="http://svn.saddi.com/py-lib/trunk/fcgi.py">fcgi.py</a> devloped by Allan Saddi (for production Lighttpd servers)</li>
<li><a href="http://www.danga.com/memcached/">memcache</a> developed by Evan Martin</li>
<li><a href="http://jquery.com/">jQuery</a> developed by John Resig</li>
<li>A syntax highlighter inspired by the code of <a href="http://www.petersblog.org/node/763">Peter Wilkinson</a></li>
</ul>
</div>
+3
View File
@@ -0,0 +1,3 @@
{{extend 'layout.html'}}
{{=BEAUTIFY(response._vars)}}
{{block sidebar}}{{end}}
+15
View File
@@ -0,0 +1,15 @@
{{
###
# response._vars contains the dictionary returned by the controller action
###
try:
from gluon.serializers import json
response.write(json(response._vars), escape=False)
response.headers['Content-Type'] = 'application/json; charset=utf-8'
except (TypeError, ValueError):
raise HTTP(405, 'JSON serialization error')
except ImportError:
raise HTTP(405, 'JSON not available')
except:
raise HTTP(405, 'JSON error')
}}
+1
View File
@@ -0,0 +1 @@
{{response.headers['web2py-response-flash']=response.flash}}{{if len(response._vars)==1:}}{{=response._vars.values()[0]}}{{else:}}{{=BEAUTIFY(response._vars)}}{{pass}}
+20
View File
@@ -0,0 +1,20 @@
{{
###
# response._vars contains the dictionary returned by the controller action
# for this to work the action must return something like
#
# dict(title=...,link=...,description=...,created_on='...',items=...)
#
# items is a list of dictionaries each with title, link, description, pub_date.
###
try:
from gluon.serializers import rss
response.write(rss(response._vars), escape=False)
response.headers['Content-Type'] = 'application/rss+xml'
except (TypeError, ValueError):
raise HTTP(405, 'RSS serialization error')
except ImportError:
raise HTTP(405, 'RSS not available')
except:
raise HTTP(405, 'RSS error')
}}
+15
View File
@@ -0,0 +1,15 @@
{{
###
# response._vars contains the dictionary returned by thecontroller action
###
try:
from gluon.serializers import xml
response.write(xml(response._vars), escape=False)
response.headers['Content-Type'] = 'text/xml'
except (TypeError, ValueError):
raise HTTP(405, 'XML serialization error')
except ImportError:
raise HTTP(405, 'XML not available')
except:
raise HTTP(405, 'XML error')
}}
@@ -0,0 +1,47 @@
{{extend 'layout.html'}}
{{import cgi}}
<div class="contentleft">
<h1>{{=T('Docs for')}} {{=title}}</h1>
<div align="right">
[ <a href="http://docs.python.org/tut/">Python Tutorial</a> ]
[ <a href="http://docs.python.org/lib/">Python Libraries</a> ]
[ <a href="/{{=request.application}}/static/epydoc/index.html">web2py epydoc</a> ]
</div>
<h2>{{=T('Description')}}</h2>
<br/>
{{if t:}}
{{=t}}{{if d:}} extends {{=d}}{{pass}}
{{pass}}
<br/>
{{pass}}
{{if doc:}}<br/><br/>{{=CODE(str(doc),language=None,counter=None,_class='boxCode')}}{{pass}}
<br/><br/>
<div class="boxInfo">
<h2>{{=T('Attributes')}}</h2>
{{keys=attributes.keys(); keys.sort()}}
<table>
<tr><td colspan=2><hr/></td></tr>
{{for a in keys:}}
{{doc1,t1,c1,d1=attributes[a]}}
<tr>
<td><b>{{#=a}}</b>{{=A(a,_href=URL(r=request,args=a.split('.')))}}</td>
<td>
{{if t1:}}
{{=t1}}{{if d1:}} extends {{=d1}}{{pass}}
{{if c1:}} belongs to class {{=c1}}{{pass}}
<br/>
{{pass}}
{{if doc1:}}{{=XML(cgi.escape(str(doc1)).replace(chr(13),'<br/>'))}}{{pass}}
</td>
</tr>
<tr><td colspan=2><hr/></td></tr>
{{pass}}
</table>
</div>
</div>
@@ -0,0 +1,5 @@
{{extend 'layout.html'}}
<h1>Upload page</h1>
{{=form}}
{{block sidebar end}}
+147
View File
@@ -0,0 +1,147 @@
<!DOCTYPE html>
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
<!--[if lt IE 7]><html class="ie ie6 ie-lte9 ie-lte8 ie-lte7 no-js" lang="{{=T.accepted_language or 'en'}}"> <![endif]-->
<!--[if IE 7]><html class="ie ie7 ie-lte9 ie-lte8 ie-lte7 no-js" lang="{{=T.accepted_language or 'en'}}"> <![endif]-->
<!--[if IE 8]><html class="ie ie8 ie-lte9 ie-lte8 no-js" lang="{{=T.accepted_language or 'en'}}"> <![endif]-->
<!--[if IE 9]><html class="ie9 ie-lte9 no-js" lang="{{=T.accepted_language or 'en'}}"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html class="no-js" lang="{{=T.accepted_language or 'en'}}"> <!--<![endif]-->
<head>
<meta charset="utf-8" />
<!-- www.phpied.com/conditional-comments-block-downloads/ -->
<!-- Always force latest IE rendering engine
(even in intranet) & Chrome Frame
Remove this if you use the .htaccess -->
<!--[if IE]>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<![endif]-->
<title>{{=response.title or request.application}}</title>
<!-- http://dev.w3.org/html5/markup/meta.name.html -->
<meta name="application-name" content="{{=request.application}}" />
<!-- Speaking of Google, don't forget to set your site up:
http://google.com/webmasters -->
<meta name="google-site-verification" content="" />
<!-- Mobile Viewport Fix
j.mp/mobileviewport & davidbcalhoun.com/2010/viewport-metatag
device-width: Occupy full width of the screen in its current orientation
initial-scale = 1.0 retains dimensions instead of zooming out if page height > device height
user-scalable = yes allows the user to zoom in -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<!-- Place favicon.ico and apple-touch-icon.png in the root of your domain and delete these references -->
<link rel="shortcut icon" href="{{=URL('static','favicon.ico')}}" type="image/x-icon">
<link rel="apple-touch-icon" href="{{=URL('static','favicon.png')}}">
<!-- All JavaScript at the bottom, except for Modernizr which enables
HTML5 elements & feature detects -->
<script src="{{=URL('static','js/modernizr.custom.js')}}"></script>
<!-- include stylesheets -->
{{
response.files.append(URL('static','css/skeleton.css'))
response.files.append(URL('static','css/web2py.css'))
response.files.append(URL('static','css/examples.css'))
response.files.append(URL('static','css/superfish.css'))
response.files.append(URL('static','js/superfish.js'))
}}
{{include 'web2py_ajax.html'}}
<script type="text/javascript">
jQuery(function(){jQuery('.sf-menu').superfish();});
</script>
{{
# using sidebars need to know what sidebar you want to use
left_sidebar_enabled = globals().get('left_sidebar_enabled',False)
right_sidebar_enabled = globals().get('right_sidebar_enabled',False)
middle_columns = {0:'sixteen',1:'ten',2:'eight'}[
(left_sidebar_enabled and 1 or 0)+(right_sidebar_enabled and 1 or 0)]
}}
<!-- uncomment here to load jquery-ui
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/base/jquery-ui.css" type="text/css" media="all" />
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js" type="text/javascript"></script>
uncomment to load jquery-ui //-->
</style>
</head>
<body>
<div class="wrapper"><!-- for sticky footer -->
<div class="flash">{{=response.flash or ''}}</div>
<div class="main">
<div class="container header">
<div class="sixteen columns">
<img src="{{=URL('static','images/web2py_logo.png')}}" />
<h5>{{=response.subtitle or ''}}</h5>
</div>
<div class="sixteen columns statusbar">
{{block statusbar}}
{{is_mobile=request.user_agent().is_mobile}}
<div id="menu">{{=MENU(response.menu,_class='mobile-menu' if is_mobile else 'sf-menu',mobile=is_mobile)}}
{{end}}
<!-- AddToAny BEGIN -->
<div style="float:right;padding-top:6px;" class="a2a_kit a2a_default_style">
<a class="a2a_dd" href="http://www.addtoany.com/share_save">Share</a></div>
<script type="text/javascript" src="http://static.addtoany.com/menu/page.js"></script>
<!-- AddToAny END -->
</div>
<div class="sixteen columns announce">
<a href="http://www.infoworld.com/d/open-source-software/bossie-awards-2011-the-best-open-source-application-development-software-171759-0&current=10&last=1#slideshowTop">2011 BOSSIE AWARD FOR OPEN SOURCE DEVELOPMENT SOFTWARE</a>
</div>
</div>
</div>
<div class="container mainbody">
<div class="sixteen columns">
<div class="{{=middle_columns}} columns center">
{{block center}}
{{include}}
{{end}}
</div>
{{if right_sidebar_enabled:}}
<div class="five columns">
{{block right_sidebar}}
<h3>Right Sidebar</h3>
<p></p>
{{end}}
</div>
{{pass}}
</div>
</div><!-- container -->
{{block extra}}{{end}}
</div><!-- main -->
<div class="push"></div>
</div><!-- wrapper -->
<div class="footer">
<div class="container header">
<div class="sixteen columns">
{{block footer}} <!-- this is default footer -->
<div class="footer-content" >
{{=T('Copyright')}} &#169; 2011
- User communities in <a href="https://groups.google.com/forum/?fromgroups#!forum/web2py" target="_blank">English<a>, <a href="https://groups.google.com/forum/?fromgroups#!forum/web2py-fr" target="_blank">French</a>, <a href="https://groups.google.com/forum/?fromgroups#!forum/web2py-japan" target="_blank">Japanese</a>, <a href="https://groups.google.com/forum/?fromgroups#!forum/web2py-users-brazil" target="_blank">Portuguese</a>, and <a href="https://groups.google.com/forum/?fromgroups#!forum/web2py-usuarios" target="_blank">Spanish</a>.
<div style="float: right;">
<a href="http://www.web2py.com/" style="float: left; padding-right: 6px;">
<img style="padding-bottom: 0;" src="{{=URL('static','images/poweredby.png')}}"/>
</a>
</div>
</div>
{{end}}
</div>
</div><!-- container -->
</div><!-- footer -->
<!--[if lt IE 7 ]>
<script src="{{=URL('static','js/dd_belatedpng.js')}}"></script>
<script> DD_belatedPNG.fix('img, .png_bg'); //fix any <img> or .png_bg background-images </script>
<![endif]-->
{{if response.google_analytics_id:}}<script>/* http://mathiasbynens.be/notes/async-analytics-snippet */ var _gaq=[['_setAccount','{{=response.google_analytics_id}}'],['_trackPageview']];(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.src='//www.google-analytics.com/ga.js';s.parentNode.insertBefore(g,s)}(document,'script')) </script>{{pass}}
</body>
</html>
@@ -0,0 +1,3 @@
{{extend 'layout.html'}}
<h2>{{=message}}</h2>
{{for i in range(1000):}}bla {{pass}}
@@ -0,0 +1,3 @@
{{extend 'layout_examples/layout_civilized.html'}}
<h2>{{=message}}</h2>
<p>{{for i in range(1000):}}bla {{pass}}&nbsp;</p>
@@ -0,0 +1,290 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Design by Free CSS Templates
http://www.freecsstemplates.org
Released for free under a Creative Commons Attribution 2.5 License
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>{{=request.application}}</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<style>
<!--
/* Basic */
*
{
margin: 0em;
padding: 0em;
}
h1,h2
{
}
a
{
color: #995500;
}
body
{
font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
font-size: 11pt;
background: #fff;
color: #665555;
}
/* Outer */
#outer
{
margin: 0em auto 1em auto;
width: 100%;
background-color: #fff;
}
/* Header */
#header
{
padding: 1.5em 2em 1.5em 4em;
background: #2E2017 url('images/a1.jpg') top left repeat-x;
}
#header h1
{
font-size: 2.0em;
}
#header h1, #header h2
{
display: block;
width: 778px;
margin: 0em auto;
}
#header h1 a
{
color: #fff;
text-decoration: none;
}
#header h2
{
color: #bbaa77;
font-size: 0.8em;
}
/* Menu */
#menu
{
padding: 1em 2em 1em 0em;
background: #F1DFC9 url("{{=URL('static', 'civilized/a2.gif')}}") top left repeat-x;
font-size: 0.9em;
}
#menu ul
{
display: block;
width: 778px;
margin: 0em auto;
list-style: none;
padding-left: 2.5em;
}
#menu li
{
display: inline;
}
#menu li a
{
color: #38271C;
font-weight: bold;
text-decoration: none;
padding: 0.25em 0.75em 0.25em 0.75em;
}
#menu li a:hover
{
background: #342117 url("{{=URL('static', 'civilized/a4.gif')}}") top left repeat-x;
color: #fff;
}
/* Content */
#content
{
width: 778px;
margin: 0em auto;
}
#content p
{
margin-bottom: 1.5em;
text-align: justify;
}
#content h2,h3,h4,h5,h6
{
color: #443333;
margin-bottom: 1em;
}
#content ul
{
margin-bottom: 1.5em;
padding-left: 1em;
}
#content blockquote
{
padding-left: 1em;
margin-bottom: 1.5em;
border-left: solid 7px #EFEECC;
}
#content blockquote p
{
margin-bottom: 0em;
}
#content table
{
margin-bottom: 1.5em;
}
#content table th
{
text-align: left;
font-weight: bold;
padding: 0.5em;
color: #443333;
}
#content table td
{
padding: 0.5em;
}
#content table tr.rowA
{
background-color: #F6EECC;
color: inherit;
}
#content table tr.rowB
{
background-color: #FFFEEF;
color: inherit;
}
/* Primary Content */
#primaryContentContainer
{
float: left;
margin-left: -17em;
width: 100%;
}
#primaryContent
{
margin: 0em 0em 0em 16.5em;
padding: 1.5em;
}
#primaryContent h2, #primaryContent h3
{
border-bottom: solid 1px #efeecc;
padding-bottom: 0.25em;
margin-bottom: 1.25em;
}
#primaryContent h2
{
font-size: 1.7em;
}
#primaryContent h3
{
font-size: 1.1em;
}
/* Secondary Content */
#secondaryContent
{
float: right;
width: 14em;
padding: 1.5em 2em 1.5em 2em;
font-size: 0.9em;
}
#secondaryContent h3
{
background: #2E2017 url("{{=URL('static', 'civilized/a4.gif')}}") top left repeat-x;
color: #fff;
padding: 0.5em;
padding: 0.5em 0.5em 0.5em 1.0em;
position: relative;
left: -0.8em;
margin-right: -1.6em;
font-size: 1.0em;
}
/* Footer */
#footer
{
padding: 1.5em 2em 1.5em 2em;
text-align: center;
width: 778px;
margin: 0em auto;
border-top: solid 1px #efeecc;
font-size: 0.9em;
}
.clear
{
clear: both;
}
-->
</style>
</head>
<body>
<div id="outer">
<div id="header">
<h1><a href="#">{{=request.application}}</a></h1>
<h2>{{=request.controller}}/{{=request.function}}</h2>
</div>
{{if response.menu:}}
<div id="menu">
<ul>
{{for name,active,link in response.menu:}}
<li><a href={{=link}}>{{=name}}</a></li>
{{pass}}
</ul>
</div>
{{pass}}
<div id="content">
<div id="primaryContentContainer">
<div id="primaryContent">
{{if response.flash:}}<h2>FLASH: {{=response.flash}}</h2>{{pass}}
{{include}}
</div>
</div>
<div id="secondaryContent">
</div>
<div class="clear"></div>
</div>
<div id="footer">
<p>Copyright © 2006 Sitename.com. Designed by <a href="http://www.freecsstemplates.org">Free CSS Templates</a></p>
</div>
</div>
</body>
</html>
@@ -0,0 +1,252 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Smooth and Sleek by christopher robinson
http://www.edg3.co.uk/
hope you enjoy it and find it usefull :)
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head profile="http://gmpg.org/xfn/11">
<title>{{=request.application}}</title>
<style>
<!--
/*
Author : Christopher Robinson
Email : christopher@edg3.co.uk
Website : http://www.edg3.co.uk/
*/
* {
border:0;
margin:0;
padding:0;
}
/* body */
body {
background:#fff;
color:#666;
font:0.75em/100% 'Lucida Grande', 'Lucida Sans Unicode', Verdana, sans-serif;
line-height:1.4em;
}
/* general */
a {
color:#9C0;
text-decoration:none;
}
a:hover {
color:#555;
text-decoration:none;
}
/* header */
#header {
background:#323232 url('/{{=request.application}}/static/sleek/background_header.jpg') center repeat-y;
width:100%;
}
#header:after {
clear:both;
content:'.';
display:block;
height:0;
visibility:hidden;
}
#header_inside {
border-left:1px solid #bbb;
border-right:1px solid #bbb;
margin:0 auto;
width:800px;
}
#header_inside h1 {
color:#fff;
float:left;
font:3.2em 'Trebuchet MS', Verdana, sans-serif;
height:100px;
line-height:100px;
margin:0 0 0 20px;
width:180px;
}
#header_inside h1 span {
color:#9c0;
}
#header_inside ul {
float:right;
height:100px;
list-style:none;
width:600px;
}
#header_inside ul li {
border-right:1px solid #555;
float:right;
height:100px;
list-style:none;
width:75px;
}
#header_inside ul li a {
color:#fff;
display:block;
height:50px;
line-height:50px;
padding:50px 0 0;
text-align:center;
width:75px;
}
#header_inside ul li a:hover {
background:#fff;
color:#111;
}
#header_inside ul li a.active {
background:#fff;
color:#111;
}
/* content */
#content {
background:#fff url('/{{=request.application}}/static/sleek/background_content.jpg') center repeat-y;
clear:both;
width:100%;
}
#content_inside {
border-left:1px solid #bbb;
border-right:1px solid #bbb;
margin:0 auto;
width:800px;
}
#content_inside_sidebar {
border-left:1px solid #bbb;
clear:both;
float:right;
height:auto;
line-height:175%;
margin:5px 0;
padding:0 10px;
width:200px;
}
#content_inside_sidebar h2 {
background:#fff;
color:#000;
font-size:110%;
font-weight:400;
padding:5px 0;
text-align:right;
}
#content_inside_sidebar ul {
letter-spacing:-1px;
list-style:none;
margin:0 0 10px;
}
#content_inside_sidebar ul li {
list-style:none;
}
#content_inside_sidebar ul li a {
border-bottom:1px solid #e9e9e9;
display:block;
padding:3px;
text-align:right;
width:194px;
}
#content_inside_sidebar ul li a:hover {
background:#ddd;
color:#000;
}
#content_inside_main {
background:#fff;
float:left;
letter-spacing:-1px;
line-height:175%;
margin:0 auto;
padding:10px;
width:559px;
}
#content_inside_main h1 {
border-bottom:1px solid #ccc;
font-size:125%;
padding:0 0 2px;
}
#content_inside_main h2 {
color:#ccc;
font-size:115%;
text-align:right;
}
#content_inside_main h2.flash {
color:red;
font-size:115%;
text-align:right;
}
#content_inside_main p {
padding:0 0 10px;
}
/* footer */
#footer {
background:#323232 url('/{{=request.application}}/static/sleek/background_footer.jpg') center repeat-y;
clear:both;
height:100px;
width:100%;
}
#footer_inside {
border-left:1px solid #bbb;
border-right:1px solid #bbb;
height:100px;
margin:0 auto;
width:800px;
}
#footer_inside p {
color:#fff;
line-height:100px;
text-align:center;
}
-->
</style>
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="content-language" content="en-gb" />
<meta http-equiv="imagetoolbar" content="false" />
<meta http-equiv="pragma" content="no-cache" />
<meta name="author" content="Christopher Robinson" />
<meta name="copyright" content="Copyright (c) Christopher Robinson 2005 - 2007" />
<meta name="description" content=""/>
<meta name="keywords" content="" />
<meta name="last-modified" content="Thursday, 01 February 2007 12:00:00 GMT" />
<meta name="mssmarttagspreventparsing" content="true" />
<meta name="robots" content="index, follow, noarchive" />
<meta name="revisit-after" content="7 days" />
</head>
<body>
<div id="header">
<div id="header_inside">
<h1><span>{{=request.application}}</span> {{=request.controller}} {{request.function}}</h1>
<ul>
{{if response.menu:}}
{{for item,active,link in response.menu:}}
{{if not active:}}<li>{{=A(item,_href=link)}}</li>{{else:}}
<li>{{=A(item,_href=link,_class='active')}}</li>{{pass}}
{{pass}}
{{pass}}
</ul>
</div>
</div>
<div id="content">
<div id="content_inside">
<div id="content_inside_sidebar">
</div>
<div id="content_inside_main">
{{if response.flash:}}<h2 class="flash">FLASH: {{=response.flash}}</h2>{{pass}}
{{include}}
</div>
<div id="footer">
<div id="footer_inside">
</div>
</div>
</div>
</body>
</html>
@@ -0,0 +1,3 @@
{{extend 'layout_examples/layout_sleek.html'}}
<h2>{{=message}}</h2>
{{for i in range(1000):}}bla {{pass}}
@@ -0,0 +1,8 @@
{{extend 'layout.html'}}
<h1>session counter</h1>
<h2>{{for i in range(counter):}}{{=i}}... {{pass}}</h2>
<a href="{{=URL(r=request)}}">{{=T('click me to count')}}</a>
{{block sidebar}} {{end}}
@@ -0,0 +1,2 @@
{{extend 'layout.html'}}
<h1>{{=message}}</h1>
@@ -0,0 +1,7 @@
{{extend 'layout.html'}}
<h1>Excel-like spreadsheet widget</h1>
Try insert "=r0c1+1" in cell r0c0 and "2" in r0c1. Formulas start with "=" as in Excel. You can use a subset of python commands and math function, and reference cells by r[row]c[col]. All computations are performed serverside via Ajax (input is validated for security). Cell values and formulas can be set and locked serverside. The shape of the spreadsheet can be modifed serverside and does not need to be tabular (think of it as a graph of css-friendly widgets you can place where you want). Cells can be given arbistrary names. This example is distributed with web2py so look at the source code of the example to learn more.
{{=sheet}}
@@ -0,0 +1,5 @@
{{extend 'layout.html'}}
<h1>BEAUTIFY</h1>
<h2>Message is</h2>
{{=message}}
@@ -0,0 +1,5 @@
{{extend 'layout.html'}}
<h1>Strings are automatically escaped</h1>
<h2>Message is</h2>
{{=message}}
@@ -0,0 +1,7 @@
{{extend 'layout.html'}}
{{def itemlink(name):}}<li>{{=A(name,_href=name)}}</li>{{return}}
<ul>
{{itemlink('http://www.google.com')}}
{{itemlink('http://www.yahoo.com')}}
{{itemlink('http://www.nyt.com')}}
</ul>
@@ -0,0 +1,6 @@
{{extend 'layout.html'}}
<h1>For loop</h1>
{{for number in ['one','two','three']:}}
<h2>{{=number.capitalize()}}</h2>
{{pass}}
@@ -0,0 +1,12 @@
{{extend 'layout.html'}}
<h1>If statement</h1>
{{
a=10
}}
{{if a%2==0:}}
<h2>{{=a}} is even</h2>
{{else:}}
<h2>{{=a}} is odd</h2>
{{pass}}
@@ -0,0 +1,8 @@
{{extend 'layout.html'}}
<h1>Try... except</h1>
{{try:}}
<h2>a={{=1/0}}</h2>
{{except:}}
infinity</h2>
{{pass}}
@@ -0,0 +1,4 @@
{{extend 'layout.html'}}
<h1>Your variables</h1>
<h2>a={{=a}}</h2>
<h2>a={{=b}}</h2>
@@ -0,0 +1,5 @@
{{extend 'layout.html'}}
<h1>XML</h1>
<h2>Message is</h2>
{{=message}}
@@ -0,0 +1,14 @@
<script type="text/javascript"><!--
// These variables are used by the web2py_ajax_init function in web2py_ajax.js (which is loaded below).
var w2p_ajax_confirm_message = "{{=T('Are you sure you want to delete this object?')}}";
var w2p_ajax_date_format = "{{=T('%Y-%m-%d')}}";
var w2p_ajax_datetime_format = "{{=T('%Y-%m-%d %H:%M:%S')}}";
//--></script>
{{
response.files.insert(0,URL('static','js/jquery.js'))
response.files.insert(1,URL('static','css/anytime.css'))
response.files.insert(2,URL('static','js/anytime.js'))
response.files.insert(3,URL('static','js/web2py.js'))
response.include_meta()
response.include_files()
}}