mdipierro
unread,Nov 1, 2009, 1:02:12 AM11/1/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to web2py-users
If you want to use the template system or the DAL from any python
program (now web2py):
1) make sure web2py/ is in path
2) HOW TO DAL:
from gluon.sql import DAL, Field
db=DAL('sqlite://storage',folder='/path/to/a/file/where/to/store/
db')
db.define_table(...)
... etc etc
3) HOW TO templates:
from gluon.template import render
page = render(content="{{for i in range(n):}}Hello
{{pass}}",context=dict(n=5))
print page
instead of content you can pass a stream
page = render(stream=open('myview.html','rb'),context=dict(n=5))
or a filename
page = render(filename='myview.html',context=dict(n=5))
If the template contains a {{import...}} or {{extend...}} you should
also pass a path
page = render(...., path='./')
telling web2py where to look for included and extended files.
If you try any of these please let us know.
Massimo