Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
spametki committed Mar 17, 2013
2 parents f6071a8 + d5b7861 commit 2214e9e
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 53 deletions.
27 changes: 18 additions & 9 deletions controllers/default.py
Expand Up @@ -2,6 +2,14 @@
import os, datetime
session.forget()

TIME_EXPIRE = 60*60*24
FORCE_RENDER = False

# this is for checking new content instantly in development
if request.is_local:
TIME_EXPIRE = -1
FORCE_RENDER = True

response.title = 'web2py'
response.subtitle = 'Full Stack Web Framework, 4th Ed.\nwritten by Massimo Di Pierro in English'
response.menu = []
Expand Down Expand Up @@ -74,7 +82,7 @@ def truncate(x): return x[:70]+'...' if len(x)>70 else x
def index():
books = {}
for subfolder in FOLDERS:
books[subfolder] = cache.ram('info_%s' % subfolder, lambda: get_info(subfolder), time_expire=60*60*24)
books[subfolder] = cache.ram('info_%s' % subfolder, lambda: get_info(subfolder), time_expire=TIME_EXPIRE)
return locals()

def calc_date(now=request.utcnow.date()):
Expand All @@ -88,14 +96,15 @@ def calc_date(now=request.utcnow.date()):
def chapter():
book_id, chapter_id = request.args(0), request.args(1,cast=int,default='0')
subfolder = get_subfolder(book_id)
info = cache.ram('info_%s' % subfolder, lambda: get_info(subfolder), time_expire=60*60*24)
chapters = cache.ram('chapters_%s' % subfolder, lambda: get_chapters(subfolder), time_expire=60*60*24)
info = cache.ram('info_%s' % subfolder, lambda: get_info(subfolder), time_expire=TIME_EXPIRE)
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 os.path.isfile(dest):
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()
if not os.path.exists(os.path.dirname(dest)):
Expand All @@ -111,8 +120,8 @@ def search():
book_id = request.args(0) or redirect(URL('index'))
search = request.vars.search or redirect(URL('chapter',args=book_id))
subfolder = get_subfolder(book_id)
info = cache.ram('info_%s' % subfolder, lambda: get_info(subfolder), time_expire=60*60*24)
chapters = cache.ram('chapters_%s' % subfolder, lambda: get_chapters(subfolder), time_expire=60*60*24)
info = cache.ram('info_%s' % subfolder, lambda: get_info(subfolder), time_expire=TIME_EXPIRE)
chapters = cache.ram('chapters_%s' % subfolder, lambda: get_chapters(subfolder), time_expire=TIME_EXPIRE)
results = []
content = H2('No results for "%s"' % search)
for chapter in chapters:
Expand Down
32 changes: 16 additions & 16 deletions languages/pt-br.py
Expand Up @@ -8,12 +8,12 @@
'%s %%{row} deleted': '%s linhas apagadas',
'%s %%{row} updated': '%s linhas atualizadas',
'%s selected': '%s selecionado',
'About': 'About',
'About': 'Sobre',
'Access Control': 'Access Control',
'Administrative interface': 'Interface administrativa',
'Ajax Recipes': 'Ajax Recipes',
'Available Databases and Tables': 'Bancos de dados e tabelas disponíveis',
'Buy this book': 'Buy this book',
'Buy this book': 'Compre este livro',
'Cannot be empty': 'Não pode ser vazio',
'Check to delete': 'Marque para apagar',
'Client IP': 'Client IP',
Expand All @@ -27,48 +27,48 @@
'Database': 'Banco de dados',
'Delete:': 'Apagar:',
'Demo': 'Demo',
'Deployment Recipes': 'Deployment Recipes',
'Description': 'Description',
'Documentation': 'Documentation',
'Deployment Recipes': 'Ambiente de produção',
'Description': 'Descrição',
'Documentation': 'Documentação',
'Download': 'Download',
'E-mail': 'E-mail',
'Edit': 'Editar',
'Edit This App': 'Edit This App',
'Edit This App': 'Edite este app',
'Edit current record': 'Editar o registro atual',
'Errors': 'Errors',
'FAQ': 'FAQ',
'First name': 'First name',
'Forms and Validators': 'Forms and Validators',
'Free Applications': 'Free Applications',
'First name': 'Primeiro nome',
'Forms and Validators': 'Formulários e Validadores',
'Free Applications': 'Applicações Livres',
'Group ID': 'Group ID',
'Groups': 'Groups',
'Hello World': 'Olá Mundo',
'Home': 'Home',
'Import/Export': 'Importar/Exportar',
'Index': 'Início',
'Internal State': 'Estado Interno',
'Introduction': 'Introduction',
'Introduction': 'Introdução',
'Invalid Query': 'Consulta Inválida',
'Invalid email': 'Invalid email',
'Last name': 'Last name',
'Invalid email': 'E-mail inválido',
'Last name': 'Sobrenome',
'Layout': 'Layout',
'Layouts': 'Layouts',
'Live chat': 'Live chat',
'Login': 'Autentique-se',
'Lost Password': 'Esqueceu sua senha?',
'Main Menu': 'Menu Principal',
'Menu Model': 'Modelo de Menu',
'Name': 'Name',
'Name': 'Nome',
'New Record': 'Novo Registro',
'No databases in this application': 'Sem bancos de dados nesta aplicação',
'Online examples': 'Alguns exemplos',
'Origin': 'Origin',
'Other Recipes': 'Other Recipes',
'Other Recipes': 'Outros ambientes',
'Overview': 'Overview',
'Password': 'Password',
'Password': 'Senha',
'Plugins': 'Plugins',
'Powered by': 'Powered by',
'Preface': 'Preface',
'Preface': 'Prefácio',
'Python': 'Python',
'Query:': 'Consulta:',
'Quick Examples': 'Quick Examples',
Expand Down
6 changes: 3 additions & 3 deletions sources/29-web2py-english/03.markmin
Expand Up @@ -1247,7 +1247,7 @@ Here we assume we are starting from scratch from a simple clone of the "welcome"
def index(): return auth.wiki()
``:code

Done! You have a fully working wiki. At this point no page has been created and in order to create pages you must be logged-in and you must be member of a group called "wiki-editor" or "wiki-author". If you are logged-in as administrator the "wiki-editor" group is created automatically and you are made a member. The difference between editors and authors is that the editors can create pages, edit and delete any page, while the authors can create pages (with some optional restrictions) and can only edit/delete the pages they have created.
Done! You have a fully working wiki. At this point no page has been created and in order to create pages you must be logged-in and you must be member of a group called "wiki_editor" or "wiki_author". If you are logged-in as administrator the "wiki_editor" group is created automatically and you are made a member. The difference between editors and authors is that the editors can create pages, edit and delete any page, while the authors can create pages (with some optional restrictions) and can only edit/delete the pages they have created.

The ``auth.wiki()`` function returns in a dictionary with a key ``content`` which is understood by the scaffolding "views/default/index.html". You can make your own view for this action:

Expand Down Expand Up @@ -1298,11 +1298,11 @@ def wiki(self, slug=None, env=None, render='markmin',
It takes the following arguments:

- ``render`` which defaults to ``'markmin'`` but can be set equal to ``'html'``. It determines the syntax of the wiki. We will discuss the markmin wiki markup later. If you change it to HTML you can use a wysiwyg javascript editor such as TinyMCE or NicEdit.
- ``manage_permissions``. This is set to ``False`` by default and only recognizes permissions for "wiki-editor" and "wiki-author". If you change it to ``True`` the create/edit page will give the option to specify by name the group(s) whose members have permission to read and edit the page. There is a group "everybody" which includes all users.
- ``manage_permissions``. This is set to ``False`` by default and only recognizes permissions for "wiki_editor" and "wiki_author". If you change it to ``True`` the create/edit page will give the option to specify by name the group(s) whose members have permission to read and edit the page. There is a group "everybody" which includes all users.

- ``force_prefix``. If set to something like ``'%(id)s-'`` it will restrict authors (not editors) to creating pages with a prefix like "[user id]-[page name]". The prefix can contain the id ("%(id)s") or the username ("%(username)s") or any other field from the auth_user table, as long as the corresponding column contains a valid string that would pass URL validation.
- ``restrict_search``. This defaults to ``False`` and any logged-in user can search all wiki pages (but not necessary read or edit them). If set to ``True``, authors can search only their own pages, editors can search everything, other users cannot search anything.
- ``menu_groups``. This defaults to ``None`` and it indicates that wiki management menu (search, create, edit, etc.) is always displayed. You can set it to a list of group names whose members only can see this menu, for example ``['wiki-editor','wiki-author']``. Notice that even if the menu is exposed to everybody that does not mean everybody is allowed to perform actions listed in the menu since they are regulated by the access control system.
- ``menu_groups``. This defaults to ``None`` and it indicates that wiki management menu (search, create, edit, etc.) is always displayed. You can set it to a list of group names whose members only can see this menu, for example ``['wiki_editor','wiki_author']``. Notice that even if the menu is exposed to everybody that does not mean everybody is allowed to perform actions listed in the menu since they are regulated by the access control system.

The ``wiki`` method has some additional parameters which will be explained later: ``slug``, ``env``, and ``extra``.

Expand Down
9 changes: 5 additions & 4 deletions sources/29-web2py-english/06.markmin
Expand Up @@ -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.

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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={})
Expand Down
6 changes: 3 additions & 3 deletions sources/29-web2py-english/13.markmin
Expand Up @@ -58,10 +58,10 @@ While we recommend following the first three recipes, the fourth recipe may prov

### ``anyserver.py``

``anyserver``:inxx ``bjoern``:inxx ``cgi``:inxx ``cherrypy``:inxx ``diesel``:inxx ``eventlet``:inxx ``fapws``:inxx ``flup``:inxx ``gevent``:inxx ``gnuicorn``:inxx ``mongrel2``:inxx ``paste``:inxx ``tornado``:inxx ``twisted``:inxx ``wsgiref``:inxx
``anyserver``:inxx ``bjoern``:inxx ``cgi``:inxx ``cherrypy``:inxx ``diesel``:inxx ``eventlet``:inxx ``fapws``:inxx ``flup``:inxx ``gevent``:inxx ``gunicorn``:inxx ``mongrel2``:inxx ``paste``:inxx ``tornado``:inxx ``twisted``:inxx ``wsgiref``:inxx

Web2py comes with a file called ``anyserver.py`` that implements WSGI interfaces to the following popular servers: bjoern, cgi, cherrypy, diesel, eventlet,
fapws, flup, gevent, gnuicorn, mongrel2, paste,
fapws, flup, gevent, gunicorn, mongrel2, paste,
rocket, tornado, twisted, wsgiref

You can use any of these servers, for example Tornado, simply by doing:
Expand Down Expand Up @@ -1579,7 +1579,7 @@ And creates a "Procfile" which tells Heroku how to start web2py:
echo "web: python web2py.py -a 'yourpassword' -i 0.0.0.0 -p \$PORT" > Procfile
``:code

You can change this line to use a different server. You must edit it to select your own admin password. ``\$PORT`` is a variable which is correctly escaped since its value is set at runtime. You should also consider starting web2py with gnuicorn using ``anyserver.py`` since this is one of the recommended web servers for Python.
You can change this line to use a different server. You must edit it to select your own admin password. ``\$PORT`` is a variable which is correctly escaped since its value is set at runtime. You should also consider starting web2py with gunicorn using ``anyserver.py`` since this is one of the recommended web servers for Python.

Finally the script creates a Git repository:

Expand Down
4 changes: 2 additions & 2 deletions sources/32-web2py-german/13.markmin
Expand Up @@ -57,10 +57,10 @@ While we recommend following the first three recipes, the fourth recipe may prov

#### ``anyserver.py``

``anyserver``:inxx ``bjoern``:inxx ``cgi``:inxx ``cherrypy``:inxx ``diesel``:inxx ``eventlet``:inxx ``fapws``:inxx ``flup``:inxx ``gevent``:inxx ``gnuicorn``:inxx ``mongrel2``:inxx ``paste``:inxx `` ``tornado``:inxx ``twisted``:inxx ``wsgiref
``anyserver``:inxx ``bjoern``:inxx ``cgi``:inxx ``cherrypy``:inxx ``diesel``:inxx ``eventlet``:inxx ``fapws``:inxx ``flup``:inxx ``gevent``:inxx ``gunicorn``:inxx ``mongrel2``:inxx ``paste``:inxx `` ``tornado``:inxx ``twisted``:inxx ``wsgiref

Web2py comes with a file called ``anyserver.py`` that implements WSGI interfaces to the following popular servers: bjoern, cgi, cherrypy, diesel, eventlet,
fapws, flup, gevent, gnuicorn, mongrel2, paste,
fapws, flup, gevent, gunicorn, mongrel2, paste,
rocket, tornado, twisted, wsgiref

You can use any of these servers, for example Tornado, simply by doing:
Expand Down
4 changes: 2 additions & 2 deletions sources/33-web2py-japanese/13.markmin
Expand Up @@ -55,10 +55,10 @@ GAE以外のプラットフォームでは拡張性は懸念事項であり、we

#### ``anyserver.py``

``anyserver``:inxx ``bjoern``:inxx ``cgi``:inxx ``cherrypy``:inxx ``diesel``:inxx ``eventlet``:inxx ``fapws``:inxx ``flup``:inxx ``gevent``:inxx ``gnuicorn``:inxx ``mongrel2``:inxx ``paste``:inxx `` ``tornado``:inxx ``twisted``:inxx ``wsgiref
``anyserver``:inxx ``bjoern``:inxx ``cgi``:inxx ``cherrypy``:inxx ``diesel``:inxx ``eventlet``:inxx ``fapws``:inxx ``flup``:inxx ``gevent``:inxx ``gunicorn``:inxx ``mongrel2``:inxx ``paste``:inxx `` ``tornado``:inxx ``twisted``:inxx ``wsgiref

web2pyには、次のポピュラーなサーバーへのWSGIインターフェイスを実装した、``anyserver.py``ファイルがあります: bjoern, cgi, cherrypy, diesel, eventlet,
fapws, flup, gevent, gnuicorn, mongrel2, paste,
fapws, flup, gevent, gunicorn, mongrel2, paste,
rocket, tornado, twisted, wsgiref

これらのサーバーのいずれかを使えます。例えばTornadoの場合、次のようになります:
Expand Down
4 changes: 2 additions & 2 deletions sources/34-web2py-italian-translation-in-progress/13.markmin
Expand Up @@ -56,10 +56,10 @@ While we recommend following the first three recipes, the fourth recipe may prov

#### ``anyserver.py``

``anyserver``:inxx ``bjoern``:inxx ``cgi``:inxx ``cherrypy``:inxx ``diesel``:inxx ``eventlet``:inxx ``fapws``:inxx ``flup``:inxx ``gevent``:inxx ``gnuicorn``:inxx ``mongrel2``:inxx ``paste``:inxx `` ``tornado``:inxx ``twisted``:inxx ``wsgiref
``anyserver``:inxx ``bjoern``:inxx ``cgi``:inxx ``cherrypy``:inxx ``diesel``:inxx ``eventlet``:inxx ``fapws``:inxx ``flup``:inxx ``gevent``:inxx ``gunicorn``:inxx ``mongrel2``:inxx ``paste``:inxx `` ``tornado``:inxx ``twisted``:inxx ``wsgiref

Web2py comes with a file called ``anyserver.py`` that implements WSGI interfaces to the following popular servers: bjoern, cgi, cherrypy, diesel, eventlet,
fapws, flup, gevent, gnuicorn, mongrel2, paste,
fapws, flup, gevent, gunicorn, mongrel2, paste,
rocket, tornado, twisted, wsgiref

You can use any of these servers, for example Tornado, simply by doing:
Expand Down
4 changes: 2 additions & 2 deletions sources/35-web2py-chinese-work-in-progress/13.markmin
Expand Up @@ -56,10 +56,10 @@ While we recommend following the first three recipes, the fourth recipe may prov

#### ``anyserver.py``

``anyserver``:inxx ``bjoern``:inxx ``cgi``:inxx ``cherrypy``:inxx ``diesel``:inxx ``eventlet``:inxx ``fapws``:inxx ``flup``:inxx ``gevent``:inxx ``gnuicorn``:inxx ``mongrel2``:inxx ``paste``:inxx `` ``tornado``:inxx ``twisted``:inxx ``wsgiref
``anyserver``:inxx ``bjoern``:inxx ``cgi``:inxx ``cherrypy``:inxx ``diesel``:inxx ``eventlet``:inxx ``fapws``:inxx ``flup``:inxx ``gevent``:inxx ``gunicorn``:inxx ``mongrel2``:inxx ``paste``:inxx `` ``tornado``:inxx ``twisted``:inxx ``wsgiref

Web2py comes with a file called ``anyserver.py`` that implements WSGI interfaces to the following popular servers: bjoern, cgi, cherrypy, diesel, eventlet,
fapws, flup, gevent, gnuicorn, mongrel2, paste,
fapws, flup, gevent, gunicorn, mongrel2, paste,
rocket, tornado, twisted, wsgiref

You can use any of these servers, for example Tornado, simply by doing:
Expand Down
4 changes: 2 additions & 2 deletions sources/36-web2py-spanish-translation-in-progress/13.markmin
Expand Up @@ -56,10 +56,10 @@ While we recommend following the first three recipes, the fourth recipe may prov

#### ``anyserver.py``

``anyserver``:inxx ``bjoern``:inxx ``cgi``:inxx ``cherrypy``:inxx ``diesel``:inxx ``eventlet``:inxx ``fapws``:inxx ``flup``:inxx ``gevent``:inxx ``gnuicorn``:inxx ``mongrel2``:inxx ``paste``:inxx `` ``tornado``:inxx ``twisted``:inxx ``wsgiref
``anyserver``:inxx ``bjoern``:inxx ``cgi``:inxx ``cherrypy``:inxx ``diesel``:inxx ``eventlet``:inxx ``fapws``:inxx ``flup``:inxx ``gevent``:inxx ``gunicorn``:inxx ``mongrel2``:inxx ``paste``:inxx `` ``tornado``:inxx ``twisted``:inxx ``wsgiref

Web2py comes with a file called ``anyserver.py`` that implements WSGI interfaces to the following popular servers: bjoern, cgi, cherrypy, diesel, eventlet,
fapws, flup, gevent, gnuicorn, mongrel2, paste,
fapws, flup, gevent, gunicorn, mongrel2, paste,
rocket, tornado, twisted, wsgiref

You can use any of these servers, for example Tornado, simply by doing:
Expand Down

0 comments on commit 2214e9e

Please sign in to comment.