Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d566e4f444 | ||
|
|
2174677f6f | ||
|
|
fb544a832c | ||
|
|
d9121967e7 | ||
|
|
f2247bc5b6 | ||
|
|
ee0cffc944 | ||
|
|
a45e08c43b | ||
|
|
9c931025cc | ||
|
|
07a97d62b8 | ||
|
|
65fec492f0 | ||
|
|
da7d3c6dbd | ||
|
|
73c66c142d | ||
|
|
29c513e5a3 | ||
|
|
72bb9d3513 | ||
|
|
90c0e0ff7e | ||
|
|
7b24ce3f41 | ||
|
|
d61748466e | ||
|
|
c17c28e42b | ||
|
|
524a65d0a9 | ||
|
|
51d8932252 | ||
|
|
7b655465bb | ||
|
|
71c44e62b8 | ||
|
|
2295b93f32 | ||
|
|
04d0b82268 | ||
|
|
dffb2eada2 | ||
|
|
c109fa727c | ||
|
|
91c9c6fb28 | ||
|
|
e4f8896b7f | ||
|
|
a558af3b09 | ||
|
|
918d3bd6df | ||
|
|
e4b6fba5ca | ||
|
|
41caa71ab0 | ||
|
|
f8786e5b6d | ||
|
|
78b5f4f8aa | ||
|
|
a0e4154f26 | ||
|
|
3f7749cf20 | ||
|
|
dba7247b44 | ||
|
|
43ac53f6a1 | ||
|
|
e82982d25d | ||
|
|
665a5cdee2 | ||
|
|
b81e4b60e5 | ||
|
|
a017996aba | ||
|
|
92ad68aad7 | ||
|
|
77618dd18b | ||
|
|
f0d075bbd6 | ||
|
|
156c2c294e | ||
|
|
c6037b0355 | ||
|
|
5edde2638e | ||
|
|
ba70a77932 | ||
|
|
1554a831ac | ||
|
|
efbabbafa3 | ||
|
|
017fd0dd14 | ||
|
|
79e7d974ad | ||
|
|
1cf2f84d24 | ||
|
|
c844759c63 | ||
|
|
b3be11953d | ||
|
|
4ee59cfaaf | ||
|
|
21cf4f9024 | ||
|
|
53889ece3d | ||
|
|
910f4c0f13 | ||
|
|
10555af3e6 | ||
|
|
ec92b8fff1 | ||
|
|
25f349a3a9 | ||
|
|
9f763c677c | ||
|
|
1444c5b476 | ||
|
|
3c0ed7b8b9 | ||
|
|
528cf0ed0f | ||
|
|
a8580673b6 | ||
|
|
04fe5199f1 |
No files matched your search
@@ -23,6 +23,7 @@
|
||||
- Support for Google App Engine projections, thanks Christian
|
||||
- Field(... 'upload', default=path) now accepts a path to a local file as default value, if user does not upload a file. Relative path looks inside current application folder, thanks Marin
|
||||
- executesql(...,fields=,columns=) allows parsing of results in Rows, thanks Anthony
|
||||
- Rows.find(lambda row: bool(), limitby=(0,1))
|
||||
|
||||
### Auth improvements
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ update:
|
||||
wget -O gluon/contrib/simplejsonrpc.py http://rad2py.googlecode.com/hg/ide2py/simplejsonrpc.py
|
||||
echo "remember that pymysql was tweaked"
|
||||
src:
|
||||
echo 'Version 2.0.2 ('`date +%Y-%m-%d\ %H:%M:%S`') stable' > VERSION
|
||||
echo 'Version 2.0.7 ('`date +%Y-%m-%d\ %H:%M:%S`') stable' > VERSION
|
||||
### rm -f all junk files
|
||||
make clean
|
||||
### clean up baisc apps
|
||||
@@ -127,5 +127,5 @@ push:
|
||||
tag:
|
||||
git tag -l '$(S)'
|
||||
hg tag -l '$(S)'
|
||||
make commit
|
||||
make commit S='$(S)'
|
||||
make push
|
||||
@@ -1 +1 @@
|
||||
Version 2.0.2 (2012-08-29 22:00:56) stable
|
||||
Version 2.0.7 (2012-09-04 17:58:46) stable
|
||||
@@ -140,8 +140,8 @@ def check_version():
|
||||
return SPAN('You should upgrade to version %s' % version_number)
|
||||
else:
|
||||
return sp_button(URL('upgrade_web2py'), T('upgrade now')) \
|
||||
+ XML(' <strong class="upgrade_version">%s</strong>' % version_number)
|
||||
|
||||
+ XML(' <strong class="upgrade_version">%s.%s.%s</strong>' \
|
||||
% version_number[:3])
|
||||
|
||||
def logout():
|
||||
""" Logout handler """
|
||||
@@ -249,6 +249,10 @@ def site():
|
||||
fname = request.vars.file.filename
|
||||
f = request.vars.file.file
|
||||
|
||||
else:
|
||||
session.flash = 'No file uploaded and no URL specified'
|
||||
redirect(URL(r=request))
|
||||
|
||||
if f:
|
||||
appname = cleanpath(form_update.vars.name)
|
||||
installed = app_install(appname, f,
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
'are not used yet': 'are not used yet',
|
||||
'Are you sure you want to delete this object?': 'Are you sure you want to delete this object?',
|
||||
'arguments': 'arguments',
|
||||
'at char %s': 'at char %s',
|
||||
'at line %s': 'at line %s',
|
||||
'back': '<<back',
|
||||
'can be a git repo': 'can be a git repo',
|
||||
'Change admin password': 'Change admin password',
|
||||
@@ -33,6 +35,7 @@
|
||||
'created by': 'created by',
|
||||
'crontab': 'crontab',
|
||||
'currently running': 'currently running',
|
||||
'currently saved or': 'currently saved or',
|
||||
'database administration': 'database administration',
|
||||
'Debug': 'Debug',
|
||||
'defines tables': 'defines tables',
|
||||
@@ -43,16 +46,23 @@
|
||||
'Detailed traceback description': 'Detailed traceback description',
|
||||
'direction: ltr': 'direction: ltr',
|
||||
'Disable': 'Disable',
|
||||
'docs': 'docs',
|
||||
'download layouts': 'download layouts',
|
||||
'download plugins': 'download plugins',
|
||||
'Edit': 'Edit',
|
||||
'Edit application': 'Edit application',
|
||||
'edit views:': 'edit views:',
|
||||
'Editing file "%s"': 'Editing file "%s"',
|
||||
'Error snapshot': 'Error snapshot',
|
||||
'Error ticket': 'Error ticket',
|
||||
'Errors': 'Errors',
|
||||
'Exception instance attributes': 'Exception instance attributes',
|
||||
'exposes': 'exposes',
|
||||
'exposes:': 'exposes:',
|
||||
'extends': 'extends',
|
||||
'failed to compile file because:': 'failed to compile file because:',
|
||||
'file does not exist': 'file does not exist',
|
||||
'file saved on %s': 'file saved on %s',
|
||||
'filter': 'filter',
|
||||
'Frames': 'Frames',
|
||||
'Get from URL:': 'Get from URL:',
|
||||
@@ -63,8 +73,12 @@
|
||||
'inspect attributes': 'inspect attributes',
|
||||
'Install': 'Install',
|
||||
'Installed applications': 'Installed applications',
|
||||
'invalid password.': 'invalid password.',
|
||||
'Key bindings': 'Key bindings',
|
||||
'Language files (static strings) updated': 'Language files (static strings) updated',
|
||||
'languages': 'languages',
|
||||
'Languages': 'Languages',
|
||||
'Last saved on:': 'Last saved on:',
|
||||
'loading...': 'loading...',
|
||||
'locals': 'locals',
|
||||
'Login': 'Login',
|
||||
@@ -72,10 +86,11 @@
|
||||
'Logout': 'Logout',
|
||||
'Models': 'Models',
|
||||
'models': 'models',
|
||||
'modules': 'modules',
|
||||
'Modules': 'Modules',
|
||||
'modules': 'modules',
|
||||
'New application wizard': 'New application wizard',
|
||||
'New simple application': 'New simple application',
|
||||
'online designer': 'online designer',
|
||||
'Overwrite installed app': 'Overwrite installed app',
|
||||
'Pack all': 'Pack all',
|
||||
'Peeking at file': 'Peeking at file',
|
||||
@@ -88,11 +103,17 @@
|
||||
'Reload routes': 'Reload routes',
|
||||
'request': 'request',
|
||||
'response': 'response',
|
||||
'restore': 'restore',
|
||||
'revert': 'revert',
|
||||
'rules are not defined': 'rules are not defined',
|
||||
'rules:': 'rules:',
|
||||
"Run tests in this file (to run all files, you may also use the button labelled 'test')": "Run tests in this file (to run all files, you may also use the button labelled 'test')",
|
||||
'Running on %s': 'Running on %s',
|
||||
'Save': 'Save',
|
||||
'Save via Ajax': 'Save via Ajax',
|
||||
'Saved file hash:': 'Saved file hash:',
|
||||
'session': 'session',
|
||||
'session expired': 'session expired',
|
||||
'shell': 'shell',
|
||||
'Site': 'Site',
|
||||
'Start wizard': 'Start wizard',
|
||||
@@ -109,7 +130,9 @@
|
||||
'These files are served without processing, your images go here': 'These files are served without processing, your images go here',
|
||||
'Ticket ID': 'Ticket ID',
|
||||
'Ticket Missing': 'Ticket Missing',
|
||||
'to previous version.': 'to previous version.',
|
||||
'To create a plugin, name a file/folder plugin_[name]': 'To create a plugin, name a file/folder plugin_[name]',
|
||||
'toggle breakpoint': 'toggle breakpoint',
|
||||
'Traceback': 'Traceback',
|
||||
'Translation strings for the application': 'Translation strings for the application',
|
||||
'Uninstall': 'Uninstall',
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
<h2>web2py™ {{=T('Web Framework')}}</h2>
|
||||
<h3>{{=T('Login to the Administrative Interface')}}</h3>
|
||||
<div>
|
||||
|
||||
{{if request.is_https or request.is_local:}}
|
||||
<div class="form">
|
||||
<form action="{{=URL(r=request)}}" method="post">
|
||||
<div><input type="hidden" name="send" value="{{=send}}"/></div>
|
||||
<table>
|
||||
@@ -11,4 +13,6 @@
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{{else:}}
|
||||
<p class="help">{{=T('ATTENTION: Login requires a secure (HTTPS) connection or running on localhost.')}}</p>
|
||||
{{pass}}
|
||||
@@ -223,16 +223,12 @@ for c in controllers: controller_functions+=[c[:-3]+'/%s.html'%x for x in functi
|
||||
{{=editpluralsfile('languages',pfile,dict(nplurals=p[0]))}}
|
||||
</span>
|
||||
<span class="file">
|
||||
{{=peekfile('languages',pfile,dict(id=id))}},
|
||||
{{=peekfile('languages',pfile,dict(id=id))}}
|
||||
</span>
|
||||
{{else:}}
|
||||
<b>{{=T("are not used yet")}}</b>,
|
||||
<b>{{=T("are not used yet")}}</b>
|
||||
{{pass}}
|
||||
{{pass}}
|
||||
{{=T("rules:")}}
|
||||
<span class="file{{=' error' if p[3]!='ok' else ''}}">
|
||||
{{=peekfile('gluon/contrib/rules', p[2], dict(app=app, id=id), p[3] if p[3]!='ok' else None)}}
|
||||
</span>
|
||||
{{pass}}
|
||||
)
|
||||
</td>
|
||||
|
||||
File renamed without changes.
@@ -1,41 +1,92 @@
|
||||
<html><body><h1>Markmin markup language</h1><h2>About</h2><p>This is a new markup language that we call markmin designed to produce high quality scientific papers and books and also put them online. We provide serializers for html, latex and pdf. It is implemented in the <code class="">markmin2html</code> function in the <code class="">markmin2html.py</code>.</p><p>Example of usage:</p><pre><code class="">>>> m = "Hello **world** [[link http://web2py.com]]"
|
||||
>>> from markmin2html import markmin2html
|
||||
>>> print markmin2html(m)
|
||||
>>> from markmin2latex import markmin2latex
|
||||
>>> print markmin2latex(m)
|
||||
>>> from markmin2pdf import markmin2pdf # requires pdflatex
|
||||
>>> print markmin2pdf(m)</code></pre><h2>Why?</h2><p>We wanted a markup language with the following requirements:</p><ul><li>less than 100 lines of functional code</li><li>easy to read</li><li>secure</li><li>support table, ul, ol, code</li><li>support html5 video and audio elements (html serialization only)</li><li>can align images and resize them</li><li>can specify class for tables and code elements</li><li>can add anchors</li><li>does not use _ for markup (since it creates odd behavior)</li><li>automatically links urls</li><li>fast</li><li>easy to extend</li><li>supports latex and pdf including references</li><li>allows to describe the markup in the markup (this document is generated from markmin syntax)</li></ul><p>(results depend on text but in average for text ~100K markmin is 30% faster than markdown, for text ~10K it is 10x faster)</p><p>The <a href="http://www.lulu.com/product/paperback/web2py-%283rd-edition%29/12822827">web2py book</a> published by lulu, for example, was entirely generated with markmin2pdf from the online <a href="http://www.web2py.com/book">web2py wiki</a></p><h2>Download</h2><ul><li>http://web2py.googlecode.com/hg/gluon/contrib/markmin/markmin2html.py</li><li>http://web2py.googlecode.com/hg/gluon/contrib/markmin/markmin2latex.py</li><li>http://web2py.googlecode.com/hg/gluon/contrib/markmin/markmin2pdf.py</li></ul><p>markmin2html.py and markmin2latex.py are single files and have no web2py dependence. Their license is BSD.</p><h2>Examples</h2><h3>Bold, italic, code and links</h3><table class=""><tr><td><b>SOURCE</b> </td><td><b>OUTPUT</b></td></tr><tr><td><code class=""># title</code> </td><td><b>title</b></td></tr><tr><td><code class="">## section</code> </td><td><b>section</b></td></tr><tr><td><code class="">### subsection</code> </td><td><b>subsection</b></td></tr><tr><td><code class="">**bold**</code> </td><td><b>bold</b></td></tr><tr><td><code class="">''italic''</code> </td><td><i>italic</i></td></tr><tr><td><code class="">``verbatim``</code> </td><td><code class="">verbatim</code></td></tr><tr><td><code class="">http://google.com</code> </td><td>http://google.com</td></tr><tr><td><code class="">[[click me #myanchor]]</code></td><td><a href="#myanchor">click me</a></td></tr></table>
|
||||
<h3>More on links</h3><p>The format is always <code class="">[[title link]]</code>. Notice you can nest bold, italic and code inside the link title.</p><h3>Anchors <span id="myanchor"><span></h3><p>You can place an anchor anywhere in the text using the syntax <code class="">[[name]]</code> where <i>name</i> is the name of the anchor.
|
||||
You can then link the anchor with <a href="#myanchor">link</a>, i.e. <code class="">[[link #myanchor]]</code>.</p><h3>Images</h3><p><img src="http://www.web2py.com/examples/static/web2py_logo.png" alt="some image" align="right" width="200px" />
|
||||
This paragraph has an image aligned to the right with a width of 200px. Its is placed using the code</p><p><code class="">[[some image http://www.web2py.com/examples/static/web2py_logo.png right 200px]]</code>.</p><h3>Unordered Lists</h3><pre><code class="">- Dog
|
||||
<!doctype html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<style>
|
||||
blockquote { background-color: #FFFAAE; padding: 7px; }
|
||||
table { border-collapse: collapse; }
|
||||
thead td { border-bottom: 1px solid; }
|
||||
tfoot td { border-top: 1px solid; }
|
||||
.tableclass1 { background-color: lime; }
|
||||
.tableclass1 thead { color: yellow; background-color: green; }
|
||||
.tableclass1 tfoot { color: yellow; background-color: green; }
|
||||
.tableclass1 .even td { background-color: #80FF7F; }
|
||||
.tableclass1 .first td {border-top: 1px solid; }
|
||||
|
||||
td.num { text-align: right; }
|
||||
pre { background-color: #E0E0E0; padding: 5px; }
|
||||
</style>
|
||||
<title>Markmin markup language</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Markmin markup language</h1><h2>About</h2><p>This is a new markup language that we call markmin designed to produce high quality scientific papers and books and also put them online. We provide serializers for html, latex and pdf. It is implemented in the <code>markmin2html</code> function in the <code>markmin2html.py</code>.</p><p>Example of usage:</p><pre><code>m = "Hello **world** [[link http://web2py.com]]"
|
||||
from markmin2html import markmin2html
|
||||
print markmin2html(m)
|
||||
from markmin2latex import markmin2latex
|
||||
print markmin2latex(m)
|
||||
from markmin2pdf import markmin2pdf # requires pdflatex
|
||||
print markmin2pdf(m)</code></pre> ====================<h1>This is a test block with new features:</h1><p>This is a blockquote with a list with tables in it:</p><blockquote class="blockquoteclass" id="markmin_blockquoteid">This is a paragraph before list. You can continue paragraph on the next lines.<br />This is an ordered list with tables:<ol><li>Item 1</li><li>Item 2</li><li><table class="tableclass1" id="markmin_tableid1"><tbody><tr class="first"><td>aa</td><td>bb</td><td>cc</td></tr><tr class="even"><td class="num">11</td><td class="num">22</td><td class="num">33</td></tr></tbody></table></li><li>Item 4 <table class="tableclass1"><thead><tr class="first"><td>T1</td><td>T2</td><td>t3</td></tr></thead><tbody><tr class="first"><td>aaa</td><td>bbb</td><td>ccc</td></tr><tr class="even"><td>ddd</td><td>fff</td><td>ggg</td></tr><tr><td class="num">123</td><td class="num">0</td><td class="num">5.0</td></tr></tbody></table></li></ol></blockquote><p>This this a new paragraph with a table. Table has header, footer, sections, odd and even rows:</p><table class="tableclass1" id="markmin_tableid2"><thead><tr class="first"><td><strong>Title 1</strong></td><td><strong>Title 2</strong></td><td><strong>Title 3</strong></td></tr></thead><tbody><tr class="first"><td>data 1</td><td>data 2</td><td class="num">2.00</td></tr><tr class="even"><td>data 3</td><td>data4(long)</td><td class="num">23.00</td></tr><tr><td></td><td>data 5</td><td class="num">33.50</td></tr><tr class="first"><td>New section</td><td>New data</td><td class="num">5.00</td></tr><tr class="even"><td>data 1</td><td>data2(long)</td><td class="num">100.45</td></tr><tr><td></td><td>data 3</td><td class="num">12.50</td></tr><tr class="even"><td>data 4</td><td>data 5</td><td class="num">.33</td></tr><tr><td>data 6</td><td>data7(long)</td><td class="num">8.01</td></tr><tr class="even"><td></td><td>data 8</td><td class="num">514</td></tr></tbody><tfoot><tr class="first"><td>Total:</td><td>9 items</td><td>698,79</td></tr></tfoot></table><h2>Multilevel lists</h2><p>Now lists can be multilevel:</p><ol><li>Ordered item 1 on level 1. You can continue item text on next strings<ol><li><p>Ordered item 1 of sublevel 2 with a paragraph (paragraph can start with point after plus or minus characters, e.g. <strong>++.</strong> or <strong>--.</strong>)</p><li><p>This is another item. But with 3 paragraphs, blockquote and sublists:</p><p>This is the second paragraph in the item. You can add paragraphs to an item, using point notation, where first characters in the string are sequence of points with space between them and another string. For example, this paragraph (in sublevel 2) starts with two points:</p><code>.. This is the second paragraph...</code><blockquote><h3>this is a blockquote in a list</h3>You can use blockquote with headers, paragraphs, tables and lists in it:<br />Tables can have or have not header and footer. This table is defined without any header and footer in it:<table><tbody><tr class="first"><td>red</td><td>fox</td><td class="num">0</td></tr><tr class="even"><td>blue</td><td>dolphin</td><td class="num">1000</td></tr><tr><td>green</td><td>leaf</td><td class="num">10000</td></tr></tbody></table></blockquote><p>This is yet another paragraph in the item.</p><ul><li>This is an item of unordered list <strong>(sublevel 3)</strong></li><li>This is the second item of the unordered list <em>(sublevel 3)</em><ol><ol><ol><li>This is a single item of ordered list in sublevel 6</li></ol></ol><p>and this is a paragraph in sublevel 4</p></ol></li><li><p>This is a new item with paragraph in sublevel 3.</p><ol><li>Start ordered list in sublevel 4 with code block: <pre><code>line 1
|
||||
line 2
|
||||
line 3</code></pre></li><li><p>Yet another item with code block:</p><pre><code> line 1
|
||||
line 2
|
||||
line 3</code></pre> This item finishes with this paragraph.</li></ol><p>Item in sublevel 3 can be continued with paragraphs.</p><pre><code> this is another
|
||||
code block
|
||||
in the
|
||||
sublevel 3 item</code></pre></li></ul><ol><li>The last item in sublevel 3</li></ol><p>This is a continuous paragraph for item 2 in sublevel 2. You can use such structure to create difficult structured documents.</p><li>item 3 in sublevel 2</li></li></li></ol><ul><li>item 1 in sublevel 2 (new unordered list)</li><li>item 2 in sublevel 2</li><li>item 3 in sublevel 2</li></ul><ol><li>item 1 in sublevel 2 (new ordered list)</li><li>item 2 in sublevel 2</li><li>item 3 in sublevle 2</li></ol></li><li>item 2 in level 1</li><li>item 3 in level 1</li></ol><ul><li>new unordered list (item 1 in level 1)</li><li>level 2 in level 1</li><li>level 3 in level 1</li><li>level 4 in level 1</li></ul><h2>This is the last section of the test</h2><p>Single paragraph with '----' in it will be turned into separator:</p><hr /><p>And this is the last paragraph in the test. Be happy!</p><p>====================</p><h2>Why?</h2><p>We wanted a markup language with the following requirements:</p><ul><li>less than 300 lines of functional code</li><li>easy to read</li><li>secure</li><li>support table, ul, ol, code</li><li>support html5 video and audio elements (html serialization only)</li><li>can align images and resize them</li><li>can specify class for tables and code elements</li><li>can add anchors</li><li>does not use _ for markup (since it creates odd behavior)</li><li>automatically links urls</li><li>fast</li><li>easy to extend</li><li>supports latex and pdf including references</li><li>allows to describe the markup in the markup (this document is generated from markmin syntax)</li></ul><p>(results depend on text but in average for text ~100K markmin is 30% faster than markdown, for text ~10K it is 10x faster)</p><p>The <a href="http://www.lulu.com/product/paperback/web2py-%283rd-edition%29/12822827">web2py book</a> published by lulu, for example, was entirely generated with markmin2pdf from the online <a href="http://www.web2py.com/book">web2py wiki</a></p><h2>Download</h2><ul><li><a href="http://web2py.googlecode.com/hg/gluon/contrib/markmin/markmin2html.py">http://web2py.googlecode.com/hg/gluon/contrib/markmin/markmin2html.py</a></li><li><a href="http://web2py.googlecode.com/hg/gluon/contrib/markmin/markmin2latex.py">http://web2py.googlecode.com/hg/gluon/contrib/markmin/markmin2latex.py</a></li><li><a href="http://web2py.googlecode.com/hg/gluon/contrib/markmin/markmin2pdf.py">http://web2py.googlecode.com/hg/gluon/contrib/markmin/markmin2pdf.py</a></li></ul><p>markmin2html.py and markmin2latex.py are single files and have no web2py dependence. Their license is BSD.</p><h2>Examples</h2><h3>Bold, italic, code and links</h3><table><thead><tr class="first"><td><strong>SOURCE</strong></td><td><strong>OUTPUT</strong></td></tr></thead><tbody><tr class="first"><td><code># title</code></td><td><strong>title</strong></td></tr><tr class="even"><td><code>## section</code></td><td><strong>section</strong></td></tr><tr><td><code>### subsection</code></td><td><strong>subsection</strong></td></tr><tr class="even"><td><code>**bold**</code></td><td><strong>bold</strong></td></tr><tr><td><code>''italic''</code></td><td><em>italic</em></td></tr><tr class="even"><td><code>~~strikeout~~</code></td><td><del>strikeout</del></td></tr><tr><td><code>``verbatim``</code></td><td><code>verbatim</code></td></tr><tr class="even"><td><code>``color with **bold**``:red</code></td><td><span style="color: red">color with <strong>bold</strong></span></td></tr><tr><td><code>``many colors``:color[blue:#ffff00]</code></td><td><span style="color: blue;background-color: #ffff00;">many colors</span></td></tr><tr class="even"><td><code>http://google.com</code></td><td><a href="http://google.com">http://google.com</a></td></tr><tr><td><code>[[**click** me #myanchor]]</code></td><td><a href="#markmin_myanchor"><strong>click</strong> me</a></td></tr><tr class="even"><td><code>[[click me [extra info] #myanchor popup]]</code></td><td><a href="#markmin_myanchor" title="extra info" target="_blank">click me</a></td></tr></tbody></table><h3>More on links</h3><p>The format is always <code>[[title link]]</code> or <code>[[title [extra] link]]</code>. Notice you can nest bold, italic, strikeout and code inside the link <code>title</code>.</p><h3>Anchors <a name="markmin_myanchor"></a></h3><p>You can place an anchor anywhere in the text using the syntax <code>[[name]]</code> where <em>name</em> is the name of the anchor. You can then link the anchor with <a href="#markmin_myanchor">link</a>, i.e. <code>[[link #myanchor]]</code> or <a href="#markmin_myanchor" title="extra info">link with an extra info</a>, i.e. <code>[[link with an extra info [extra info] #myanchor]]</code>.</p><h3>Images</h3><p><img src="http://www.web2py.com/examples/static/web2py_logo.png" alt="alt-string for the image" title="the image title" style="float:right" width="200px" /> This paragraph has an image aligned to the right with a width of 200px. Its is placed using the code</p><p><code>[[alt-string for the imaLine truncated
|
||||
- Cat
|
||||
- Mouse</code></pre><p>is rendered as</p><ul><li>Dog</li><li>Cat</li><li>Mouse</li></ul><p>Two new lines between items break the list in two lists.</p><h3>Ordered Lists</h3><pre><code class="">+ Dog
|
||||
- Mouse</code></pre><p>is rendered as</p><ul><li>Dog</li><li>Cat</li><li>Mouse</li></ul><p>Two new lines between items break the list in two lists.</p><h3>Ordered Lists</h3><pre><code>+ Dog
|
||||
+ Cat
|
||||
+ Mouse</code></pre><p>is rendered as</p><ol><li>Dog</li><li>Cat</li><li>Mouse</li></ol><h3>Tables</h3><p>Something like this
|
||||
<pre><code class="">---------
|
||||
**A** | **B** | **C**
|
||||
0 | 0 | X
|
||||
0 | X | 0
|
||||
X | 0 | 0
|
||||
-----:abc</code></pre>
|
||||
is a table and is rendered as
|
||||
<table class="abc"><tr><td><b>A</b></td><td><b>B</b></td><td><b>C</b></td></tr><tr><td>0</td><td>0</td><td>X</td></tr><tr><td>0</td><td>X</td><td>0</td></tr><tr><td>X</td><td>0</td><td>0</td></tr></table>Four or more dashes delimit the table and | separates the columns.
|
||||
The <code class="">:abc</code> at the end sets the class for the table and it is optional.</p><h3>Blockquote</h3><p>A table with a single cell is rendered as a blockquote:</p><blockquote class="">Hello world</blockquote>
|
||||
<h3>Code, <code class=""><code></code>, escaping and extra stuff</h3><pre><code class="python">def test():
|
||||
return "this is Python code"</code></pre><p>Optionally a ` inside a <code class="">``...``</code> block can be inserted escaped with !`!.
|
||||
The <code class="">:python</code> after the markup is also optional. If present, by default, it is used to set the class of the <code> block.
|
||||
The behavior can be overridden by passing an argument <code class="">extra</code> to the <code class="">render</code> function. For example:</p><pre><code class="python">>>> markmin2html("``aaa``:custom",
|
||||
extra=dict(custom=lambda text: 'x'+text+'x'))</code></pre><p>generates</p><code class="python">'xaaax'</code><p>(the <code class="">``...``:custom</code> block is rendered by the <code class="">custom=lambda</code> function passed to <code class="">render</code>).</p><h3>Html5 support</h3><p>Markmin also supports the <video> and <audio> html5 tags using the notation:
|
||||
<pre><code class="">[[title link video]]
|
||||
[[title link audio]]</code></pre></p><h3>Latex and other extensions</h3><p>Formulas can be embedded into HTML with <code class="">$</code><code class="">$</code>formula<code class="">$</code><code class="">$</code>.
|
||||
You can use Google charts to render the formula:</p><pre><code class="">>>> LATEX = '<img src="http://chart.apis.google.com/chart?cht=tx&chl=%s" align="center"/>'
|
||||
>>> markmin2html(text,{'latex':lambda code: LATEX % code.replace('"','"')})</code></pre><h3>Code with syntax highlighting</h3><p>This requires a syntax highlighting tool, such as the web2py CODE helper.</p><pre><code class="">>>> extra={'code_cpp':lambda text: CODE(text,language='cpp').xml(),
|
||||
+ Mouse</code></pre><p>is rendered as</p><ol><li>Dog</li><li>Cat</li><li>Mouse</li></ol><h3>Multilevel Lists</h3><pre><code>+ Dogs
|
||||
-- red
|
||||
-- brown
|
||||
-- black
|
||||
+ Cats
|
||||
-- fluffy
|
||||
-- smooth
|
||||
-- bald
|
||||
+ Mice
|
||||
-- small
|
||||
-- big
|
||||
-- huge</code></pre><p>is rendered as</p><ol><li>Dogs<ul><li>red</li><li>brown</li><li>black</li></ul></li><li>Cats<ul><li>fluffy</li><li>smooth</li><li>bald</li></ul></li><li>Mice<ul><li>small</li><li>big</li><li>huge</li></ul></li></ol><h3>Tables (with optional header and/or footer)</h3><p>Something like this</p><pre><code>-----------------
|
||||
**A**|**B**|**C**
|
||||
=================
|
||||
0 | 0 | X
|
||||
0 | X | 0
|
||||
X | 0 | 0
|
||||
=================
|
||||
**D**|**F**|**G**
|
||||
-----------------:abc[id]</code></pre> is a table and is rendered as<table class="abc" id="markmin_id"><thead><tr class="first"><td><strong>A</strong></td><td><strong>B</strong></td><td><strong>C</strong></td></tr></thead><tbody><tr class="first"><td class="num">0</td><td class="num">0</td><td>X</td></tr><tr class="even"><td class="num">0</td><td>X</td><td class="num">0</td></tr><tr><td>X</td><td class="num">0</td><td class="num">0</td></tr></tbody><tfoot><tr class="first"><td><strong>D</strong></td><td><strong>F</strong></td><td><strong>G</strong></td></tr></tfoot></table> Four or more dashes delimit the table and | separates the columns. The <code>:abc</code>, <code>:id[abc_1]</code> or <code>:abc[abc_1]</code> at the end sets the class and/or id for the table and it is optional.<h3>Blockquote</h3><p>A table with a single cell is rendered as a blockquote:</p><blockquote>Hello world</blockquote><p>Blockquote can contain headers, paragraphs, lists and tables:</p><pre><code>-----
|
||||
This is a paragraph in a blockquote
|
||||
|
||||
+ item 1
|
||||
+ item 2
|
||||
-- item 2.1
|
||||
-- item 2.2
|
||||
+ item 3
|
||||
|
||||
---------
|
||||
0 | 0 | X
|
||||
0 | X | 0
|
||||
X | 0 | 0
|
||||
---------:tableclass1
|
||||
-----</code></pre><p>is rendered as:</p><blockquote>This is a paragraph in a blockquote<ol><li>item 1</li><li>item 2<ul><li>item 2.1</li><li>item 2.2</li></ul></li><li>item 3</li></ol><table class="tableclass1"><tbody><tr class="first"><td class="num">0</td><td class="num">0</td><td>X</td></tr><tr class="even"><td class="num">0</td><td>X</td><td class="num">0</td></tr><tr><td>X</td><td class="num">0</td><td class="num">0</td></tr></tbody></table></blockquote><h3>Code, <code><code></code>, escaping and extra stuff</h3><pre><code class="python">def test():
|
||||
return "this is Python code"</code></pre><p>Optionally a ` inside a <code>``...``</code> block can be inserted escaped with !`!.</p><p><strong>NOTE:</strong> You can escape markmin constructions ('',``,**,~~,[,{,]},$,@) with '\' character: so \`\` can replace !`!`! escape string</p><p>The <code>:python</code> after the markup is also optional. If present, by default, it is used to set the class of the <code> block. The behavior can be overridden by passing an argument <code>extra</code> to the <code>render</code> function. For example:</p><pre><code class="python">markmin2html("``aaa``:custom",
|
||||
extra=dict(custom=lambda text: 'x'+text+'x'))</code></pre><p>generates</p><code class="python">'xaaax'</code><p>(the <code>``...``:custom</code> block is rendered by the <code>custom=lambda</code> function passed to <code>render</code>).</p><h3>Html5 support</h3><p>Markmin also supports the <video> and <audio> html5 tags using the notation:</p><pre><code>[[message link video]]
|
||||
[[message link audio]]
|
||||
|
||||
[[message [title] link video]]
|
||||
[[message [title] link audio]]</code></pre> where <code>message</code> will be shown in brousers without HTML5 video/audio tags support.<h3>Latex and other extensions</h3><p>Formulas can be embedded into HTML with <em>$$<code>formula</code>$$</em>. You can use Google charts to render the formula:</p><pre><code>LATEX = '<img src="http://chart.apis.google.com/chart?cht=tx&chl=%s" />'
|
||||
markmin2html(text,{'latex':lambda code: LATEX % code.replace('"','\"')})</code></pre><h3>Code with syntax highlighting</h3><p>This requires a syntax highlighting tool, such as the web2py CODE helper.</p><pre><code>extra={'code_cpp':lambda text: CODE(text,language='cpp').xml(),
|
||||
'code_java':lambda text: CODE(text,language='java').xml(),
|
||||
'code_python':lambda text: CODE(text,language='python').xml(),
|
||||
'code_html':lambda text: CODE(text,language='html').xml()}
|
||||
>>> markmin2html(text,extra=extra)</code></pre><p>Code can now be marked up as in this example:</p><pre><code class="">``
|
||||
'code_html':lambda text: CODE(text,language='html').xml()}</code></pre> or simple:<pre><code>extra={'code':lambda text,lang='python': CODE(text,language=lang).xml()}</code></pre><pre><code>markmin2html(text,extra=extra)</code></pre><p>Code can now be marked up as in this example:</p><pre><code>``
|
||||
<html><body>example</body></html>
|
||||
``:code_html</code></pre><h3>Citations and References</h3><p>Citations are treated as internal links in html and proper citations in latex if there is a final section called "References". Items like</p><pre><code class="">- [[key]] value</code></pre><p>in the References will be translated into Latex</p><pre><code class="">\bibitem{key} value</code></pre><p>Here is an example of usage:</p><pre><code class="">As shown in Ref.``mdipierro``:cite
|
||||
``:code_html</code></pre> OR<pre><code>``
|
||||
<html><body>example</body></html>
|
||||
``:code[html]</code></pre><h3>Citations and References</h3><p>Citations are treated as internal links in html and proper citations in latex if there is a final section called "References". Items like</p><pre><code>- [[key]] value</code></pre><p>in the References will be translated into Latex</p><pre><code>\bibitem{key} value</code></pre><p>Here is an example of usage:</p><pre><code>As shown in Ref.``mdipierro``:cite
|
||||
|
||||
## References
|
||||
- [[mdipierro]] web2py Manual, 3rd Edition, lulu.com</code></pre><h3>Caveats</h3><p><code class=""><ul/></code>, <code class=""><ol/></code>, <code class=""><code/></code>, <code class=""><table/></code>, <code class=""><blockquote/></code>, <code class=""><h1/></code>, ..., <code class=""><h6/></code> do not have <code class=""><p>...</p></code> around them.</p></body></html>
|
||||
|
||||
- [[mdipierro]] web2py Manual, 3rd Edition, lulu.com</code></pre><h3>Caveats</h3><p><code><ul/></code>, <code><ol/></code>, <code><code/></code>, <code><table/></code>, <code><blockquote/></code>, <code><h1/></code>, ..., <code><h6/></code> do not have <code><p>...</p></code> around them.</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -4,13 +4,119 @@
|
||||
'!langname!': 'English (US)',
|
||||
'%s %%(shop)': '%s %%(shop)',
|
||||
'%s %%(shop[0])': '%s %%(shop[0])',
|
||||
'%s %%{quark[0]}': '%s %%{quark[0]}',
|
||||
'%s %%{shop[0]}': '%s %%{shop[0]}',
|
||||
'%s %%{shop}': '%s %%{shop}',
|
||||
'%Y-%m-%d': '%Y-%m-%d',
|
||||
'%Y-%m-%d %H:%M:%S': '%Y-%m-%d %H:%M:%S',
|
||||
'@markmin\x01**Hello World**': '**Hello World**',
|
||||
'About': 'About',
|
||||
'Access Control': 'Access Control',
|
||||
'Administrative Interface': 'Administrative Interface',
|
||||
'Ajax Recipes': 'Ajax Recipes',
|
||||
'Are you sure you want to delete this object?': 'Are you sure you want to delete this object?',
|
||||
'Buy this book': 'Buy this book',
|
||||
'Cannot be empty': 'Cannot be empty',
|
||||
'Check to delete': 'Check to delete',
|
||||
'Client IP': 'Client IP',
|
||||
'Community': 'Community',
|
||||
'Components and Plugins': 'Components and Plugins',
|
||||
'Controller': 'Controller',
|
||||
'Copyright': 'Copyright',
|
||||
'Created By': 'Created By',
|
||||
'Created On': 'Created On',
|
||||
'customize me!': 'customize me!',
|
||||
'Database': 'Database',
|
||||
'DB Model': 'DB Model',
|
||||
'Demo': 'Demo',
|
||||
'Deployment Recipes': 'Deployment Recipes',
|
||||
'Description': 'Description',
|
||||
'Documentation': 'Documentation',
|
||||
"Don't know what to do?": "Don't know what to do?",
|
||||
'Download': 'Download',
|
||||
'E-mail': 'E-mail',
|
||||
'Email and SMS': 'Email and SMS',
|
||||
'enter an integer between %(min)g and %(max)g': 'enter an integer between %(min)g and %(max)g',
|
||||
'enter date and time as %(format)s': 'enter date and time as %(format)s',
|
||||
'Errors': 'Errors',
|
||||
'FAQ': 'FAQ',
|
||||
'First name': 'First name',
|
||||
'Forms and Validators': 'Forms and Validators',
|
||||
'Free Applications': 'Free Applications',
|
||||
'Group %(group_id)s created': 'Group %(group_id)s created',
|
||||
'Group ID': 'Group ID',
|
||||
'Group uniquely assigned to user %(id)s': 'Group uniquely assigned to user %(id)s',
|
||||
'Groups': 'Groups',
|
||||
'Hello World': 'Hello World',
|
||||
'Hello World ## comment': 'Hello World ',
|
||||
'Hello World## comment': 'Hello World',
|
||||
'Home': 'Home',
|
||||
'How did you get here?': 'How did you get here?',
|
||||
'Introduction': 'Introduction',
|
||||
'Invalid email': 'Invalid email',
|
||||
'Is Active': 'Is Active',
|
||||
'Last name': 'Last name',
|
||||
'Layout': 'Layout',
|
||||
'Layout Plugins': 'Layout Plugins',
|
||||
'Layouts': 'Layouts',
|
||||
'Live Chat': 'Live Chat',
|
||||
'Logged in': 'Logged in',
|
||||
'Logged out': 'Logged out',
|
||||
'Login': 'Login',
|
||||
'Logout': 'Logout',
|
||||
'Lost Password': 'Lost Password',
|
||||
'Lost password?': 'Lost password?',
|
||||
'Menu Model': 'Menu Model',
|
||||
'Modified By': 'Modified By',
|
||||
'Modified On': 'Modified On',
|
||||
'My Sites': 'My Sites',
|
||||
'Name': 'Name',
|
||||
'Object or table name': 'Object or table name',
|
||||
'Online examples': 'Online examples',
|
||||
'Origin': 'Origin',
|
||||
'Other Plugins': 'Other Plugins',
|
||||
'Other Recipes': 'Other Recipes',
|
||||
'Overview': 'Overview',
|
||||
'Password': 'Password',
|
||||
"Password fields don't match": "Password fields don't match",
|
||||
'please input your password again': 'please input your password again',
|
||||
'Plugins': 'Plugins',
|
||||
'Powered by': 'Powered by',
|
||||
'Preface': 'Preface',
|
||||
'Profile': 'Profile',
|
||||
'Python': 'Python',
|
||||
'Quick Examples': 'Quick Examples',
|
||||
'Recipes': 'Recipes',
|
||||
'Record ID': 'Record ID',
|
||||
'Register': 'Register',
|
||||
'Registration identifier': 'Registration identifier',
|
||||
'Registration key': 'Registration key',
|
||||
'Registration successful': 'Registration successful',
|
||||
'Remember me (for 30 days)': 'Remember me (for 30 days)',
|
||||
'Reset Password key': 'Reset Password key',
|
||||
'Role': 'Role',
|
||||
'Semantic': 'Semantic',
|
||||
'Services': 'Services',
|
||||
'Stylesheet': 'Stylesheet',
|
||||
'Support': 'Support',
|
||||
'The Core': 'The Core',
|
||||
'The output of the file is a dictionary that was rendered by the view %s': 'The output of the file is a dictionary that was rendered by the view %s',
|
||||
'The Views': 'The Views',
|
||||
'This App': 'This App',
|
||||
'Timestamp': 'Timestamp',
|
||||
'Twitter': 'Twitter',
|
||||
'User %(id)s Logged-in': 'User %(id)s Logged-in',
|
||||
'User %(id)s Logged-out': 'User %(id)s Logged-out',
|
||||
'User %(id)s Registered': 'User %(id)s Registered',
|
||||
'User ID': 'User ID',
|
||||
'value already in database or empty': 'value already in database or empty',
|
||||
'Verify Password': 'Verify Password',
|
||||
'Videos': 'Videos',
|
||||
'View': 'View',
|
||||
'Welcome': 'Welcome',
|
||||
'Welcome to web2py!': 'Welcome to web2py!',
|
||||
'Which called the function %s located in the file %s': 'Which called the function %s located in the file %s',
|
||||
'You are successfully running web2py': 'You are successfully running web2py',
|
||||
'You can modify this application and adapt it to your needs': 'You can modify this application and adapt it to your needs',
|
||||
'You visited the url %s': 'You visited the url %s',
|
||||
}
|
||||
@@ -60,6 +60,7 @@
|
||||
'edit profile': 'modifica profilo',
|
||||
'Edit This App': 'Modifica questa applicazione',
|
||||
'Email and SMS': 'Email and SMS',
|
||||
'Email non valida': 'Email non valida',
|
||||
'enter an integer between %(min)g and %(max)g': 'enter an integer between %(min)g and %(max)g',
|
||||
'Errors': 'Errors',
|
||||
'export as csv file': 'esporta come file CSV',
|
||||
@@ -95,6 +96,7 @@
|
||||
'Layouts': 'Layouts',
|
||||
'Live Chat': 'Live Chat',
|
||||
'Logged in': 'Logged in',
|
||||
'Logged out': 'Logged out',
|
||||
'login': 'accesso',
|
||||
'Login': 'Login',
|
||||
'logout': 'uscita',
|
||||
@@ -113,6 +115,7 @@
|
||||
'new record inserted': 'nuovo record inserito',
|
||||
'next 100 rows': 'prossime 100 righe',
|
||||
'No databases in this application': 'Nessun database presente in questa applicazione',
|
||||
'Non può essere vuoto': 'Non può essere vuoto',
|
||||
'not authorized': 'non autorizzato',
|
||||
'Object or table name': 'Object or table name',
|
||||
'Online examples': 'Vedere gli esempi',
|
||||
@@ -166,12 +169,14 @@
|
||||
'This App': 'This App',
|
||||
'This is a copy of the scaffolding application': "Questa è una copia dell'applicazione di base (scaffold)",
|
||||
'Timestamp': 'Ora (timestamp)',
|
||||
'too short': 'too short',
|
||||
'Twitter': 'Twitter',
|
||||
'unable to parse csv file': 'non riesco a decodificare questo file CSV',
|
||||
'Update': 'Update',
|
||||
'Update:': 'Aggiorna:',
|
||||
'Use (...)&(...) for AND, (...)|(...) for OR, and ~(...) for NOT to build more complex queries.': 'Per costruire richieste (query) più complesse si usano (...)&(...) come "e" (AND), (...)|(...) come "o" (OR), e ~(...) come negazione (NOT).',
|
||||
'User %(id)s Logged-in': 'User %(id)s Logged-in',
|
||||
'User %(id)s Logged-out': 'User %(id)s Logged-out',
|
||||
'User %(id)s Registered': 'User %(id)s Registered',
|
||||
'User ID': 'ID Utente',
|
||||
'Verify Password': 'Verify Password',
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
'is': ['are'],
|
||||
'man': ['men'],
|
||||
'person': ['people'],
|
||||
'quark': ['quarks'],
|
||||
'shop': ['shops'],
|
||||
'this': ['these'],
|
||||
'was': ['were'],
|
||||
|
||||
@@ -15,9 +15,9 @@ td,th {text-align:left; padding:2px 5px 2px 5px}
|
||||
th {vertical-align:middle; border-right:1px solid white}
|
||||
td {vertical-align:top}
|
||||
form table tr td label {text-align:left}
|
||||
p,table,ol,ul {padding:0; margin: 0.5em 0}
|
||||
p,table,ol,ul {padding:0; margin: 0.75em 0}
|
||||
p {text-align:justify}
|
||||
ol, ul {list-style-position:inside}
|
||||
ol, ul {list-style-position:outside; margin-left:2em}
|
||||
li {margin-bottom:0.5em}
|
||||
span,input,select,textarea,button,label,a {display:inline}
|
||||
img {border:0}
|
||||
@@ -39,13 +39,6 @@ input[type=text],input[type=password],select{width:300px; margin-right:5px}
|
||||
|
||||
/* Sticky footer begin */
|
||||
|
||||
.wrapper {
|
||||
min-height:100%;
|
||||
height:auto !important;
|
||||
height:100%;
|
||||
margin:0 auto -8em; /* set last value to footer height plus footer vertical padding */
|
||||
}
|
||||
|
||||
.main {
|
||||
padding:20px 0 50px 0;
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@
|
||||
</section><!--/main-->
|
||||
|
||||
<!-- Footer ================================================== -->
|
||||
<footer class="footer">
|
||||
<footer class="footer" id="footer">
|
||||
{{block footer}} <!-- this is default footer -->
|
||||
<div class="footer-content">
|
||||
<div class="copyright pull-left">{{=T('Copyright')}} © {{=request.now.year}}</div>
|
||||
|
||||
@@ -40,7 +40,6 @@ __all__ = ['Cache', 'lazy_cache']
|
||||
|
||||
DEFAULT_TIME_EXPIRE = 300
|
||||
|
||||
|
||||
class CacheAbstract(object):
|
||||
"""
|
||||
Abstract class for cache implementations.
|
||||
|
||||
+28
-5
@@ -91,6 +91,18 @@ def _TEST():
|
||||
_TEST()
|
||||
"""
|
||||
|
||||
CACHED_REGEXES = {}
|
||||
CACHED_REGEXES_MAX_SIZE = 1000
|
||||
|
||||
def re_compile(regex):
|
||||
try:
|
||||
return CACHED_REGEXES[regex]
|
||||
except KeyError:
|
||||
if len(CACHED_REGEXES) >= CACHED_REGEXES_MAX_SIZE:
|
||||
CACHED_REGEXES.clear()
|
||||
compiled_regex = CACHED_REGEXES[regex] = re.compile(regex)
|
||||
return compiled_regex
|
||||
|
||||
class mybuiltin(object):
|
||||
"""
|
||||
NOTE could simple use a dict and populate it,
|
||||
@@ -355,6 +367,10 @@ def build_environment(request, response, session, store_current=True):
|
||||
environment.update((k,getattr(v, k)) for k in v.__all__)
|
||||
if not request.env:
|
||||
request.env = Storage()
|
||||
# Enable standard conditional models (i.e., /*.py, /[controller]/*.py, and
|
||||
# /[controller]/[function]/*.py)
|
||||
response.models_to_run = [r'^\w+\.py$', r'^%s/\w+\.py$' % request.controller,
|
||||
r'^%s/%s/\w+\.py$' % (request.controller, request.function)]
|
||||
|
||||
t = environment['T'] = translator(request)
|
||||
c = environment['cache'] = Cache(request)
|
||||
@@ -485,9 +501,13 @@ def run_models_in(environment):
|
||||
path = pjoin(folder, 'models')
|
||||
models = listdir(path, '^\w+\.py$',0,sort=False)
|
||||
compiled=False
|
||||
paths = (path, pjoin(path,c), pjoin(path,c,f))
|
||||
n = len(path) + 1
|
||||
for model in models:
|
||||
if not os.path.split(model)[0] in paths and c!='appadmin':
|
||||
regex = environment['response'].models_to_run
|
||||
if isinstance(regex, list):
|
||||
regex = re_compile('|'.join(regex))
|
||||
file = model[n:].replace(os.path.sep, '/').replace('.pyc', '.py')
|
||||
if not regex.search(file) and c!= 'appadmin':
|
||||
continue
|
||||
elif compiled:
|
||||
code = read_pyc(model)
|
||||
@@ -581,10 +601,13 @@ def run_view_in(environment):
|
||||
folder = request.folder
|
||||
path = pjoin(folder, 'compiled')
|
||||
badv = 'invalid view (%s)' % view
|
||||
patterns = response.generic_patterns or []
|
||||
regex = re.compile('|'.join(map(fnmatch.translate, patterns)))
|
||||
if response.generic_patterns:
|
||||
patterns = response.generic_patterns
|
||||
regex = re_compile('|'.join(map(fnmatch.translate, patterns)))
|
||||
short_action = '%(controller)s/%(function)s.%(extension)s' % request
|
||||
allow_generic = patterns and regex.search(short_action)
|
||||
allow_generic = regex.search(short_action)
|
||||
else:
|
||||
allow_generic = False
|
||||
if not isinstance(view, str):
|
||||
ccode = parse_template(view, pjoin(folder, 'views'),
|
||||
context=environment)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/env python
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# created by Massimo Di Pierro
|
||||
# recreated by Vladyslav Kozlovskyy
|
||||
@@ -44,8 +44,8 @@ from markmin2pdf import markmin2pdf # requires pdflatex
|
||||
print markmin2pdf(m)
|
||||
``
|
||||
====================
|
||||
# This is a test block with new features:
|
||||
|
||||
# This is a test block
|
||||
with new features:
|
||||
This is a blockquote with
|
||||
a list with tables in it:
|
||||
-----------
|
||||
@@ -71,7 +71,9 @@ a list with tables in it:
|
||||
-----------:blockquoteclass[blockquoteid]
|
||||
|
||||
This this a new paragraph
|
||||
with a table. Table has header, footer, sections, odd and even rows:
|
||||
with a followed table.
|
||||
Table has header, footer, sections,
|
||||
odd and even rows:
|
||||
-------------------------------
|
||||
**Title 1**|**Title 2**|**Title 3**
|
||||
==============================
|
||||
@@ -98,6 +100,8 @@ Now lists can be multilevel:
|
||||
You can continue item text on
|
||||
next strings
|
||||
|
||||
. paragraph in an item
|
||||
|
||||
++. Ordered item 1 of sublevel 2 with
|
||||
a paragraph (paragraph can start
|
||||
with point after plus or minus
|
||||
@@ -143,13 +147,13 @@ line 1
|
||||
line 2
|
||||
line 3
|
||||
``
|
||||
++++. Yet another item with code block:
|
||||
``
|
||||
++++. Yet another item with code block (we need to indent \`\` to add code block as part of item):
|
||||
``
|
||||
line 1
|
||||
line 2
|
||||
line 3
|
||||
``
|
||||
This item finishes with this paragraph.
|
||||
This item finishes with this paragraph.
|
||||
|
||||
... Item in sublevel 3 can be continued with paragraphs.
|
||||
|
||||
@@ -201,7 +205,7 @@ We wanted a markup language with the following requirements:
|
||||
- support table, ul, ol, code
|
||||
- support html5 video and audio elements (html serialization only)
|
||||
- can align images and resize them
|
||||
- can specify class for tables and code elements
|
||||
- can specify class for tables, blockquotes and code elements
|
||||
- can add anchors
|
||||
- does not use _ for markup (since it creates odd behavior)
|
||||
- automatically links urls
|
||||
@@ -420,6 +424,23 @@ generates
|
||||
|
||||
(the ``!`!`...`!`!:custom`` block is rendered by the ``custom=lambda`` function passed to ``render``).
|
||||
|
||||
### Line breaks
|
||||
|
||||
``[[NEWLINE]]`` tag is used to break lines:
|
||||
``
|
||||
#### Multiline [[NEWLINE]]
|
||||
title
|
||||
paragraph [[NEWLINE]]
|
||||
with breaks[[NEWLINE]]in it
|
||||
``
|
||||
generates:
|
||||
|
||||
#### Multiline [[NEWLINE]]
|
||||
title
|
||||
paragraph [[NEWLINE]]
|
||||
with breaks[[NEWLINE]]in it
|
||||
|
||||
|
||||
### Html5 support
|
||||
|
||||
Markmin also supports the <video> and <audio> html5 tags using the notation:
|
||||
@@ -430,7 +451,7 @@ Markmin also supports the <video> and <audio> html5 tags using the notation:
|
||||
[[message [title] link video]]
|
||||
[[message [title] link audio]]
|
||||
``
|
||||
where ``message`` will be shown in brousers without HTML5 video/audio tags support.
|
||||
where ``message`` will be shown in browsers without HTML5 video/audio tags support.
|
||||
|
||||
### Latex and other extensions
|
||||
|
||||
@@ -512,18 +533,19 @@ DISABLED_META = '\x08'
|
||||
LATEX = '<img src="http://chart.apis.google.com/chart?cht=tx&chl=%s" />'
|
||||
regex_URL=re.compile(r'@/(?P<a>\w*)/(?P<c>\w*)/(?P<f>\w*(\.\w+)?)(/(?P<args>[\w\.\-/]+))?')
|
||||
regex_env=re.compile(r'@\{(?P<a>[\w\-\.]+?)(\:(?P<b>.*?))?\}')
|
||||
regex_expand_meta = re.compile('('+META+'|'+DISABLED_META+')')
|
||||
regex_expand_meta = re.compile('('+META+'|'+DISABLED_META+'|````)')
|
||||
regex_dd=re.compile(r'\$\$(?P<latex>.*?)\$\$')
|
||||
regex_code = re.compile('('+META+'|'+DISABLED_META+r')|(``(?P<t>.+?)``(?::(?P<c>[a-zA-Z][_a-zA-Z\-\d]*)(?:\[(?P<p>[^\]]*)\])?)?)',re.S)
|
||||
regex_code = re.compile('('+META+'|'+DISABLED_META+r'|````)|(``(?P<t>.+?)``(?::(?P<c>[a-zA-Z][_a-zA-Z\-\d]*)(?:\[(?P<p>[^\]]*)\])?)?)',re.S)
|
||||
regex_strong=re.compile(r'\*\*(?P<t>[^\s*]+( +[^\s*]+)*)\*\*')
|
||||
regex_del=re.compile(r'~~(?P<t>[^\s*]+( +[^\s*]+)*)~~')
|
||||
regex_em=re.compile(r"''(?P<t>[^\s']+(?: +[^\s']+)*)''")
|
||||
regex_num=re.compile(r"^\s*[+-]?((\d+(\.\d*)?)|\.\d+)([eE][+-]?[0-9]+)?\s*$")
|
||||
regex_list=re.compile('^(?:(#{1,6}|\.+ |\++ |\++\. |\-+ |\-+\. )\s*)?(.*)$')
|
||||
regex_list=re.compile('^(?:(?:(#{1,6})|(?:(\.+|\++|\-+)(\.)?))\s+)?(.*)$')
|
||||
regex_bq_headline=re.compile('^(?:(\.+|\++|\-+)(\.)?\s+)?(-{3}-*)$')
|
||||
regex_tq=re.compile('^(-{3}-*)(?::(?P<c>[a-zA-Z][_a-zA-Z\-\d]*)(?:\[(?P<p>[a-zA-Z][_a-zA-Z\-\d]*)\])?)?$')
|
||||
regex_proto = re.compile(r'(?<!["\w>/=])(?P<p>\w+):(?P<k>\w+://[\w\d\-+=?%&/:.]+)', re.M)
|
||||
regex_auto = re.compile(r'(?<!["\w>/=])(?P<k>\w+://[^\s\'\"\]\}\)]+)',re.M)
|
||||
regex_auto = re.compile(r'(?<!["\w>/=])(?P<k>\w+://[\w\d\-+_=?%&/:.]+)',re.M)
|
||||
regex_link=re.compile(r'('+LINK+r')|\[\[(?P<s>.+?)\]\]')
|
||||
regex_link_level2=re.compile(r'^(?P<t>\S.*?)?(?:\s+\[(?P<a>.+?)\])?(?:\s+(?P<k>\S+))?(?:\s+(?P<p>popup))?\s*$')
|
||||
regex_media_level2=re.compile(r'^(?P<t>\S.*?)?(?:\s+\[(?P<a>.+?)\])?(?:\s+(?P<k>\S+))?\s+(?P<p>img|IMG|left|right|center|video|audio)(?:\s+(?P<w>\d+px))?\s*$')
|
||||
@@ -579,7 +601,8 @@ def render(text,
|
||||
autolinks='default',
|
||||
protolinks='default',
|
||||
class_prefix='',
|
||||
id_prefix='markmin_'):
|
||||
id_prefix='markmin_',
|
||||
pretty_print=False):
|
||||
"""
|
||||
Arguments:
|
||||
- text is the text to be processed
|
||||
@@ -791,9 +814,18 @@ def render(text,
|
||||
>>> render('[[id1 [span **messag** in ''markmin''] ]] ... [[**link** to id [link\\\'s title] #mark1]]')
|
||||
'<p><div class="anchor" id="markmin_id1">span <strong>messag</strong> in markmin</div> ... <a href="#markmin_mark1" title="link\\\'s title"><strong>link</strong> to id</a></p>'
|
||||
|
||||
>>> render('# Multiline[[NEWLINE]]\\n title\\nParagraph[[NEWLINE]]\\nwith breaks[[NEWLINE]]\\nin it')
|
||||
'<h1>Multiline<br /> title</h1><p>Paragraph<br /> with breaks<br /> in it</p>'
|
||||
|
||||
>>> render("anchor with name 'NEWLINE': [[NEWLINE [ ] ]]")
|
||||
'<p>anchor with name \\'NEWLINE\\': <div class="anchor" id="markmin_NEWLINE"></div></p>'
|
||||
|
||||
>>> render("anchor with name 'NEWLINE': [[NEWLINE [newline] ]]")
|
||||
'<p>anchor with name \\'NEWLINE\\': <div class="anchor" id="markmin_NEWLINE">newline</div></p>'
|
||||
"""
|
||||
if autolinks=="default": autolinks = autolinks_simple
|
||||
if protolinks=="default": protolinks = protolinks_simple
|
||||
pp='\n' if pretty_print else ''
|
||||
text = str(text or '')
|
||||
text = regex_backslash.sub(lambda m: m.group(1).translate(ttab_in), text)
|
||||
|
||||
@@ -816,9 +848,12 @@ def render(text,
|
||||
segments = []
|
||||
def mark_code(m):
|
||||
g = m.group(0)
|
||||
if m.group() in ( META, DISABLED_META ):
|
||||
if g in (META, DISABLED_META ):
|
||||
segments.append((None, None, None, g))
|
||||
return m.group()
|
||||
elif g == '````':
|
||||
segments.append((None, None, None, ''))
|
||||
return m.group()
|
||||
else:
|
||||
c = m.group('c') or ''
|
||||
p = m.group('p') or ''
|
||||
@@ -849,13 +884,13 @@ def render(text,
|
||||
#############################################################
|
||||
# normalize spaces
|
||||
#############################################################
|
||||
strings=[t.strip() for t in text.split('\n')]
|
||||
strings=text.split('\n')
|
||||
|
||||
def parse_title(t, s): #out, lev, etags, tag, s):
|
||||
hlevel=str(len(t))
|
||||
out.extend(etags[::-1])
|
||||
out.append("<h%s>%s"%(hlevel,s))
|
||||
etags[:]=["</h%s>"%hlevel]
|
||||
etags[:]=["</h%s>%s"%(hlevel,pp)]
|
||||
lev=0
|
||||
ltags[:]=[]
|
||||
tlev[:]=[]
|
||||
@@ -880,8 +915,8 @@ def render(text,
|
||||
out.append(etags.pop())
|
||||
ltags.pop()
|
||||
for i in xrange(lent-lev):
|
||||
out.append('<'+tag+'>')
|
||||
etags.append('</'+tag+'>')
|
||||
out.append('<'+tag+'>'+pp)
|
||||
etags.append('</'+tag+'>'+pp)
|
||||
lev+=1
|
||||
ltags.append(lev)
|
||||
tlev.append(tag)
|
||||
@@ -892,8 +927,8 @@ def render(text,
|
||||
ltags.pop()
|
||||
out.append(etags.pop())
|
||||
tlev[-1]=tag
|
||||
out.append('<'+tag+'>')
|
||||
etags.append('</'+tag+'>')
|
||||
out.append('<'+tag+'>'+pp)
|
||||
etags.append('</'+tag+'>'+pp)
|
||||
ltags.append(lev)
|
||||
else:
|
||||
if ltags.count(lev)>1:
|
||||
@@ -901,7 +936,7 @@ def render(text,
|
||||
ltags.pop()
|
||||
mtag='l'
|
||||
out.append('<li>')
|
||||
etags.append('</li>')
|
||||
etags.append('</li>'+pp)
|
||||
ltags.append(lev)
|
||||
if s[:1] == '-':
|
||||
(s, mtag, lineno) = parse_table_or_blockquote(s, mtag, lineno)
|
||||
@@ -954,7 +989,7 @@ def render(text,
|
||||
return (s, mtag, lineno)
|
||||
|
||||
lineno+=1
|
||||
s = strings[lineno]
|
||||
s = strings[lineno].strip()
|
||||
if s:
|
||||
if '|' in s:
|
||||
# table
|
||||
@@ -967,7 +1002,7 @@ def render(text,
|
||||
|
||||
# parse table:
|
||||
while lineno < strings_len:
|
||||
s = strings[lineno]
|
||||
s = strings[lineno].strip()
|
||||
if s[:1] == '=':
|
||||
if s.count('=')==len(s) and len(s)>3: # header or footer
|
||||
if not thead: # if thead list is empty:
|
||||
@@ -994,7 +1029,7 @@ def render(text,
|
||||
if regex_num.match(f)
|
||||
else '',
|
||||
f.strip()
|
||||
) for f in s.split('|')])+'</tr>')
|
||||
) for f in s.split('|')])+'</tr>'+pp)
|
||||
rownum+=1
|
||||
lineno+=1
|
||||
|
||||
@@ -1002,15 +1037,15 @@ def render(text,
|
||||
t_id = ' id="%s%s"'%(id_prefix, t_id) if t_id else ''
|
||||
s = ''
|
||||
if thead:
|
||||
s += '<thead>'+''.join([l for l in thead])+'</thead>'
|
||||
s += '<thead>'+pp+''.join([l for l in thead])+'</thead>'+pp
|
||||
if not tbody: # tbody strings are in tout list
|
||||
tbody = tout
|
||||
tout = []
|
||||
if tbody: # if tbody list is not empty:
|
||||
s += '<tbody>'+''.join([l for l in tbody])+'</tbody>'
|
||||
s += '<tbody>'+pp+''.join([l for l in tbody])+'</tbody>'+pp
|
||||
if tout: # tfoot is not empty:
|
||||
s += '<tfoot>'+''.join([l for l in tout])+'</tfoot>'
|
||||
s = '<table%s%s>%s</table>' % (t_cls, t_id, s)
|
||||
s += '<tfoot>'+pp+''.join([l for l in tout])+'</tfoot>'+pp
|
||||
s = '<table%s%s>%s%s</table>%s' % (t_cls, t_id, pp, s, pp)
|
||||
mtag='t'
|
||||
else:
|
||||
# parse blockquote:
|
||||
@@ -1021,7 +1056,7 @@ def render(text,
|
||||
|
||||
# search blockquote closing line:
|
||||
while lineno < strings_len:
|
||||
s = strings[lineno]
|
||||
s = strings[lineno].strip()
|
||||
if not t_mode:
|
||||
m = regex_tq.match(s)
|
||||
if m:
|
||||
@@ -1031,7 +1066,7 @@ def render(text,
|
||||
break
|
||||
|
||||
if regex_bq_headline.match(s):
|
||||
if lineno+1 < strings_len and strings[lineno+1]:
|
||||
if lineno+1 < strings_len and strings[lineno+1].strip():
|
||||
t_mode = True
|
||||
lineno+=1
|
||||
continue
|
||||
@@ -1044,7 +1079,7 @@ def render(text,
|
||||
|
||||
t_cls = ' class="%s%s"'%(class_prefix,t_cls) if t_cls and t_cls != 'id' else ''
|
||||
t_id = ' id="%s%s"'%(id_prefix,t_id) if t_id else ''
|
||||
s = '<blockquote%s%s>%s</blockquote>' \
|
||||
s = '<blockquote%s%s>%s</blockquote>%s' \
|
||||
% (t_cls,
|
||||
t_id,
|
||||
render('\n'.join(strings[bq_begin:lineno]),
|
||||
@@ -1057,7 +1092,9 @@ def render(text,
|
||||
autolinks,
|
||||
protolinks,
|
||||
class_prefix,
|
||||
id_prefix)
|
||||
id_prefix,
|
||||
pretty_print),
|
||||
pp
|
||||
)
|
||||
mtag='q'
|
||||
else:
|
||||
@@ -1068,51 +1105,56 @@ def render(text,
|
||||
|
||||
if sep == 'p':
|
||||
pbeg = "<p>"
|
||||
pend = "</p>"
|
||||
pend = "</p>"+pp
|
||||
br = ''
|
||||
else:
|
||||
pbeg = pend = ''
|
||||
br = "<br />" if sep=='br' else ''
|
||||
br = "<br />"+pp if sep=='br' else ''
|
||||
|
||||
lev = 0 # рівень вкладеності списків
|
||||
c0 = '' # перший символ поточного рядка
|
||||
out = [] # результуючий список рядків
|
||||
etags = [] # завершуючі таги
|
||||
ltags = [] # номер рівня відповідний завершуючому тагу
|
||||
tlev = [] # таг рівня ('ul' або 'ol')
|
||||
mtag = '' # marked tag (~last tag) ('l','.','h','p','t'). Used for set <br/>
|
||||
# and for avoid <p></p> around tables and blockquotes
|
||||
lev = 0 # nesting level of lists
|
||||
c0 = '' # first character of current line
|
||||
out = [] # list of processed lines
|
||||
etags = [] # trailing tags
|
||||
ltags = [] # level# correspondent to trailing tag
|
||||
tlev = [] # list of tags for each level ('ul' or 'ol')
|
||||
mtag = '' # marked tag (~last tag) ('l','.','h','p','t'). Used to set <br/>
|
||||
# and to avoid <p></p> around tables and blockquotes
|
||||
lineno = 0
|
||||
strings_len = len(strings)
|
||||
while lineno < strings_len:
|
||||
s = strings[lineno]
|
||||
s0 = strings[lineno][:1]
|
||||
s = strings[lineno].strip()
|
||||
""" # + - . ---------------------
|
||||
## ++ -- .. ------- field | field | field <-title
|
||||
### +++ --- ... quote =====================
|
||||
#### ++++ ---- .... ------- field | field | field <-body
|
||||
##### +++++ ----- ..... ---------------------:class[id]
|
||||
"""
|
||||
pc0=c0 # перший символ попереднього рядка
|
||||
pc0=c0 # first character of previous line
|
||||
c0=s[:1]
|
||||
if c0: # for non empty strings
|
||||
if c0 in "#+-.": # first character is one of: # + - .
|
||||
match = regex_list.search(s)
|
||||
(t,p,s) = match.group(1), None, match.group(2)
|
||||
t = (t or '').strip()
|
||||
if t.endswith('.'): t, p = t[:-1], '.'
|
||||
# t - tag ("###", "+++", "---", "...")
|
||||
(t1,t2,p,ss) = regex_list.findall(s)[0]
|
||||
# t1 - tag ("###")
|
||||
# t2 - tag ("+++", "---", "...")
|
||||
# p - paragraph point ('.')->for "++." or "--."
|
||||
# s - other part of string
|
||||
if t:
|
||||
# ss - other part of string
|
||||
if t1 or t2:
|
||||
# headers and lists:
|
||||
if c0 == '#': # headers
|
||||
(lev, mtag) = parse_title(t, s)
|
||||
(lev, mtag) = parse_title(t1, ss)
|
||||
lineno+=1
|
||||
continue
|
||||
elif c0 == '+': # ordered list
|
||||
(lev, mtag, lineno)= parse_list(t, p, s, 'ol', lev, mtag, lineno)
|
||||
(lev, mtag, lineno)= parse_list(t2, p, ss, 'ol', lev, mtag, lineno)
|
||||
lineno+=1
|
||||
continue
|
||||
elif c0 == '-': # unordered list
|
||||
(lev, mtag, lineno) = parse_list(t, p, s, 'ul', lev, mtag, lineno)
|
||||
else: # c0 == '.' # paragraph in lists
|
||||
(lev, mtag, lineno) = parse_point(t, s, lev, mtag, lineno)
|
||||
(lev, mtag, lineno) = parse_list(t2, p, ss, 'ul', lev, mtag, lineno)
|
||||
lineno+=1
|
||||
continue
|
||||
elif lev>0: # and c0 == '.' # paragraph in lists
|
||||
(lev, mtag, lineno) = parse_point(t2, ss, lev, mtag, lineno)
|
||||
lineno+=1
|
||||
continue
|
||||
else:
|
||||
@@ -1123,7 +1165,7 @@ def render(text,
|
||||
# new paragraph
|
||||
pc0=''
|
||||
|
||||
if pc0 == '':
|
||||
if pc0 == '' or (mtag != 'p' and s0 not in (' ','\t')):
|
||||
# paragraph
|
||||
out.extend(etags[::-1])
|
||||
etags=[]
|
||||
@@ -1171,12 +1213,12 @@ def render(text,
|
||||
style = p_begin = p_end = ''
|
||||
if p == 'center':
|
||||
p_begin = '<p style="text-align:center">'
|
||||
p_end = '</p>'
|
||||
p_end = '</p>'+pp
|
||||
elif p in ('left','right'):
|
||||
style = ' style="float:%s"' % p
|
||||
if p in ('video','audio'):
|
||||
t = render(t, {}, {}, 'br', URL, environment, latex,
|
||||
autolinks, protolinks, class_prefix, id_prefix)
|
||||
autolinks, protolinks, class_prefix, id_prefix, pretty_print)
|
||||
return '<%(p)s controls="controls"%(title)s%(width)s><source src="%(k)s" />%(t)s</%(p)s>' \
|
||||
% dict(p=p, title=title, width=width, k=k, t=t)
|
||||
alt = ' alt="%s"'%escape(t).replace(META, DISABLED_META) if t else ''
|
||||
@@ -1197,13 +1239,16 @@ def render(text,
|
||||
title = ' title="%s"' % a.replace(META, DISABLED_META) if a else ''
|
||||
target = ' target="_blank"' if p == 'popup' else ''
|
||||
t = render(t, {}, {}, 'br', URL, environment, latex, autolinks,
|
||||
protolinks, class_prefix, id_prefix) if t else k
|
||||
protolinks, class_prefix, id_prefix, pretty_print) if t else k
|
||||
return '<a href="%(k)s"%(title)s%(target)s>%(t)s</a>' \
|
||||
% dict(k=k, title=title, target=target, t=t)
|
||||
if t == 'NEWLINE' and not a:
|
||||
return '<br />'+pp
|
||||
return '<div class="anchor" id="%s">%s</div>' % (escape(id_prefix+t),
|
||||
render(a, {},{},'br', URL,
|
||||
environment, latex, autolinks,
|
||||
protolinks, class_prefix, id_prefix))
|
||||
protolinks, class_prefix,
|
||||
id_prefix, pretty_print))
|
||||
|
||||
parts = text.split(LINK)
|
||||
text = parts[0]
|
||||
@@ -1230,9 +1275,9 @@ def render(text,
|
||||
if code[:1]=='\n': code=code[1:]
|
||||
if code[-1:]=='\n': code=code[:-1]
|
||||
if p:
|
||||
return extra[b](code,p)
|
||||
return str(extra[b](code,p))
|
||||
else:
|
||||
return extra[b](code)
|
||||
return str(extra[b](code))
|
||||
elif b=='cite':
|
||||
return '['+','.join('<a href="#%s" class="%s">%s</a>' \
|
||||
% (d,b,d) \
|
||||
@@ -1241,21 +1286,22 @@ def render(text,
|
||||
return LATEX % code.replace('"','\"').replace('\n',' ')
|
||||
elif b in html_colors:
|
||||
return '<span style="color: %s">%s</span>' \
|
||||
% (b, render(code,{},{},'br',URL,environment,latex,autolinks, protolinks))
|
||||
% (b, render(code, {}, {}, 'br', URL, environment, latex,
|
||||
autolinks, protolinks, class_prefix, id_prefix, pretty_print))
|
||||
elif b in ('c', 'color') and p:
|
||||
c=p.split(':')
|
||||
fg='color: %s;' % c[0] if c[0] else ''
|
||||
bg='background-color: %s;' % c[1] if len(c)>1 and c[1] else ''
|
||||
return '<span style="%s%s">%s</span>' \
|
||||
% (fg, bg, render(code,{},{},'br', URL, environment, latex, autolinks, protolinks))
|
||||
% (fg, bg, render(code, {}, {}, 'br', URL, environment, latex,
|
||||
autolinks, protolinks, class_prefix, id_prefix, pretty_print))
|
||||
cls = ' class="%s%s"'%(class_prefix,b) if b and b != 'id' else ''
|
||||
id = ' id="%s%s"'%(id_prefix,escape(p)) if p else ''
|
||||
beg=(code[:1]=='\n')
|
||||
end=[None,-1][code[-1:]=='\n']
|
||||
if beg and end:
|
||||
return '<pre><code%s%s>%s</code></pre>' % (cls, id, escape(code[1:-1]))
|
||||
return '<pre><code%s%s>%s</code></pre>%s' % (cls, id, escape(code[1:-1]), pp)
|
||||
return '<code%s%s>%s</code>' % (cls, id, escape(code[beg:end]))
|
||||
|
||||
text = regex_expand_meta.sub(expand_meta, text)
|
||||
text = text.translate(ttab_out)
|
||||
|
||||
@@ -1273,9 +1319,16 @@ def render(text,
|
||||
return text
|
||||
|
||||
def markmin2html(text, extra={}, allowed={}, sep='p',
|
||||
autolinks='default',protolinks='default'):
|
||||
autolinks='default', protolinks='default',
|
||||
class_prefix='', id_prefix='markmin_', pretty_print=False):
|
||||
return render(text, extra, allowed, sep,
|
||||
autolinks=autolinks, protolinks=protolinks)
|
||||
autolinks=autolinks, protolinks=protolinks,
|
||||
class_prefix=class_prefix, id_prefix=id_prefix,
|
||||
pretty_print=pretty_print)
|
||||
|
||||
def run_doctests():
|
||||
import doctest
|
||||
doctest.testmod()
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
@@ -1312,7 +1365,9 @@ if __name__ == '__main__':
|
||||
pre { background-color: #E0E0E0; padding: 5px; }
|
||||
</style>""")[1:]
|
||||
|
||||
print html % dict(title="Markmin markup language", style=style, body=markmin2html(__doc__))
|
||||
print html % dict(title="Markmin markup language",
|
||||
style=style,
|
||||
body=markmin2html(__doc__, pretty_print=True))
|
||||
elif sys.argv[1:2] == ['-t']:
|
||||
from timeit import Timer
|
||||
loops=1000
|
||||
@@ -1338,7 +1393,8 @@ if __name__ == '__main__':
|
||||
else:
|
||||
markmin_style = ""
|
||||
|
||||
print html % dict(title=sys.argv[1], style=markmin_style, body=markmin2html(markmin_text))
|
||||
print html % dict(title=sys.argv[1], style=markmin_style,
|
||||
body=markmin2html(markmin_text, pretty_print=True))
|
||||
finally:
|
||||
fargv.close()
|
||||
|
||||
@@ -1348,4 +1404,5 @@ if __name__ == '__main__':
|
||||
print " -t - timeit __doc__ (for testing purpuse only)"
|
||||
print " file.markmin [file.css] - process file.markmin + built in file.css (optional)"
|
||||
print " file.markmin [@path_to/css] - process file.markmin + link path_to/css (optional)"
|
||||
doctest.testmod()
|
||||
run_doctests()
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -39,6 +39,7 @@ class WebClient(object):
|
||||
session_regex = SESSION_REGEX):
|
||||
self.app = app
|
||||
self.postbacks = postbacks
|
||||
self.forms = {}
|
||||
self.history = []
|
||||
self.cookies = {}
|
||||
self.default_headers = default_headers
|
||||
|
||||
@@ -66,12 +66,14 @@ class _BaseImporter(object):
|
||||
help the management of this aspect.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self._STANDARD_PYTHON_IMPORTER = _STANDARD_PYTHON_IMPORTER
|
||||
def __call__(self, name, globals=None, locals=None,
|
||||
fromlist=None, level=-1):
|
||||
"""
|
||||
The import method itself.
|
||||
"""
|
||||
return _STANDARD_PYTHON_IMPORTER(name,
|
||||
return self._STANDARD_PYTHON_IMPORTER(name,
|
||||
globals,
|
||||
locals,
|
||||
fromlist,
|
||||
@@ -226,7 +228,8 @@ class _Web2pyImporter(_BaseImporter):
|
||||
"""
|
||||
|
||||
global DEBUG
|
||||
super(_Web2pyImporter, self).__init__()
|
||||
self.super_class = super(_Web2pyImporter, self)
|
||||
self.super_class.__init__()
|
||||
self.web2py_path = web2py_path
|
||||
self.__web2py_path_os_path_sep = self.web2py_path+os.path.sep
|
||||
self.__web2py_path_os_path_sep_len = len(self.__web2py_path_os_path_sep)
|
||||
@@ -284,16 +287,16 @@ class _Web2pyImporter(_BaseImporter):
|
||||
globals, locals, fromlist, level)
|
||||
else:
|
||||
# import like "from x import a, b, ..."
|
||||
return super(_Web2pyImporter, self) \
|
||||
return self.super_class \
|
||||
.__call__(modules_prefix+"."+name,
|
||||
globals, locals, fromlist, level)
|
||||
except ImportError, e:
|
||||
try:
|
||||
return super(_Web2pyImporter, self).__call__(name, globals, locals,
|
||||
return self.super_class.__call__(name, globals, locals,
|
||||
fromlist, level)
|
||||
except ImportError, e1:
|
||||
raise e
|
||||
return super(_Web2pyImporter, self).__call__(name, globals, locals,
|
||||
return self.super_class.__call__(name, globals, locals,
|
||||
fromlist, level)
|
||||
|
||||
def __import__dot(self, prefix, name, globals, locals, fromlist,
|
||||
|
||||
+340
-280
File diff suppressed because it is too large.
Load diff
+28
-42
@@ -12,13 +12,14 @@ Plural subsystem is created by Vladyslav Kozlovskyy (Ukraine)
|
||||
|
||||
import os
|
||||
import re
|
||||
import pkgutil
|
||||
from utf8 import Utf8
|
||||
from cgi import escape
|
||||
import portalocker
|
||||
import logging
|
||||
import marshal
|
||||
import copy_reg
|
||||
from fileutils import abspath, listdir
|
||||
from fileutils import listdir
|
||||
import settings
|
||||
from cfs import getcfs
|
||||
from thread import allocate_lock
|
||||
@@ -31,6 +32,8 @@ __all__ = ['translator', 'findT', 'update_all_languages']
|
||||
ospath = os.path
|
||||
ostat = os.stat
|
||||
osep = os.sep
|
||||
pjoin = os.path.join
|
||||
pdirname = os.path.dirname
|
||||
isdir = os.path.isdir
|
||||
is_gae = settings.global_settings.web2py_runtime_gae
|
||||
|
||||
@@ -80,7 +83,6 @@ regex_backslash = re.compile(r"\\([\\{}%])")
|
||||
regex_plural = re.compile('%({.+?})')
|
||||
regex_plural_dict = re.compile('^{(?P<w>[^()[\]][^()[\]]*?)\((?P<n>[^()\[\]]+)\)}$') # %%{word(varname or number)}
|
||||
regex_plural_tuple = re.compile('^{(?P<w>[^[\]()]+)(?:\[(?P<i>\d+)\])?}$') # %%{word[index]} or %%{word}
|
||||
regex_plural_rules = re.compile('^plural_rules-[a-zA-Z]{2}(-[a-zA-Z]{2})?\.py$')
|
||||
|
||||
# UTF8 helper functions
|
||||
def upper_fun(s):
|
||||
@@ -213,47 +215,30 @@ def read_possible_languages(appdir):
|
||||
langs['en'] = ('en', 'English', 0)
|
||||
return langs
|
||||
|
||||
def read_global_plural_rules(filename):
|
||||
"""
|
||||
retrieve plural rules from rules/*plural_rules-lang*.py file.
|
||||
|
||||
args:
|
||||
filename (str): plural_rules filename
|
||||
|
||||
returns:
|
||||
(nplurals, get_plural_id, construct_plural_form, status)
|
||||
e.g.: (3, <function>, <function>, ok)
|
||||
"""
|
||||
env = {}
|
||||
data = portalocker.read_locked(filename)
|
||||
try:
|
||||
exec(data) in env
|
||||
status='ok'
|
||||
except Exception, e:
|
||||
status='Syntax error in %s (%s)' % (filename, e)
|
||||
logging.error(status)
|
||||
nplurals = env.get('nplurals', DEFAULT_NPLURALS)
|
||||
get_plural_id = env.get('get_plural_id', DEFAULT_GET_PLURAL_ID)
|
||||
construct_plural_form = env.get('construct_plural_form',
|
||||
DEFAULT_CONSTRUCTOR_PLURAL_FORM)
|
||||
return (nplurals, get_plural_id, construct_plural_form, status)
|
||||
|
||||
|
||||
def read_possible_plurals():
|
||||
"""
|
||||
create list of all possible plural rules files
|
||||
result is cached to increase speed
|
||||
"""
|
||||
pdir = abspath('gluon','contrib','rules')
|
||||
try:
|
||||
import gluon.contrib.plural_rules as package
|
||||
plurals = {}
|
||||
# scan rules directory for plural_rules-*.py files:
|
||||
for pname in os.listdir(pdir):
|
||||
if not isdir(pname) and regex_plural_rules.match(pname):
|
||||
lang = pname[13:-3]
|
||||
fname = ospath.join(pdir, pname)
|
||||
n, f1, f2, status = read_global_plural_rules(fname)
|
||||
if status == 'ok':
|
||||
plurals[lang] = (lang, n, f1, f2, pname)
|
||||
for importer, modname, ispkg in pkgutil.iter_modules(package.__path__):
|
||||
if len(modname)==2:
|
||||
module = __import__(package.__name__+'.'+modname)
|
||||
lang = modname
|
||||
pname = modname+'.py'
|
||||
nplurals = getattr(module,'nplurals', DEFAULT_NPLURALS)
|
||||
get_plural_id = getattr(
|
||||
module,'get_plural_id',
|
||||
DEFAULT_GET_PLURAL_ID)
|
||||
construct_plural_form = getattr(
|
||||
module,'construct_plural_form',
|
||||
DEFAULT_CONSTRUCTOR_PLURAL_FORM)
|
||||
plurals[lang] = (lang, nplurals, get_plural_id,
|
||||
construct_plural_form, pname)
|
||||
except ImportError:
|
||||
logging.warn('Unable to import plural rules')
|
||||
plurals['default'] = ('default',
|
||||
DEFAULT_NPLURALS,
|
||||
DEFAULT_GET_PLURAL_ID,
|
||||
@@ -505,7 +490,7 @@ class translator(object):
|
||||
if int(n)==1:
|
||||
return word
|
||||
elif word:
|
||||
id = min(int(n)-1,1) # self.get_plural_id(abs(int(n)))
|
||||
id = self.get_plural_id(abs(int(n)))
|
||||
# id = 0 first plural form
|
||||
# id = 1 second plural form
|
||||
# etc.
|
||||
@@ -815,8 +800,8 @@ def findT(path, language='en'):
|
||||
"""
|
||||
must be run by the admin app
|
||||
"""
|
||||
filename = ospath.join(path, 'languages', language + '.py')
|
||||
sentences = read_dict(filename)
|
||||
lang_file = ospath.join(path, 'languages', language + '.py')
|
||||
sentences = read_dict(lang_file)
|
||||
mp = ospath.join(path, 'models')
|
||||
cp = ospath.join(path, 'controllers')
|
||||
vp = ospath.join(path, 'views')
|
||||
@@ -845,8 +830,9 @@ def findT(path, language='en'):
|
||||
'en' if language in ('default', 'en') else language)
|
||||
if not '!langname!' in sentences:
|
||||
sentences['!langname!'] = (
|
||||
'English' if language in ('default', 'en') else sentences['!langcode!'])
|
||||
write_dict(filename, sentences)
|
||||
'English' if language in ('default', 'en')
|
||||
else sentences['!langcode!'])
|
||||
write_dict(lang_file, sentences)
|
||||
|
||||
### important to allow safe session.flash=T(....)
|
||||
def lazyT_unpickle(data):
|
||||
|
||||
+16
-29
@@ -30,7 +30,7 @@ import string
|
||||
import urllib2
|
||||
from thread import allocate_lock
|
||||
|
||||
from fileutils import abspath, write_file, parse_version
|
||||
from fileutils import abspath, write_file, parse_version, copystream
|
||||
from settings import global_settings
|
||||
from admin import add_path_first, create_missing_folders, create_missing_app_folders
|
||||
from globals import current
|
||||
@@ -84,7 +84,6 @@ from http import HTTP, redirect
|
||||
from globals import Request, Response, Session
|
||||
from compileapp import build_environment, run_models_in, \
|
||||
run_controller_in, run_view_in
|
||||
from fileutils import copystream, parse_version
|
||||
from contenttype import contenttype
|
||||
from dal import BaseAdapter
|
||||
from settings import global_settings
|
||||
@@ -92,7 +91,8 @@ from validators import CRYPT
|
||||
from cache import Cache
|
||||
from html import URL, xmlescape
|
||||
from utils import is_valid_ip_address
|
||||
from rewrite import load, url_in, thread as rwthread, try_rewrite_on_error
|
||||
from rewrite import load, url_in, thread as rwthread, \
|
||||
try_rewrite_on_error, fixup_missing_path_info
|
||||
import newcron
|
||||
|
||||
__all__ = ['wsgibase', 'save_password', 'appfactory', 'HttpServer']
|
||||
@@ -149,10 +149,11 @@ def copystream_progress(request, chunk_size= 10**5):
|
||||
and stores progress upload status in cache.ram
|
||||
X-Progress-ID:length and X-Progress-ID:uploaded
|
||||
"""
|
||||
if not request.env.content_length:
|
||||
env = request.env
|
||||
if not env.content_length:
|
||||
return cStringIO.StringIO()
|
||||
source = request.env.wsgi_input
|
||||
size = int(request.env.content_length)
|
||||
source = env.wsgi_input
|
||||
size = int(env.content_length)
|
||||
dest = tempfile.TemporaryFile()
|
||||
if not 'X-Progress-ID' in request.vars:
|
||||
copystream(source, dest, size, chunk_size)
|
||||
@@ -275,7 +276,8 @@ def environ_aux(environ,request):
|
||||
def parse_get_post_vars(request, environ):
|
||||
|
||||
# always parse variables in URL for GET, POST, PUT, DELETE, etc. in get_vars
|
||||
dget = cgi.parse_qsl(request.env.query_string or '', keep_blank_values=1)
|
||||
env = request.env
|
||||
dget = cgi.parse_qsl(env.query_string or '', keep_blank_values=1)
|
||||
for (key, value) in dget:
|
||||
if key in request.get_vars:
|
||||
if isinstance(request.get_vars[key], list):
|
||||
@@ -291,7 +293,7 @@ def parse_get_post_vars(request, environ):
|
||||
request.body = body = copystream_progress(request)
|
||||
except IOError:
|
||||
raise HTTP(400,"Bad Request - HTTP body is incomplete")
|
||||
if (body and request.env.request_method in ('POST', 'PUT', 'BOTH')):
|
||||
if (body and env.request_method in ('POST', 'PUT', 'BOTH')):
|
||||
dpost = cgi.FieldStorage(fp=body,environ=environ,keep_blank_values=1)
|
||||
# The same detection used by FieldStorage to detect multipart POSTs
|
||||
is_multipart = dpost.type[:10] == 'multipart/'
|
||||
@@ -383,21 +385,7 @@ def wsgibase(environ, responder):
|
||||
# serve file if static
|
||||
# ##################################################
|
||||
|
||||
eget = environ.get
|
||||
if not eget('PATH_INFO',None) and eget('REQUEST_URI',None):
|
||||
# for fcgi, get path_info and
|
||||
# query_string from request_uri
|
||||
items = environ['REQUEST_URI'].split('?')
|
||||
environ['PATH_INFO'] = items[0]
|
||||
if len(items) > 1:
|
||||
environ['QUERY_STRING'] = items[1]
|
||||
else:
|
||||
environ['QUERY_STRING'] = ''
|
||||
if not eget('HTTP_HOST',None):
|
||||
environ['HTTP_HOST'] = \
|
||||
eget('SERVER_NAME')+':'+eget('SERVER_PORT')
|
||||
|
||||
|
||||
fixup_missing_path_info(environ)
|
||||
(static_file, environ) = url_in(request, environ)
|
||||
|
||||
if static_file:
|
||||
@@ -434,6 +422,7 @@ def wsgibase(environ, responder):
|
||||
is_https = env.wsgi_url_scheme \
|
||||
in ['https', 'HTTPS'] or env.https=='on')
|
||||
request.uuid = request.compute_uuid() # requires client
|
||||
request.url = environ['PATH_INFO']
|
||||
|
||||
# ##################################################
|
||||
# access the requested application
|
||||
@@ -456,9 +445,6 @@ def wsgibase(environ, responder):
|
||||
elif not request.is_local and \
|
||||
exists(pjoin(request.folder,'DISABLED')):
|
||||
raise HTTP(503, "<html><body><h1>Temporarily down for maintenance</h1></body></html>")
|
||||
request.url = URL(r=request,
|
||||
args=request.args,
|
||||
extension=request.raw_extension)
|
||||
|
||||
# ##################################################
|
||||
# build missing folders
|
||||
@@ -488,9 +474,9 @@ def wsgibase(environ, responder):
|
||||
# load cookies
|
||||
# ##################################################
|
||||
|
||||
if request.env.http_cookie:
|
||||
if env.http_cookie:
|
||||
try:
|
||||
request.cookies.load(request.env.http_cookie)
|
||||
request.cookies.load(env.http_cookie)
|
||||
except Cookie.CookieError, e:
|
||||
pass # invalid cookies
|
||||
|
||||
@@ -498,6 +484,7 @@ def wsgibase(environ, responder):
|
||||
# try load session or create new session file
|
||||
# ##################################################
|
||||
|
||||
if not env.web2py_disable_session:
|
||||
session.connect(request, response)
|
||||
|
||||
# ##################################################
|
||||
@@ -562,7 +549,7 @@ def wsgibase(environ, responder):
|
||||
# ##################################################
|
||||
|
||||
if request.cid:
|
||||
rheaders = response.headers
|
||||
rheaders = http_response.headers
|
||||
if response.flash and \
|
||||
not 'web2py-component-flash' in rheaders:
|
||||
rheaders['web2py-component-flash'] = \
|
||||
|
||||
+40
-18
@@ -38,6 +38,7 @@ thread = threading.local() # thread-local storage for routing params
|
||||
regex_at = re.compile(r'(?<!\\)\$[a-zA-Z]\w*')
|
||||
regex_anything = re.compile(r'(?<!\\)\$anything')
|
||||
regex_redirect = re.compile(r'(\d+)->(.*)')
|
||||
regex_full_url = re.compile(r'^(?P<scheme>http|https|HTTP|HTTPS)\://(?P<host>[^/]*)(?P<uri>.*)')
|
||||
|
||||
def _router_default():
|
||||
"return new copy of default base router"
|
||||
@@ -134,6 +135,27 @@ ROUTER_BASE_KEYS = set(
|
||||
# filter_err: helper for doctest & unittest
|
||||
# regex_filter_out: doctest
|
||||
|
||||
def fixup_missing_path_info(environ):
|
||||
eget = environ.get
|
||||
path_info = eget('PATH_INFO')
|
||||
request_uri = eget('REQUEST_URI')
|
||||
if not path_info and request_uri:
|
||||
# for fcgi, get path_info and
|
||||
# query_string from request_uri
|
||||
items = request_uri.split('?')
|
||||
path_info = environ['PATH_INFO'] = items[0]
|
||||
environ['QUERY_STRING'] = items[1] if len(items) > 1 else ''
|
||||
elif not request_uri:
|
||||
query_string = eget('QUERY_STRING')
|
||||
if query_string:
|
||||
environ['REQUEST_URI'] = '%s?%s' % (path_info,query_string)
|
||||
else:
|
||||
environ['REQUEST_URI'] = path_info
|
||||
if not eget('HTTP_HOST'):
|
||||
environ['HTTP_HOST'] = \
|
||||
'%s:%s' % (eget('SERVER_NAME'),eget('SERVER_PORT'))
|
||||
|
||||
|
||||
def url_in(request, environ):
|
||||
"parse and rewrite incoming URL"
|
||||
if routers:
|
||||
@@ -286,8 +308,8 @@ def load(routes='routes.py', app=None, data=None, rdict=None):
|
||||
|
||||
for sym in ('routes_app', 'routes_in', 'routes_out'):
|
||||
if sym in symbols:
|
||||
for (k, v) in symbols[sym]:
|
||||
p[sym].append(compile_regex(k, v))
|
||||
for items in symbols[sym]:
|
||||
p[sym].append(compile_regex(*items))
|
||||
for sym in ('routes_onerror', 'routes_apps_raw',
|
||||
'error_handler','error_message', 'error_message_ticket',
|
||||
'default_application','default_controller', 'default_function',
|
||||
@@ -349,7 +371,7 @@ def load(routes='routes.py', app=None, data=None, rdict=None):
|
||||
log_rewrite('URL rewrite is on. configuration in %s' % path)
|
||||
|
||||
|
||||
def compile_regex(k, v):
|
||||
def compile_regex(k, v, env=None):
|
||||
"""
|
||||
Preprocess and compile the regular expressions in routes_app/in/out
|
||||
The resulting regex will match a pattern of the form:
|
||||
@@ -383,7 +405,7 @@ def compile_regex(k, v):
|
||||
# same for replacement pattern, but with \g
|
||||
for item in regex_at.findall(v):
|
||||
v = v.replace(item, r'\g<%s>' % item[1:])
|
||||
return (re.compile(k, re.DOTALL), v)
|
||||
return (re.compile(k, re.DOTALL), v, env or {})
|
||||
|
||||
def load_routers(all_apps):
|
||||
"load-time post-processing of routers"
|
||||
@@ -497,8 +519,9 @@ def regex_uri(e, regexes, tag, default=None):
|
||||
(e.get('REMOTE_ADDR','localhost'),
|
||||
e.get('wsgi.url_scheme', 'http').lower(), host,
|
||||
e.get('REQUEST_METHOD', 'get').lower(), path)
|
||||
for (regex, value) in regexes:
|
||||
for (regex, value, custom_env) in regexes:
|
||||
if regex.match(key):
|
||||
e.update(custom_env)
|
||||
rewritten = regex.sub(value, key)
|
||||
log_rewrite('%s: [%s] [%s] -> %s' % (tag, key, value, rewritten))
|
||||
return rewritten
|
||||
@@ -686,7 +709,7 @@ def regex_filter_out(url, e=None):
|
||||
e.get('request_method', 'get').lower(), items[0])
|
||||
else:
|
||||
items[0] = ':http://localhost:get %s' % items[0]
|
||||
for (regex, value) in thread.routes.routes_out:
|
||||
for (regex, value, tmp) in thread.routes.routes_out:
|
||||
if regex.match(items[0]):
|
||||
rewritten = '?'.join([regex.sub(value, items[0])] + items[1:])
|
||||
log_rewrite('routes_out: [%s] -> %s' % (url, rewritten))
|
||||
@@ -695,11 +718,14 @@ def regex_filter_out(url, e=None):
|
||||
return url
|
||||
|
||||
|
||||
def filter_url(url, method='get', remote='0.0.0.0', out=False, app=False, lang=None,
|
||||
domain=(None,None), env=False, scheme=None, host=None, port=None):
|
||||
"doctest/unittest interface to regex_filter_in() and regex_filter_out()"
|
||||
regex_url = re.compile(r'^(?P<scheme>http|https|HTTP|HTTPS)\://(?P<host>[^/]*)(?P<uri>.*)')
|
||||
match = regex_url.match(url)
|
||||
def filter_url(url, method='get', remote='0.0.0.0',
|
||||
out=False, app=False, lang=None,
|
||||
domain=(None,None), env=False, scheme=None,
|
||||
host=None, port=None):
|
||||
"""
|
||||
doctest/unittest interface to regex_filter_in() and regex_filter_out()
|
||||
"""
|
||||
match = regex_full_url.match(url)
|
||||
urlscheme = match.group('scheme').lower()
|
||||
urlhost = match.group('host').lower()
|
||||
uri = match.group('uri')
|
||||
@@ -994,6 +1020,7 @@ class MapUrlIn(object):
|
||||
static_file = pjoin(self.request.env.applications_parent,
|
||||
'applications', self.application,
|
||||
'static', file)
|
||||
self.extension = None
|
||||
log_rewrite("route: static=%s" % static_file)
|
||||
return static_file
|
||||
|
||||
@@ -1053,7 +1080,7 @@ class MapUrlIn(object):
|
||||
if self.map_hyphen:
|
||||
uri = uri.replace('_', '-')
|
||||
app = app.replace('_', '-')
|
||||
if self.extension != 'html':
|
||||
if self.extension and self.extension != 'html':
|
||||
uri += '.' + self.extension
|
||||
if self.language:
|
||||
uri = '/%s%s' % (self.language, uri)
|
||||
@@ -1271,19 +1298,14 @@ def map_url_in(request, env, app=False):
|
||||
# handle mapping of lang/static to static/lang in externally-rewritten URLs
|
||||
# in case we have to handle them ourselves
|
||||
if map.languages and map.map_static is False and map.arg0 == 'static' and map.args(1) in map.languages:
|
||||
if 'es' in map.languages:
|
||||
print 'handle static/lang %s' % map.args(1)
|
||||
map.map_controller()
|
||||
map.map_language()
|
||||
else:
|
||||
if 'es' in map.languages:
|
||||
print 'NO handle static/lang %s' % map.args(1)
|
||||
map.map_language()
|
||||
map.map_controller()
|
||||
static_file = map.map_static()
|
||||
if 'es' in map.languages:
|
||||
print 'static_file=%s' % static_file
|
||||
if static_file:
|
||||
map.update_request()
|
||||
return (static_file, map.env)
|
||||
map.map_function()
|
||||
map.validate_args()
|
||||
|
||||
+14
-9
@@ -88,7 +88,7 @@ except:
|
||||
from simplejson import loads, dumps
|
||||
|
||||
|
||||
from gluon import DAL, Field, IS_NOT_EMPTY, IS_IN_SET, IS_NOT_IN_DB
|
||||
from gluon import DAL, Field, IS_NOT_EMPTY, IS_IN_SET, IS_NOT_IN_DB, IS_INT_IN_RANGE
|
||||
from gluon.utils import web2py_uuid
|
||||
|
||||
|
||||
@@ -262,7 +262,8 @@ class MetaScheduler(threading.Thread):
|
||||
|
||||
start = time.time()
|
||||
|
||||
while p.is_alive() and (time.time()-start < task.timeout):
|
||||
while p.is_alive() and (
|
||||
not task.timeout or time.time()-start < task.timeout):
|
||||
if tout:
|
||||
try:
|
||||
logging.debug(' partial output saved')
|
||||
@@ -453,15 +454,20 @@ class Scheduler(MetaScheduler):
|
||||
Field('args','text',default='[]',requires=TYPE(list)),
|
||||
Field('vars','text',default='{}',requires=TYPE(dict)),
|
||||
Field('enabled','boolean',default=True),
|
||||
Field('start_time','datetime',default=now),
|
||||
Field('start_time','datetime',default=now, requires=IS_NOT_EMPTY()),
|
||||
Field('next_run_time','datetime',default=now),
|
||||
Field('stop_time','datetime'),
|
||||
Field('repeats','integer',default=1,comment="0=unlimited"),
|
||||
Field('retry_failed', 'integer', default=0, comment="-1=unlimited"),
|
||||
Field('period','integer',default=60,comment='seconds'),
|
||||
Field('timeout','integer',default=60,comment='seconds'),
|
||||
Field('repeats','integer',default=1,comment="0=unlimited",
|
||||
requires=IS_INT_IN_RANGE(0, None)),
|
||||
Field('retry_failed', 'integer', default=0, comment="-1=unlimited",
|
||||
requires=IS_INT_IN_RANGE(-1, None)),
|
||||
Field('period','integer',default=60,comment='seconds',
|
||||
requires=IS_INT_IN_RANGE(0, None)),
|
||||
Field('timeout','integer',default=60,comment='seconds',
|
||||
requires=IS_INT_IN_RANGE(0, None)),
|
||||
Field('sync_output', 'integer', default=0,
|
||||
comment="update output every n sec: 0=never"),
|
||||
comment="update output every n sec: 0=never",
|
||||
requires=IS_INT_IN_RANGE(0, None)),
|
||||
Field('times_run','integer',default=0,writable=False),
|
||||
Field('times_failed','integer',default=0,writable=False),
|
||||
Field('last_run_time','datetime',writable=False,readable=False),
|
||||
@@ -869,4 +875,3 @@ def main():
|
||||
|
||||
if __name__=='__main__':
|
||||
main()
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
# this file exists for backward compatibility
|
||||
|
||||
__all__ = ['DAL','Field','drivers']
|
||||
__all__ = ['DAL','Field','DRIVERS']
|
||||
|
||||
from dal import DAL, Field, Table, Query, Set, Expression, Row, Rows, drivers, BaseAdapter, SQLField, SQLTable, SQLXorable, SQLQuery, SQLSet, SQLRows, SQLStorage, SQLDB, GQLDB, SQLALL, SQLCustomType
|
||||
from dal import DAL, Field, Table, Query, Set, Expression, Row, Rows, DRIVERS, BaseAdapter, SQLField, SQLTable, SQLXorable, SQLQuery, SQLSet, SQLRows, SQLStorage, SQLDB, GQLDB, SQLALL, SQLCustomType
|
||||
|
||||
|
||||
|
||||
|
||||
+62
-44
@@ -24,7 +24,7 @@ from html import FORM, INPUT, LABEL, OPTION, SELECT, BUTTON
|
||||
from html import TABLE, THEAD, TBODY, TR, TD, TH, STYLE
|
||||
from html import URL, truncate_string, FIELDSET
|
||||
from dal import DAL, Field, Table, Row, CALLABLETYPES, smart_query, \
|
||||
bar_encode, regex_table_field, Reference
|
||||
bar_encode, Reference, REGEX_TABLE_DOT_FIELD
|
||||
from storage import Storage
|
||||
from utils import md5_hash
|
||||
from validators import IS_EMPTY_OR, IS_NOT_EMPTY, IS_LIST_OF, IS_DATE, \
|
||||
@@ -702,17 +702,17 @@ def formstyle_bootstrap(form, fields):
|
||||
_submit = False
|
||||
|
||||
if isinstance(controls, INPUT):
|
||||
controls['_class'] = 'input-xlarge'
|
||||
controls.add_class('input-xlarge')
|
||||
if controls['_type'] == 'submit':
|
||||
# flag submit button
|
||||
_submit = True
|
||||
controls['_class'] = 'btn btn-primary'
|
||||
|
||||
if isinstance(controls, SELECT):
|
||||
controls['_class'] = 'input-xlarge'
|
||||
controls.add_class('input-xlarge')
|
||||
|
||||
if isinstance(controls, TEXTAREA):
|
||||
controls['_class'] = 'input-xlarge'
|
||||
controls.add_class('input-xlarge')
|
||||
|
||||
if isinstance(label, LABEL):
|
||||
label['_class'] = 'control-label'
|
||||
@@ -1376,8 +1376,8 @@ class SQLFORM(FORM):
|
||||
# this should never happen but seems to happen to some
|
||||
del fields['delete_this_record']
|
||||
for field in self.table:
|
||||
if not field.name in fields and field.writable==False \
|
||||
and field.update is None:
|
||||
if not field.name in fields and field.writable is False \
|
||||
and field.update is None and field.compute is None:
|
||||
if record_id and self.record:
|
||||
fields[field.name] = self.record[field.name]
|
||||
elif not self.table[field.name].default is None:
|
||||
@@ -1498,11 +1498,10 @@ class SQLFORM(FORM):
|
||||
selectfields = []
|
||||
for field in fields:
|
||||
name = str(field).replace('.','-')
|
||||
criterion = []
|
||||
options = search_options.get(field.type,None)
|
||||
if options:
|
||||
label = isinstance(field.label,str) and T(field.label) or field.label
|
||||
selectfields.append((str(field),label))
|
||||
selectfields.append(OPTION(label, _value=str(field)))
|
||||
operators = SELECT(*[T(option) for option in options])
|
||||
if field.type=='boolean':
|
||||
value_input = SELECT(
|
||||
@@ -1510,30 +1509,39 @@ class SQLFORM(FORM):
|
||||
OPTION(T("False"),_value="F"),
|
||||
_id="w2p_value_"+name)
|
||||
else:
|
||||
value_input = INPUT(_type='text',_id="w2p_value_"+name,
|
||||
value_input = INPUT(_type='text',
|
||||
_id="w2p_value_"+name,
|
||||
_class=field.type)
|
||||
new_button = INPUT(
|
||||
_type="button", _value=T('New'),_class="btn",
|
||||
_onclick="w2p_build_query('new','"+str(field)+"')")
|
||||
_onclick="w2p_build_query('new','%s')" % field)
|
||||
and_button = INPUT(
|
||||
_type="button", _value=T('And'),_class="btn",
|
||||
_onclick="w2p_build_query('and','"+str(field)+"')")
|
||||
_onclick="w2p_build_query('and','%s')" % field)
|
||||
or_button = INPUT(
|
||||
_type="button", _value=T('Or'),_class="btn",
|
||||
_onclick="w2p_build_query('or','"+str(field)+"')")
|
||||
_onclick="w2p_build_query('or','%s')" % field)
|
||||
close_button = INPUT(
|
||||
_type="button", _value=T('Close'),_class="btn",
|
||||
_onclick="jQuery('#w2p_query_panel').slideUp()")
|
||||
|
||||
criteria.append(DIV(
|
||||
operators,value_input,new_button,
|
||||
and_button,or_button,close_button,
|
||||
_id='w2p_field_%s' % name,
|
||||
_class='w2p_query_row hidden',
|
||||
_style='display:inline'))
|
||||
|
||||
criterion.extend([operators,value_input,new_button,and_button,or_button])
|
||||
criteria.append(DIV(criterion, _id='w2p_field_%s' % name,
|
||||
_class='w2p_query_row hidden'))
|
||||
criteria.insert(0,SELECT(
|
||||
_id="w2p_query_fields",
|
||||
_onchange="jQuery('.w2p_query_row').hide();jQuery('#w2p_field_'+jQuery('#w2p_query_fields').val().replace('.','-')).show();",
|
||||
*[OPTION(label, _value=fname) for fname,label in selectfields]))
|
||||
_style='float:left',
|
||||
*selectfields))
|
||||
|
||||
fadd = SCRIPT("""
|
||||
jQuery('#w2p_query_panel input,#w2p_query_panel select').css(
|
||||
'width','auto').css('float','left');
|
||||
jQuery('#w2p_query_panel input,#w2p_query_panel select').css('width','auto');
|
||||
jQuery(function(){web2py_ajax_fields('#w2p_query_panel');});
|
||||
function w2p_build_query(aggregator,a){
|
||||
function w2p_build_query(aggregator,a) {
|
||||
var b=a.replace('.','-');
|
||||
var option = jQuery('#w2p_field_'+b+' select').val();
|
||||
var value = jQuery('#w2p_value_'+b).val().replace('"','\\\\"');
|
||||
@@ -1541,10 +1549,11 @@ class SQLFORM(FORM):
|
||||
var k=jQuery('#web2py_keywords');
|
||||
var v=k.val();
|
||||
if(aggregator=='new') k.val(s); else k.val((v?(v+' '+ aggregator +' '):'')+s);
|
||||
jQuery('#w2p_query_panel').slideUp();
|
||||
}
|
||||
""")
|
||||
return CAT(DIV(_id="w2p_query_panel",_class='hidden',*criteria),fadd)
|
||||
return CAT(
|
||||
DIV(_id="w2p_query_panel",_class='hidden',*criteria),fadd)
|
||||
|
||||
|
||||
|
||||
@staticmethod
|
||||
@@ -1656,15 +1665,16 @@ class SQLFORM(FORM):
|
||||
if user_signature:
|
||||
if (args != request.args and user_signature and \
|
||||
not URL.verify(request,user_signature=user_signature)) or \
|
||||
(not session.auth.user and \
|
||||
(not (session.auth and session.auth.user) and \
|
||||
('edit' in request.args or \
|
||||
'create' in request.args or \
|
||||
'delete' in request.args)):
|
||||
session.flash = T('not authorized')
|
||||
redirect(referrer)
|
||||
|
||||
def gridbutton(buttonclass='buttonadd',buttontext='Add',
|
||||
buttonurl=url(args=[]),callback=None,delete=None,trap=True):
|
||||
def gridbutton(buttonclass='buttonadd', buttontext='Add',
|
||||
buttonurl=url(args=[]), callback=None,
|
||||
delete=None, trap=True):
|
||||
if showbuttontext:
|
||||
if callback:
|
||||
return A(SPAN(_class=ui.get(buttonclass)),
|
||||
@@ -1826,14 +1836,15 @@ class SQLFORM(FORM):
|
||||
try:
|
||||
dbset = dbset(SQLFORM.build_query(
|
||||
fields,request.vars.get('keywords','')))
|
||||
rows = dbset.select()
|
||||
rows = dbset.select(cacheable=True)
|
||||
except Exception, e:
|
||||
response.flash = T('Internal Error')
|
||||
rows = []
|
||||
else:
|
||||
rows = dbset.select()
|
||||
rows = dbset.select(cacheable=True)
|
||||
else:
|
||||
rows = dbset.select(left=left,orderby=orderby,*columns)
|
||||
rows = dbset.select(left=left,orderby=orderby,
|
||||
cacheable=True*columns)
|
||||
|
||||
if export_type in exportManager:
|
||||
value = exportManager[export_type]
|
||||
@@ -1853,12 +1864,6 @@ class SQLFORM(FORM):
|
||||
|
||||
session['_web2py_grid_referrer_'+formname] = url2(vars=request.vars)
|
||||
console = DIV(_class='web2py_console %(header)s %(cornertop)s' % ui)
|
||||
if create:
|
||||
console.append(gridbutton(
|
||||
buttonclass='buttonadd',
|
||||
buttontext='Add',
|
||||
buttonurl=url(args=['new',tablename])))
|
||||
|
||||
error = None
|
||||
if searchable:
|
||||
sfields = reduce(lambda a,b:a+b,
|
||||
@@ -1867,13 +1872,13 @@ class SQLFORM(FORM):
|
||||
search_widget = search_widget[tablename]
|
||||
if search_widget=='default':
|
||||
search_menu = SQLFORM.search_menu(sfields)
|
||||
search_widget = lambda sfield, url: FORM(
|
||||
search_widget = lambda sfield, url: DIV(FORM(
|
||||
INPUT(_name='keywords',_value=request.vars.keywords,
|
||||
_id='web2py_keywords',_onfocus="jQuery('#w2p_query_fields').change();jQuery('#w2p_query_panel').slideDown();"),
|
||||
INPUT(_type='submit',_value=T('Search'),_class="btn"),
|
||||
INPUT(_type='submit',_value=T('Clear'),_class="btn",
|
||||
_onclick="jQuery('#web2py_keywords').val('');"),
|
||||
search_menu,_method="GET",_action=url)
|
||||
_method="GET",_action=url),search_menu)
|
||||
form = search_widget and search_widget(sfields,url()) or ''
|
||||
console.append(form)
|
||||
keywords = request.vars.get('keywords','')
|
||||
@@ -1887,12 +1892,19 @@ class SQLFORM(FORM):
|
||||
error = T('Invalid query')
|
||||
else:
|
||||
subquery = None
|
||||
if create:
|
||||
console.append(gridbutton(
|
||||
buttonclass='buttonadd',
|
||||
buttontext='Add',
|
||||
buttonurl=url(args=['new',tablename])))
|
||||
|
||||
if subquery:
|
||||
dbset = dbset(subquery)
|
||||
try:
|
||||
if left or groupby:
|
||||
c = 'count(*)'
|
||||
nrows = dbset.select(c,left=left,groupby=groupby).first()[c]
|
||||
nrows = dbset.select(c,left=left,cacheable=True,
|
||||
groupby=groupby).first()[c]
|
||||
else:
|
||||
nrows = dbset.count()
|
||||
except:
|
||||
@@ -1976,7 +1988,9 @@ class SQLFORM(FORM):
|
||||
|
||||
try:
|
||||
table_fields = [f for f in fields if f._tablename in tablenames]
|
||||
rows = dbset.select(left=left,orderby=orderby,groupby=groupby,limitby=limitby,*table_fields)
|
||||
rows = dbset.select(left=left,orderby=orderby,
|
||||
groupby=groupby,limitby=limitby,
|
||||
cacheable=True,*table_fields)
|
||||
except SyntaxError:
|
||||
rows = None
|
||||
error = T("Query Not Supported")
|
||||
@@ -2186,12 +2200,14 @@ class SQLFORM(FORM):
|
||||
LI(A(T(db[referee]._plural),
|
||||
_class=trap_class(),
|
||||
_href=url()),
|
||||
SPAN(divider,_class='divider'),_class='w2p_grid_breadcrumb_elem'))
|
||||
SPAN(divider,_class='divider'),
|
||||
_class='w2p_grid_breadcrumb_elem'))
|
||||
if kwargs.get('details',True):
|
||||
breadcrumbs.append(
|
||||
LI(A(name,_class=trap_class(),
|
||||
_href=url(args=['view',referee,id])),
|
||||
SPAN(divider,_class='divider'),_class='w2p_grid_breadcrumb_elem'))
|
||||
SPAN(divider,_class='divider'),
|
||||
_class='w2p_grid_breadcrumb_elem'))
|
||||
nargs+=2
|
||||
else:
|
||||
break
|
||||
@@ -2217,16 +2233,18 @@ class SQLFORM(FORM):
|
||||
del kwargs[key]
|
||||
check = {}
|
||||
id_field_name = table._id.name
|
||||
for field in table._referenced_by:
|
||||
if field.readable:
|
||||
check[field.tablename] = check.get(field.tablename,[])+[field.name]
|
||||
for rfield in table._referenced_by:
|
||||
if rfield.readable:
|
||||
check[rfield.tablename] = \
|
||||
check.get(rfield.tablename,[])+[rfield.name]
|
||||
for tablename in sorted(check):
|
||||
linked_fieldnames = check[tablename]
|
||||
tb = db[tablename]
|
||||
multiple_links = len(linked_fieldnames)>1
|
||||
for fieldname in linked_fieldnames:
|
||||
if linked_tables is None or tablename in linked_tables:
|
||||
t = T(tb._plural) if not multiple_links else T(tb._plural+'('+fieldname+')')
|
||||
t = T(tb._plural) if not multiple_links else \
|
||||
T(tb._plural+'('+fieldname+')')
|
||||
args0 = tablename+'.'+fieldname
|
||||
links.append(
|
||||
lambda row,t=t,nargs=nargs,args0=args0:\
|
||||
@@ -2560,7 +2578,7 @@ class ExportClass(object):
|
||||
for record in self.rows:
|
||||
row = []
|
||||
for col in self.rows.colnames:
|
||||
if not regex_table_field.match(col):
|
||||
if not REGEX_TABLE_DOT_FIELD.match(col):
|
||||
row.append(record._extra[col])
|
||||
else:
|
||||
(t, f) = col.split('.')
|
||||
|
||||
+1
-1
@@ -136,7 +136,7 @@ class StorageList(Storage):
|
||||
like Storage but missing elements default to [] instead of None
|
||||
"""
|
||||
def __getitem__(self,key):
|
||||
return self.__gteattr__(key)
|
||||
return self.__getattr__(key)
|
||||
def __getattr__(self, key):
|
||||
if key in self:
|
||||
return getattr(self,key)
|
||||
|
||||
@@ -9,4 +9,5 @@ from test_storage import *
|
||||
from test_template import *
|
||||
from test_utils import *
|
||||
from test_contribs import *
|
||||
from test_markmin import *
|
||||
# from test_web import *
|
||||
@@ -411,12 +411,14 @@ class TestMinMaxSum(unittest.TestCase):
|
||||
self.assertEqual(db.t.insert(a=3), 3)
|
||||
s = db.t.a.min()
|
||||
self.assertEqual(db(db.t.id > 0).select(s)[0]._extra[s], 1)
|
||||
self.assertEqual(db(db.t.id > 0).select(s).first()[s], 1)
|
||||
self.assertEqual(db().select(s).first()[s], 1)
|
||||
s = db.t.a.max()
|
||||
self.assertEqual(db(db.t.id > 0).select(s)[0]._extra[s], 3)
|
||||
self.assertEqual(db().select(s).first()[s], 3)
|
||||
s = db.t.a.sum()
|
||||
self.assertEqual(db(db.t.id > 0).select(s)[0]._extra[s], 6)
|
||||
self.assertEqual(db().select(s).first()[s], 6)
|
||||
s = db.t.a.count()
|
||||
self.assertEqual(db(db.t.id > 0).select(s)[0]._extra[s], 3)
|
||||
self.assertEqual(db().select(s).first()[s], 3)
|
||||
db.t.drop()
|
||||
|
||||
|
||||
|
||||
@@ -81,6 +81,10 @@ try:
|
||||
'1 shop')
|
||||
self.assertEqual(str(T('%s %%{shop[0]}', 2)),
|
||||
'2 shops')
|
||||
self.assertEqual(str(T('%s %%{quark[0]}', 1)),
|
||||
'1 quark')
|
||||
self.assertEqual(str(T('%s %%{quark[0]}', 2)),
|
||||
'2 quarks')
|
||||
self.assertEqual(str(T.M('**Hello World**')),
|
||||
'<strong>Hello World</strong>')
|
||||
T.force('it')
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Unit tests for running web2py
|
||||
"""
|
||||
import sys
|
||||
import os
|
||||
if os.path.isdir('gluon'):
|
||||
sys.path.append(os.path.realpath('gluon'))
|
||||
else:
|
||||
sys.path.append(os.path.realpath('../'))
|
||||
|
||||
import unittest
|
||||
from gluon.contrib.markmin.markmin2html import run_doctests
|
||||
|
||||
class TestMarkmin(unittest.TestCase):
|
||||
def testMarkmin(self):
|
||||
run_doctests()
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
@@ -41,6 +41,11 @@ class TestWeb(unittest.TestCase):
|
||||
client.get('index')
|
||||
self.assertTrue('Welcome Homer' in client.text)
|
||||
|
||||
client = WebClient('http://127.0.0.1:8000/admin/default/')
|
||||
client.post('index',data=dict(password='hello'))
|
||||
client.get('site')
|
||||
client.get('design/welcome')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
+18
-11
@@ -839,6 +839,7 @@ class Auth(object):
|
||||
table_event = None,
|
||||
table_cas = None,
|
||||
showid = False,
|
||||
use_username = False,
|
||||
login_email_validate = True,
|
||||
login_userfield = None,
|
||||
logout_onlogout = None,
|
||||
@@ -1250,18 +1251,21 @@ class Auth(object):
|
||||
else:
|
||||
login = A(T('Login'), _href=href('login'))
|
||||
register = A(T('Register'), _href=href('register'))
|
||||
retrieve_username = A(T('Forgot username?'), _href=href('retrieve_username'))
|
||||
lost_password = A(T('Lost password?'), _href=href('request_reset_password'))
|
||||
retrieve_username = A(
|
||||
T('Forgot username?'), _href=href('retrieve_username'))
|
||||
lost_password = A(
|
||||
T('Lost password?'), _href=href('request_reset_password'))
|
||||
bar = SPAN(s1, login, s3, _class='auth_navbar')
|
||||
|
||||
if not 'register' in self.settings.actions_disabled:
|
||||
bar.insert(-1, s2)
|
||||
bar.insert(-1, register)
|
||||
if self.use_username and \
|
||||
not 'retrieve_username' in self.settings.actions_disabled:
|
||||
if self.settings.use_username and not 'retrieve_username' \
|
||||
in self.settings.actions_disabled:
|
||||
bar.insert(-1, s2)
|
||||
bar.insert(-1, retrieve_username)
|
||||
if not 'request_reset_password' in self.settings.actions_disabled:
|
||||
if not 'request_reset_password' \
|
||||
in self.settings.actions_disabled:
|
||||
bar.insert(-1, s2)
|
||||
bar.insert(-1, lost_password)
|
||||
return bar
|
||||
@@ -1353,7 +1357,7 @@ class Auth(object):
|
||||
writable=False,readable=False,
|
||||
label=T('Modified By')))
|
||||
|
||||
def define_tables(self, username=False, signature=None,
|
||||
def define_tables(self, username=None, signature=None,
|
||||
migrate=True, fake_migrate=False):
|
||||
"""
|
||||
to be called unless tables are defined manually
|
||||
@@ -1371,7 +1375,10 @@ class Auth(object):
|
||||
|
||||
db = self.db
|
||||
settings = self.settings
|
||||
self.use_username = username
|
||||
if username is None:
|
||||
username = settings.use_username
|
||||
else:
|
||||
settings.use_username = username
|
||||
if not self.signature:
|
||||
self.define_signature()
|
||||
if signature==True:
|
||||
@@ -1612,12 +1619,12 @@ class Auth(object):
|
||||
checks = []
|
||||
# make a guess about who this user is
|
||||
for fieldname in ['registration_id','username','email']:
|
||||
if fieldname in table_user.fields() and keys.get(fieldname,None):
|
||||
if fieldname in table_user.fields() and \
|
||||
keys.get(fieldname,None):
|
||||
checks.append(fieldname)
|
||||
value = keys[fieldname]
|
||||
user = user or table_user._db(
|
||||
(table_user.registration_id==value)|
|
||||
(table_user[fieldname]==value)).select().first()
|
||||
user = table_user(**{fieldname:value})
|
||||
if user: break
|
||||
if not checks:
|
||||
return None
|
||||
if not 'registration_id' in keys:
|
||||
|
||||
+23
-20
@@ -1376,6 +1376,7 @@ class IS_GENERIC_URL(Validator):
|
||||
|
||||
"""
|
||||
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
error_message='enter a valid URL',
|
||||
@@ -1402,6 +1403,9 @@ class IS_GENERIC_URL(Validator):
|
||||
"prepend_scheme='%s' is not in allowed_schemes=%s" \
|
||||
% (self.prepend_scheme, self.allowed_schemes)
|
||||
|
||||
GENERIC_URL = re.compile(r"%[^0-9A-Fa-f]{2}|%[^0-9A-Fa-f][0-9A-Fa-f]|%[0-9A-Fa-f][^0-9A-Fa-f]|%$|%[0-9A-Fa-f]$|%[^0-9A-Fa-f]$")
|
||||
GENERIC_URL_VALID = re.compile(r"[A-Za-z0-9;/?:@&=+$,\-_\.!~*'\(\)%#]+$")
|
||||
|
||||
def __call__(self, value):
|
||||
"""
|
||||
:param value: a string, the URL to validate
|
||||
@@ -1411,12 +1415,9 @@ class IS_GENERIC_URL(Validator):
|
||||
"""
|
||||
try:
|
||||
# if the URL does not misuse the '%' character
|
||||
if not re.compile(
|
||||
r"%[^0-9A-Fa-f]{2}|%[^0-9A-Fa-f][0-9A-Fa-f]|%[0-9A-Fa-f][^0-9A-Fa-f]|%$|%[0-9A-Fa-f]$|%[^0-9A-Fa-f]$"
|
||||
).search(value):
|
||||
if not self.GENERIC_URL.search(value):
|
||||
# if the URL is only composed of valid characters
|
||||
if re.compile(
|
||||
r"[A-Za-z0-9;/?:@&=+$,\-_\.!~*'\(\)%#]+$").match(value):
|
||||
if self.GENERIC_URL_VALID.match(value):
|
||||
# Then split up the URL into its components and check on
|
||||
# the scheme
|
||||
scheme = url_split_regex.match(value).group(2)
|
||||
@@ -1432,11 +1433,10 @@ class IS_GENERIC_URL(Validator):
|
||||
# ports, check to see if adding a valid scheme fixes
|
||||
# the problem (but only do this if it doesn't have
|
||||
# one already!)
|
||||
if not re.compile('://').search(value) and None\
|
||||
in self.allowed_schemes:
|
||||
if value.find('://')<0 and None in self.allowed_schemes:
|
||||
schemeToUse = self.prepend_scheme or 'http'
|
||||
prependTest = self.__call__(schemeToUse
|
||||
+ '://' + value)
|
||||
prependTest = self.__call__(
|
||||
schemeToUse + '://' + value)
|
||||
# if the prepend test succeeded
|
||||
if prependTest[1] is None:
|
||||
# if prepending in the output is enabled
|
||||
@@ -1791,6 +1791,9 @@ class IS_HTTP_URL(Validator):
|
||||
|
||||
"""
|
||||
|
||||
GENERIC_VALID_IP = re.compile("([\w.!~*'|;:&=+$,-]+@)?\d+\.\d+\.\d+\.\d+(:\d*)*$")
|
||||
GENERIC_VALID_DOMAIN = re.compile("([\w.!~*'|;:&=+$,-]+@)?(([A-Za-z0-9]+[A-Za-z0-9\-]*[A-Za-z0-9]+\.)*([A-Za-z0-9]+\.)*)*([A-Za-z]+[A-Za-z0-9\-]*[A-Za-z0-9]+)\.?(:\d*)*$")
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
error_message='enter a valid URL',
|
||||
@@ -1843,16 +1846,12 @@ class IS_HTTP_URL(Validator):
|
||||
# if there is an authority component
|
||||
if authority:
|
||||
# if authority is a valid IP address
|
||||
if re.compile(
|
||||
"([\w.!~*'|;:&=+$,-]+@)?\d+\.\d+\.\d+\.\d+(:\d*)*$").match(authority):
|
||||
if self.GENERIC_VALID_IP.match(authority):
|
||||
# Then this HTTP URL is valid
|
||||
return (value, None)
|
||||
else:
|
||||
# else if authority is a valid domain name
|
||||
domainMatch = \
|
||||
re.compile(
|
||||
"([\w.!~*'|;:&=+$,-]+@)?(([A-Za-z0-9]+[A-Za-z0-9\-]*[A-Za-z0-9]+\.)*([A-Za-z0-9]+\.)*)*([A-Za-z]+[A-Za-z0-9\-]*[A-Za-z0-9]+)\.?(:\d*)*$"
|
||||
).match(authority)
|
||||
domainMatch = self.GENERIC_VALID_DOMAIN.match(authority)
|
||||
if domainMatch:
|
||||
# if the top-level domain really exists
|
||||
if domainMatch.group(5).lower()\
|
||||
@@ -1865,13 +1864,13 @@ class IS_HTTP_URL(Validator):
|
||||
path = componentsMatch.group(5)
|
||||
# relative case: if this is a valid path (if it starts with
|
||||
# a slash)
|
||||
if re.compile('/').match(path):
|
||||
if path.startswith('/'):
|
||||
# Then this HTTP URL is valid
|
||||
return (value, None)
|
||||
else:
|
||||
# abbreviated case: if we haven't already, prepend a
|
||||
# scheme and see if it fixes the problem
|
||||
if not re.compile('://').search(value):
|
||||
if value.find('://')<0:
|
||||
schemeToUse = self.prepend_scheme or 'http'
|
||||
prependTest = self.__call__(schemeToUse
|
||||
+ '://' + value)
|
||||
@@ -2521,9 +2520,11 @@ class CLEANUP(Validator):
|
||||
|
||||
removes special characters on validation
|
||||
"""
|
||||
REGEX_CLEANUP = re.compile('[^\x09\x0a\x0d\x20-\x7e]')
|
||||
|
||||
def __init__(self, regex='[^\x09\x0a\x0d\x20-\x7e]'):
|
||||
self.regex = re.compile(regex)
|
||||
def __init__(self, regex=None):
|
||||
self.regex = self.REGEX_CLEANUP if regex is None \
|
||||
else re.compile(regex)
|
||||
|
||||
def __call__(self, value):
|
||||
v = self.regex.sub('',str(value).strip())
|
||||
@@ -2790,11 +2791,13 @@ class IS_STRONG(object):
|
||||
|
||||
class IS_IN_SUBSET(IS_IN_SET):
|
||||
|
||||
REGEX_W = re.compile('\w+')
|
||||
|
||||
def __init__(self, *a, **b):
|
||||
IS_IN_SET.__init__(self, *a, **b)
|
||||
|
||||
def __call__(self, value):
|
||||
values = re.compile("\w+").findall(str(value))
|
||||
values = self.REGEX_W.findall(str(value))
|
||||
failures = [x for x in values if IS_IN_SET.__call__(self, x)[1]]
|
||||
if failures:
|
||||
return (value, translate(self.error_message))
|
||||
|
||||
+2
-2
@@ -1004,9 +1004,9 @@ def start(cron=True):
|
||||
print ProgramAuthor
|
||||
print ProgramVersion
|
||||
|
||||
from dal import drivers
|
||||
from dal import DRIVERS
|
||||
if not options.nobanner:
|
||||
print 'Database drivers available: %s' % ', '.join(drivers)
|
||||
print 'Database drivers available: %s' % ', '.join(DRIVERS)
|
||||
|
||||
|
||||
# ## if -L load options from options.config file
|
||||
|
||||
+15
-10
@@ -27,12 +27,14 @@
|
||||
# set by the setLevel call, the [logger_myapp] section, and the [handler_...]
|
||||
# section. For example, you will not see DEBUG messages unless all three are
|
||||
# set to DEBUG.
|
||||
#
|
||||
# Available levels: DEBUG INFO WARNING ERROR CRITICAL
|
||||
|
||||
[loggers]
|
||||
keys=root,rocket,markdown,web2py,rewrite,cron,app,welcome
|
||||
|
||||
[handlers]
|
||||
keys=consoleHandler,messageBoxHandler
|
||||
keys=consoleHandler,messageBoxHandler,rotatingFileHandler
|
||||
#keys=consoleHandler,rotatingFileHandler
|
||||
#keys=osxSysLogHandler
|
||||
|
||||
@@ -41,50 +43,53 @@ keys=simpleFormatter
|
||||
|
||||
[logger_root]
|
||||
level=WARNING
|
||||
handlers=consoleHandler
|
||||
handlers=consoleHandler,rotatingFileHandler
|
||||
|
||||
[logger_web2py]
|
||||
level=WARNING
|
||||
handlers=consoleHandler
|
||||
handlers=consoleHandler,rotatingFileHandler
|
||||
qualname=web2py
|
||||
propagate=0
|
||||
|
||||
# URL rewrite logging (routes.py)
|
||||
# See also the logging parameter in routes.py
|
||||
#
|
||||
[logger_rewrite]
|
||||
level=WARNING
|
||||
qualname=web2py.rewrite
|
||||
handlers=consoleHandler
|
||||
handlers=consoleHandler,rotatingFileHandler
|
||||
propagate=0
|
||||
|
||||
[logger_cron]
|
||||
level=WARNING
|
||||
qualname=web2py.cron
|
||||
handlers=consoleHandler
|
||||
handlers=consoleHandler,rotatingFileHandler
|
||||
propagate=0
|
||||
|
||||
# generic app handler
|
||||
[logger_app]
|
||||
level=WARNING
|
||||
qualname=web2py.app
|
||||
handlers=consoleHandler
|
||||
handlers=consoleHandler,rotatingFileHandler
|
||||
propagate=0
|
||||
|
||||
# welcome app handler
|
||||
[logger_welcome]
|
||||
level=WARNING
|
||||
qualname=web2py.app.welcome
|
||||
qualname=web2py.app.welcome,rotatingFileHandler
|
||||
handlers=consoleHandler
|
||||
propagate=0
|
||||
|
||||
# loggers for legacy getLogger calls: Rocket and markdown
|
||||
[logger_rocket]
|
||||
level=WARNING
|
||||
handlers=consoleHandler,messageBoxHandler
|
||||
handlers=consoleHandler,messageBoxHandler,rotatingFileHandler
|
||||
qualname=Rocket
|
||||
propagate=0
|
||||
|
||||
[logger_markdown]
|
||||
level=WARNING
|
||||
handlers=consoleHandler
|
||||
handlers=consoleHandler,rotatingFileHandler
|
||||
qualname=markdown
|
||||
propagate=0
|
||||
|
||||
@@ -106,7 +111,7 @@ args=()
|
||||
#
|
||||
[handler_rotatingFileHandler]
|
||||
class=handlers.RotatingFileHandler
|
||||
level=INFO
|
||||
level=DEBUG
|
||||
formatter=simpleFormatter
|
||||
args=("logs/web2py.log", "a", 1000000, 5)
|
||||
|
||||
|
||||
@@ -26,10 +26,8 @@ administrator_email = 'you@localhost'
|
||||
|
||||
while 1:
|
||||
for file in os.listdir(path):
|
||||
filename = os.path.join(path, file)
|
||||
|
||||
if not ALLOW_DUPLICATES:
|
||||
fileobj = open(filename, 'r')
|
||||
fileobj = open(file, 'r')
|
||||
try:
|
||||
file_data = fileobj.read()
|
||||
finally:
|
||||
@@ -42,10 +40,10 @@ while 1:
|
||||
hashes[key] = 1
|
||||
|
||||
error = RestrictedError()
|
||||
error.load(request, request.application, filename)
|
||||
error.load(request, request.application, file)
|
||||
|
||||
mail.send(to=administrator_email, subject='new web2py ticket', message=error.traceback)
|
||||
|
||||
os.unlink(filename)
|
||||
os.unlink(os.path.join(path, file))
|
||||
time.sleep(SLEEP_MINUTES * 60)
|
||||
|
||||
@@ -12,7 +12,7 @@ else: #should never happen
|
||||
path = os.getcwd()
|
||||
os.chdir(path)
|
||||
|
||||
sys.path = [path]+[p for p in sys.path if not p==path]
|
||||
sys.path = [path]+[p for p in sys.path if not p == path]
|
||||
|
||||
# import gluon.import_all ##### This should be uncommented for py2exe.py
|
||||
import gluon.widget
|
||||
|
||||
Reference in new issue
Block a user