Permalink
Browse files

explains better how to switch adapters at runtime, thanks Niphlod

  • Loading branch information...
1 parent 317fda3 commit d5b786168d913e831aedb847c3eae42b87d49f1d @mdipierro mdipierro committed Mar 17, 2013
Showing with 10 additions and 8 deletions.
  1. +4 −3 controllers/default.py
  2. +5 −4 sources/29-web2py-english/06.markmin
  3. +1 −1 views/default/chapter.html
@@ -100,9 +100,10 @@ def chapter():
chapters = cache.ram('chapters_%s' % subfolder, lambda: get_chapters(subfolder), time_expire=TIME_EXPIRE)
filename = os.path.join(FOLDER,subfolder,'%.2i.markmin' % chapter_id)
dest = os.path.join(request.folder, 'static_chaps', subfolder, '%.2i.html' % chapter_id)
- response.headers['Cache-Control'] = 'public, must-revalidate'
- response.headers['Expires'] = calc_date()
- response.headers['Pragma'] = None
+ if not FORCE_RENDER:
+ response.headers['Cache-Control'] = 'public, must-revalidate'
+ response.headers['Expires'] = calc_date()
+ response.headers['Pragma'] = None
if (not os.path.isfile(dest)) or FORCE_RENDER:
content = open(filename).read()
content = convert2html(book_id,content).xml()
@@ -473,7 +473,7 @@ The first argument of ``define_table`` is always the table name. The other unnam
>>> db.define_table('person', Field('name'), migrate='person.table')
``:code
-The value of migrate is the filename (in the "databases" folder for the application) where web2py stores internal migration information for this table.
+The value of migrate is the filename (in the "databases" folder for the application) where web2py stores internal migration information for this table.
These files are very important and should never be removed while the corresponding tables exist. In cases where a table has been dropped and the corresponding file still exist, it can be removed manually. By default, migrate is set to True. This causes web2py to generate the filename from a hash of the connection string. If migrate is set to False, the migration is not performed, and web2py assumes that the table exists in the datastore and it contains (at least) the fields listed in ``define_table``.
The best practice is to give an explicit name to the migrate table.
@@ -637,7 +637,7 @@ The DAL allows you to explicitly issue SQL statements.
``:code
In this case, the return values are not parsed or transformed by the DAL, and the format depends on the specific database driver. This usage with selects is normally not needed, but it is more common with indexes.
-``executesql`` takes four optional arguments: ``placeholders``, ``as_dict``, ``fields`` and ``colnames``.
+``executesql`` takes four optional arguments: ``placeholders``, ``as_dict``, ``fields`` and ``colnames``.
``placeholders`` is an optional
sequence of values to be substituted in
or, if supported by the DB driver, a dictionary with keys
@@ -3278,11 +3278,12 @@ the uri string is then parsed in more detail by the adapter itself.
For any adapter you can replace the driver with a different one:
``
+import MySQLdb as mysqldb
from gluon.dal import MySQLAdapter
MySQLAdapter.driver = mysqldb
``
-
-and you can specify optional driver arguments and adapter arguments:
+i.e. ``mysqldb`` has to be ''that module'' with a .connect() method.
+You can specify optional driver arguments and adapter arguments:
``
db =DAL(..., driver_args={}, adapter_args={})
@@ -5,7 +5,7 @@
response.files.append(URL('static','js/jquery.toc-0.1.js'))
response.files.append(URL('static','js/jquery.qtip-1.0.0-rc3.min.js'))
response.title = info['title']
-response.subtitle = SPAN(info['subtitle']," written by "+(info['authors'] and info['authors'] or 'unkown')+" in " + info['language'])
+response.subtitle = SPAN(info['subtitle']," written by "+(info['authors'] and info['authors'] or 'unknown')+" in " + info['language'])
}}
{{extend 'layout.html'}}
<style>

0 comments on commit d5b7861

Please sign in to comment.