Merge github.com:web2py/web2py

This commit is contained in:
Michele Comitini committed 2012-09-04 22:37:20 +02:00
commit f42984612f
16 files changed
+222 -129

No files matched your search

+1 -1
View File
@@ -29,7 +29,7 @@ update:
wget -O gluon/contrib/simplejsonrpc.py http://rad2py.googlecode.com/hg/ide2py/simplejsonrpc.py wget -O gluon/contrib/simplejsonrpc.py http://rad2py.googlecode.com/hg/ide2py/simplejsonrpc.py
echo "remember that pymysql was tweaked" echo "remember that pymysql was tweaked"
src: src:
echo 'Version 2.0.6 ('`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 ### rm -f all junk files
make clean make clean
### clean up baisc apps ### clean up baisc apps
+1 -1
View File
@@ -1 +1 @@
Version 2.0.6 (2012-09-02 12:26:12) stable Version 2.0.7 (2012-09-04 15:32:23) stable
@@ -249,6 +249,10 @@ def site():
fname = request.vars.file.filename fname = request.vars.file.filename
f = request.vars.file.file f = request.vars.file.file
else:
session.flash = 'No file uploaded and no URL specified'
redirect(URL(r=request))
if f: if f:
appname = cleanpath(form_update.vars.name) appname = cleanpath(form_update.vars.name)
installed = app_install(appname, f, installed = app_install(appname, f,
+4
View File
@@ -16,6 +16,8 @@
'are not used yet': 'are not used yet', '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?', 'Are you sure you want to delete this object?': 'Are you sure you want to delete this object?',
'arguments': 'arguments', 'arguments': 'arguments',
'at char %s': 'at char %s',
'at line %s': 'at line %s',
'back': '<<back', 'back': '<<back',
'can be a git repo': 'can be a git repo', 'can be a git repo': 'can be a git repo',
'Change admin password': 'Change admin password', 'Change admin password': 'Change admin password',
@@ -58,6 +60,7 @@
'exposes': 'exposes', 'exposes': 'exposes',
'exposes:': 'exposes:', 'exposes:': 'exposes:',
'extends': 'extends', 'extends': 'extends',
'failed to compile file because:': 'failed to compile file because:',
'file does not exist': 'file does not exist', 'file does not exist': 'file does not exist',
'file saved on %s': 'file saved on %s', 'file saved on %s': 'file saved on %s',
'filter': 'filter', 'filter': 'filter',
@@ -87,6 +90,7 @@
'modules': 'modules', 'modules': 'modules',
'New application wizard': 'New application wizard', 'New application wizard': 'New application wizard',
'New simple application': 'New simple application', 'New simple application': 'New simple application',
'online designer': 'online designer',
'Overwrite installed app': 'Overwrite installed app', 'Overwrite installed app': 'Overwrite installed app',
'Pack all': 'Pack all', 'Pack all': 'Pack all',
'Peeking at file': 'Peeking at file', 'Peeking at file': 'Peeking at file',
@@ -2,7 +2,9 @@
<h2>web2py&trade; {{=T('Web Framework')}}</h2> <h2>web2py&trade; {{=T('Web Framework')}}</h2>
<h3>{{=T('Login to the Administrative Interface')}}</h3> <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"> <form action="{{=URL(r=request)}}" method="post">
<div><input type="hidden" name="send" value="{{=send}}"/></div> <div><input type="hidden" name="send" value="{{=send}}"/></div>
<table> <table>
@@ -11,4 +13,6 @@
</table> </table>
</form> </form>
</div> </div>
{{else:}}
<p class="help">{{=T('ATTENTION: Login requires a secure (HTTPS) connection or running on localhost.')}}</p>
{{pass}}
+81 -30
View File
@@ -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="">&gt;&gt;&gt; m = "Hello **world** [[link http://web2py.com]]" <!doctype html>
&gt;&gt;&gt; from markmin2html import markmin2html <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
&gt;&gt;&gt; print markmin2html(m) <head>
&gt;&gt;&gt; from markmin2latex import markmin2latex <meta http-equiv="content-type" content="text/html; charset=utf-8" />
&gt;&gt;&gt; print markmin2latex(m) <style>
&gt;&gt;&gt; from markmin2pdf import markmin2pdf # requires pdflatex blockquote { background-color: #FFFAAE; padding: 7px; }
&gt;&gt;&gt; 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> table { border-collapse: collapse; }
<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. thead td { border-bottom: 1px solid; }
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" /> tfoot td { border-top: 1px solid; }
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 .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 - 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 + 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 + 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
<pre><code class="">--------- -- 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** **A**|**B**|**C**
=================
0 | 0 | X 0 | 0 | X
0 | X | 0 0 | X | 0
X | 0 | 0 X | 0 | 0
-----:abc</code></pre> =================
is a table and is rendered as **D**|**F**|**G**
<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. -----------------: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>-----
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> This is a paragraph in a blockquote
<h3>Code, <code class="">&lt;code&gt;</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 !`!. + item 1
The <code class="">:python</code> after the markup is also optional. If present, by default, it is used to set the class of the &lt;code&gt; block. + item 2
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">&gt;&gt;&gt; markmin2html("``aaa``:custom", -- item 2.1
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 &lt;video&gt; and &lt;audio&gt; html5 tags using the notation: -- item 2.2
<pre><code class="">[[title link video]] + item 3
[[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="">&gt;&gt;&gt; LATEX = '&lt;img src="http://chart.apis.google.com/chart?cht=tx&amp;chl=%s" align="center"/&gt;' ---------
&gt;&gt;&gt; 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="">&gt;&gt;&gt; extra={'code_cpp':lambda text: CODE(text,language='cpp').xml(), 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>&lt;code&gt;</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 &lt;code&gt; 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 &lt;video&gt; and &lt;audio&gt; 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 = '&lt;img src="http://chart.apis.google.com/chart?cht=tx&amp;chl=%s" /&gt;'
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_java':lambda text: CODE(text,language='java').xml(),
'code_python':lambda text: CODE(text,language='python').xml(), 'code_python':lambda text: CODE(text,language='python').xml(),
'code_html':lambda text: CODE(text,language='html').xml()} '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>``
&gt;&gt;&gt; markmin2html(text,extra=extra)</code></pre><p>Code can now be marked up as in this example:</p><pre><code class="">``
&lt;html&gt;&lt;body&gt;example&lt;/body&gt;&lt;/html&gt; &lt;html&gt;&lt;body&gt;example&lt;/body&gt;&lt;/html&gt;
``: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>``
&lt;html&gt;&lt;body&gt;example&lt;/body&gt;&lt;/html&gt;
``: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 ## References
- [[mdipierro]] web2py Manual, 3rd Edition, lulu.com</code></pre><h3>Caveats</h3><p><code class="">&lt;ul/&gt;</code>, <code class="">&lt;ol/&gt;</code>, <code class="">&lt;code/&gt;</code>, <code class="">&lt;table/&gt;</code>, <code class="">&lt;blockquote/&gt;</code>, <code class="">&lt;h1/&gt;</code>, ..., <code class="">&lt;h6/&gt;</code> do not have <code class="">&lt;p&gt;...&lt;/p&gt;</code> around them.</p></body></html>
- [[mdipierro]] web2py Manual, 3rd Edition, lulu.com</code></pre><h3>Caveats</h3><p><code>&lt;ul/&gt;</code>, <code>&lt;ol/&gt;</code>, <code>&lt;code/&gt;</code>, <code>&lt;table/&gt;</code>, <code>&lt;blockquote/&gt;</code>, <code>&lt;h1/&gt;</code>, ..., <code>&lt;h6/&gt;</code> do not have <code>&lt;p&gt;...&lt;/p&gt;</code> around them.</p>
</body>
</html>
+5
View File
@@ -60,6 +60,7 @@
'edit profile': 'modifica profilo', 'edit profile': 'modifica profilo',
'Edit This App': 'Modifica questa applicazione', 'Edit This App': 'Modifica questa applicazione',
'Email and SMS': 'Email and SMS', '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', 'enter an integer between %(min)g and %(max)g': 'enter an integer between %(min)g and %(max)g',
'Errors': 'Errors', 'Errors': 'Errors',
'export as csv file': 'esporta come file CSV', 'export as csv file': 'esporta come file CSV',
@@ -95,6 +96,7 @@
'Layouts': 'Layouts', 'Layouts': 'Layouts',
'Live Chat': 'Live Chat', 'Live Chat': 'Live Chat',
'Logged in': 'Logged in', 'Logged in': 'Logged in',
'Logged out': 'Logged out',
'login': 'accesso', 'login': 'accesso',
'Login': 'Login', 'Login': 'Login',
'logout': 'uscita', 'logout': 'uscita',
@@ -113,6 +115,7 @@
'new record inserted': 'nuovo record inserito', 'new record inserted': 'nuovo record inserito',
'next 100 rows': 'prossime 100 righe', 'next 100 rows': 'prossime 100 righe',
'No databases in this application': 'Nessun database presente in questa applicazione', 'No databases in this application': 'Nessun database presente in questa applicazione',
'Non può essere vuoto': 'Non può essere vuoto',
'not authorized': 'non autorizzato', 'not authorized': 'non autorizzato',
'Object or table name': 'Object or table name', 'Object or table name': 'Object or table name',
'Online examples': 'Vedere gli esempi', 'Online examples': 'Vedere gli esempi',
@@ -166,12 +169,14 @@
'This App': 'This App', 'This App': 'This App',
'This is a copy of the scaffolding application': "Questa è una copia dell'applicazione di base (scaffold)", 'This is a copy of the scaffolding application': "Questa è una copia dell'applicazione di base (scaffold)",
'Timestamp': 'Ora (timestamp)', 'Timestamp': 'Ora (timestamp)',
'too short': 'too short',
'Twitter': 'Twitter', 'Twitter': 'Twitter',
'unable to parse csv file': 'non riesco a decodificare questo file CSV', 'unable to parse csv file': 'non riesco a decodificare questo file CSV',
'Update': 'Update', 'Update': 'Update',
'Update:': 'Aggiorna:', '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).', '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-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)s Registered': 'User %(id)s Registered',
'User ID': 'ID Utente', 'User ID': 'ID Utente',
'Verify Password': 'Verify Password', 'Verify Password': 'Verify Password',
+2 -9
View File
@@ -15,9 +15,9 @@ td,th {text-align:left; padding:2px 5px 2px 5px}
th {vertical-align:middle; border-right:1px solid white} th {vertical-align:middle; border-right:1px solid white}
td {vertical-align:top} td {vertical-align:top}
form table tr td label {text-align:left} 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} p {text-align:justify}
ol, ul {list-style-position:inside} ol, ul {list-style-position:outside; margin-left:2em}
li {margin-bottom:0.5em} li {margin-bottom:0.5em}
span,input,select,textarea,button,label,a {display:inline} span,input,select,textarea,button,label,a {display:inline}
img {border:0} img {border:0}
@@ -39,13 +39,6 @@ input[type=text],input[type=password],select{width:300px; margin-right:5px}
/* Sticky footer begin */ /* 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 { .main {
padding:20px 0 50px 0; padding:20px 0 50px 0;
} }
+1 -1
View File
@@ -129,7 +129,7 @@
</section><!--/main--> </section><!--/main-->
<!-- Footer ================================================== --> <!-- Footer ================================================== -->
<footer class="footer"> <footer class="footer" id="footer">
{{block footer}} <!-- this is default footer --> {{block footer}} <!-- this is default footer -->
<div class="footer-content"> <div class="footer-content">
<div class="copyright pull-left">{{=T('Copyright')}} &#169; {{=request.now.year}}</div> <div class="copyright pull-left">{{=T('Copyright')}} &#169; {{=request.now.year}}</div>
+3
View File
@@ -92,11 +92,14 @@ _TEST()
""" """
CACHED_REGEXES = {} CACHED_REGEXES = {}
CACHED_REGEXES_MAX_SIZE = 1000
def re_compile(regex): def re_compile(regex):
try: try:
return CACHED_REGEXES[regex] return CACHED_REGEXES[regex]
except KeyError: except KeyError:
if len(CACHED_REGEXES) >= CACHED_REGEXES_MAX_SIZE:
CACHED_REGEXES.clear()
compiled_regex = CACHED_REGEXES[regex] = re.compile(regex) compiled_regex = CACHED_REGEXES[regex] = re.compile(regex)
return compiled_regex return compiled_regex
+15 -12
View File
@@ -544,6 +544,7 @@ regex_list=re.compile('^(?:(?:(#{1,6})|(?:(\.+|\++|\-+)(\.)?))\s+)?(.*)$')
regex_bq_headline=re.compile('^(?:(\.+|\++|\-+)(\.)?\s+)?(-{3}-*)$') 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_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_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_auto = re.compile(r'(?<!["\w>/=])(?P<k>\w+://[\w\d\-+_=?%&/:.]+)',re.M)
regex_link=re.compile(r'('+LINK+r')|\[\[(?P<s>.+?)\]\]') 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_link_level2=re.compile(r'^(?P<t>\S.*?)?(?:\s+\[(?P<a>.+?)\])?(?:\s+(?P<k>\S+))?(?:\s+(?P<p>popup))?\s*$')
@@ -620,7 +621,7 @@ def render(text,
- class_prefix is a prefix for ALL classes in markmin text. E.g. if class_prefix='my_' - class_prefix is a prefix for ALL classes in markmin text. E.g. if class_prefix='my_'
then for ``test``:cls class will be changed to "my_cls" (default value is '') then for ``test``:cls class will be changed to "my_cls" (default value is '')
- id_prefix is prefix for ALL ids in markmin text (default value is 'markmin_'). E.g.: - id_prefix is prefix for ALL ids in markmin text (default value is 'markmin_'). E.g.:
-- [[id]] will be converted to <a name="markmin_id"></a> -- [[id]] will be converted to <div class="anchor" id="markmin_id"></div>
-- [[link #id]] will be converted to <a href="#markmin_id">link</a> -- [[link #id]] will be converted to <a href="#markmin_id">link</a>
-- ``test``:cls[id] will be converted to <code class="cls" id="markmin_id">test</code> -- ``test``:cls[id] will be converted to <code class="cls" id="markmin_id">test</code>
@@ -837,17 +838,6 @@ def render(text,
args=args.split('/'), scheme=True, host=True) args=args.split('/'), scheme=True, host=True)
text = regex_URL.sub(u1,text) text = regex_URL.sub(u1,text)
if environment:
def u2(match, environment=environment):
f = environment.get(match.group('a'), match.group(0))
if callable(f):
try:
f = f(match.group('b'))
except Exception, e:
f = 'ERROR: %s' % e
return str(f)
text = regex_env.sub(u2, text)
if latex == 'google': if latex == 'google':
text = regex_dd.sub('``\g<latex>``:latex ', text) text = regex_dd.sub('``\g<latex>``:latex ', text)
@@ -1314,6 +1304,18 @@ def render(text,
return '<code%s%s>%s</code>' % (cls, id, escape(code[beg:end])) return '<code%s%s>%s</code>' % (cls, id, escape(code[beg:end]))
text = regex_expand_meta.sub(expand_meta, text) text = regex_expand_meta.sub(expand_meta, text)
text = text.translate(ttab_out) text = text.translate(ttab_out)
if environment:
def u2(match, environment=environment):
f = environment.get(match.group('a'), match.group(0))
if callable(f):
try:
f = f(match.group('b'))
except Exception, e:
f = 'ERROR: %s' % e
return str(f)
text = regex_env.sub(u2, text)
return text return text
def markmin2html(text, extra={}, allowed={}, sep='p', def markmin2html(text, extra={}, allowed={}, sep='p',
@@ -1403,3 +1405,4 @@ if __name__ == '__main__':
print " file.markmin [file.css] - process file.markmin + built in file.css (optional)" 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)" print " file.markmin [@path_to/css] - process file.markmin + link path_to/css (optional)"
run_doctests() run_doctests()
+35 -18
View File
@@ -2379,9 +2379,9 @@ class PostgreSQLAdapter(BaseAdapter):
if self.driver_name == 'psycopg2': if self.driver_name == 'psycopg2':
return psycopg2_adapt(obj).getquoted() return psycopg2_adapt(obj).getquoted()
elif self.driver_name == 'pg8000': elif self.driver_name == 'pg8000':
return str(obj).replace("%","%%").replace("'","''") return "'%s'" % str(obj).replace("%","%%").replace("'","''")
else: else:
return str(obj).replace("'","''") return "'%s'" % str(obj).replace("'","''")
def sequence_name(self,table): def sequence_name(self,table):
return '%s_id_Seq' % table return '%s_id_Seq' % table
@@ -6460,7 +6460,7 @@ class Row(object):
return '<Row %s>' % self.__dict__ return '<Row %s>' % self.__dict__
def __int__(self): def __int__(self):
return dict.__getitem__(self,'id') return object.__getattribute__(self,'id')
def __eq__(self,other): def __eq__(self,other):
try: try:
@@ -7198,21 +7198,34 @@ def index():
[{field1: value1, field2: value2}, {field1: value1b, field2: value2b}] [{field1: value1, field2: value2}, {field1: value1b, field2: value2b}]
Added 2012-08-24 "fields" optional argument. If not None, the Added 2012-08-24 "fields" and "colnames" optional arguments. If either
results cursor returned by the DB driver will be converted to a is provided, the results cursor returned by the DB driver will be
DAL Rows object using the db._adapter.parse() method. This requires converted to a DAL Rows object using the db._adapter.parse() method.
specifying the "fields" argument as a list of DAL Field objects
that match the fields returned from the DB. The Field objects should
be part of one or more Table objects defined on the DAL object.
The "fields" list can include one or more DAL Table objects in addition
to or instead of including Field objects, or it can be just a single
table (not in a list). In that case, the Field objects will be
extracted from the table(s).
The field names will be extracted from the Field objects, or optionally, The "fields" argument is a list of DAL Field objects that match the
a list of field names can be provided (in tablename.fieldname format) fields returned from the DB. The Field objects should be part of one or
via the "colnames" argument. Note, the fields and colnames must be in more Table objects defined on the DAL object. The "fields" list can
the same order as the fields in the results cursor returned from the DB. include one or more DAL Table objects in addition to or instead of
including Field objects, or it can be just a single table (not in a
list). In that case, the Field objects will be extracted from the
table(s).
Instead of specifying the "fields" argument, the "colnames" argument
can be specified as a list of field names in tablename.fieldname format.
Again, these should represent tables and fields defined on the DAL
object.
It is also possible to specify both "fields" and the associated
"colnames". In that case, "fields" can also include DAL Expression
objects in addition to Field objects. For Field objects in "fields",
the associated "colnames" must still be in tablename.fieldname format.
For Expression objects in "fields", the associated "colnames" can
be any arbitrary labels.
Note, the DAL Table objects referred to by "fields" or "colnames" can
be dummy tables and do not have to represent any real tables in the
database. Also, note that the "fields" and "colnames" must be in the
same order as the fields in the results cursor returned from the DB.
""" """
adapter = self._adapter adapter = self._adapter
if placeholders: if placeholders:
@@ -7233,8 +7246,12 @@ def index():
# convert the list for each row into a dictionary so it's # convert the list for each row into a dictionary so it's
# easier to work with. row['field_name'] rather than row[0] # easier to work with. row['field_name'] rather than row[0]
return [dict(zip(fields,row)) for row in data] return [dict(zip(fields,row)) for row in data]
try:
data = adapter.cursor.fetchall() data = adapter.cursor.fetchall()
if fields: except:
return None
if fields or colnames:
fields = [] if fields is None else fields
if not isinstance(fields, list): if not isinstance(fields, list):
fields = [fields] fields = [fields]
extracted_fields = [] extracted_fields = []
+15 -32
View File
@@ -91,7 +91,8 @@ from validators import CRYPT
from cache import Cache from cache import Cache
from html import URL, xmlescape from html import URL, xmlescape
from utils import is_valid_ip_address 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 import newcron
__all__ = ['wsgibase', 'save_password', 'appfactory', 'HttpServer'] __all__ = ['wsgibase', 'save_password', 'appfactory', 'HttpServer']
@@ -148,10 +149,11 @@ def copystream_progress(request, chunk_size= 10**5):
and stores progress upload status in cache.ram and stores progress upload status in cache.ram
X-Progress-ID:length and X-Progress-ID:uploaded 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() return cStringIO.StringIO()
source = request.env.wsgi_input source = env.wsgi_input
size = int(request.env.content_length) size = int(env.content_length)
dest = tempfile.TemporaryFile() dest = tempfile.TemporaryFile()
if not 'X-Progress-ID' in request.vars: if not 'X-Progress-ID' in request.vars:
copystream(source, dest, size, chunk_size) copystream(source, dest, size, chunk_size)
@@ -274,7 +276,8 @@ def environ_aux(environ,request):
def parse_get_post_vars(request, environ): def parse_get_post_vars(request, environ):
# always parse variables in URL for GET, POST, PUT, DELETE, etc. in get_vars # 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: for (key, value) in dget:
if key in request.get_vars: if key in request.get_vars:
if isinstance(request.get_vars[key], list): if isinstance(request.get_vars[key], list):
@@ -290,7 +293,7 @@ def parse_get_post_vars(request, environ):
request.body = body = copystream_progress(request) request.body = body = copystream_progress(request)
except IOError: except IOError:
raise HTTP(400,"Bad Request - HTTP body is incomplete") 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) dpost = cgi.FieldStorage(fp=body,environ=environ,keep_blank_values=1)
# The same detection used by FieldStorage to detect multipart POSTs # The same detection used by FieldStorage to detect multipart POSTs
is_multipart = dpost.type[:10] == 'multipart/' is_multipart = dpost.type[:10] == 'multipart/'
@@ -382,26 +385,7 @@ def wsgibase(environ, responder):
# serve file if static # serve file if static
# ################################################## # ##################################################
eget = environ.get fixup_missing_path_info(environ)
if not eget('PATH_INFO') and eget('REQUEST_URI'):
# 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'] = ''
elif not eget('REQUEST_URI'):
if eget('QUERY_STRING'):
environ['REQUEST_URI'] = eget('PATH_INFO') + '?' + eget('QUERY_STRING')
else:
environ['REQUEST_URI'] = eget('PATH_INFO')
if not eget('HTTP_HOST'):
environ['HTTP_HOST'] = \
eget('SERVER_NAME') + ':' + eget('SERVER_PORT')
(static_file, environ) = url_in(request, environ) (static_file, environ) = url_in(request, environ)
if static_file: if static_file:
@@ -438,6 +422,7 @@ def wsgibase(environ, responder):
is_https = env.wsgi_url_scheme \ is_https = env.wsgi_url_scheme \
in ['https', 'HTTPS'] or env.https=='on') in ['https', 'HTTPS'] or env.https=='on')
request.uuid = request.compute_uuid() # requires client request.uuid = request.compute_uuid() # requires client
request.url = environ['PATH_INFO']
# ################################################## # ##################################################
# access the requested application # access the requested application
@@ -460,9 +445,6 @@ def wsgibase(environ, responder):
elif not request.is_local and \ elif not request.is_local and \
exists(pjoin(request.folder,'DISABLED')): exists(pjoin(request.folder,'DISABLED')):
raise HTTP(503, "<html><body><h1>Temporarily down for maintenance</h1></body></html>") 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 # build missing folders
@@ -492,9 +474,9 @@ def wsgibase(environ, responder):
# load cookies # load cookies
# ################################################## # ##################################################
if request.env.http_cookie: if env.http_cookie:
try: try:
request.cookies.load(request.env.http_cookie) request.cookies.load(env.http_cookie)
except Cookie.CookieError, e: except Cookie.CookieError, e:
pass # invalid cookies pass # invalid cookies
@@ -502,6 +484,7 @@ def wsgibase(environ, responder):
# try load session or create new session file # try load session or create new session file
# ################################################## # ##################################################
if not env.web2py_disable_session:
session.connect(request, response) session.connect(request, response)
# ################################################## # ##################################################
@@ -566,7 +549,7 @@ def wsgibase(environ, responder):
# ################################################## # ##################################################
if request.cid: if request.cid:
rheaders = response.headers rheaders = http_response.headers
if response.flash and \ if response.flash and \
not 'web2py-component-flash' in rheaders: not 'web2py-component-flash' in rheaders:
rheaders['web2py-component-flash'] = \ rheaders['web2py-component-flash'] = \
+28 -6
View File
@@ -135,6 +135,27 @@ ROUTER_BASE_KEYS = set(
# filter_err: helper for doctest & unittest # filter_err: helper for doctest & unittest
# regex_filter_out: doctest # 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): def url_in(request, environ):
"parse and rewrite incoming URL" "parse and rewrite incoming URL"
if routers: if routers:
@@ -287,8 +308,8 @@ def load(routes='routes.py', app=None, data=None, rdict=None):
for sym in ('routes_app', 'routes_in', 'routes_out'): for sym in ('routes_app', 'routes_in', 'routes_out'):
if sym in symbols: if sym in symbols:
for (k, v) in symbols[sym]: for items in symbols[sym]:
p[sym].append(compile_regex(k, v)) p[sym].append(compile_regex(*items))
for sym in ('routes_onerror', 'routes_apps_raw', for sym in ('routes_onerror', 'routes_apps_raw',
'error_handler','error_message', 'error_message_ticket', 'error_handler','error_message', 'error_message_ticket',
'default_application','default_controller', 'default_function', 'default_application','default_controller', 'default_function',
@@ -350,7 +371,7 @@ def load(routes='routes.py', app=None, data=None, rdict=None):
log_rewrite('URL rewrite is on. configuration in %s' % path) 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 Preprocess and compile the regular expressions in routes_app/in/out
The resulting regex will match a pattern of the form: The resulting regex will match a pattern of the form:
@@ -384,7 +405,7 @@ def compile_regex(k, v):
# same for replacement pattern, but with \g # same for replacement pattern, but with \g
for item in regex_at.findall(v): for item in regex_at.findall(v):
v = v.replace(item, r'\g<%s>' % item[1:]) 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): def load_routers(all_apps):
"load-time post-processing of routers" "load-time post-processing of routers"
@@ -498,8 +519,9 @@ def regex_uri(e, regexes, tag, default=None):
(e.get('REMOTE_ADDR','localhost'), (e.get('REMOTE_ADDR','localhost'),
e.get('wsgi.url_scheme', 'http').lower(), host, e.get('wsgi.url_scheme', 'http').lower(), host,
e.get('REQUEST_METHOD', 'get').lower(), path) e.get('REQUEST_METHOD', 'get').lower(), path)
for (regex, value) in regexes: for (regex, value, custom_env) in regexes:
if regex.match(key): if regex.match(key):
e.update(custom_env)
rewritten = regex.sub(value, key) rewritten = regex.sub(value, key)
log_rewrite('%s: [%s] [%s] -> %s' % (tag, key, value, rewritten)) log_rewrite('%s: [%s] [%s] -> %s' % (tag, key, value, rewritten))
return rewritten return rewritten
@@ -687,7 +709,7 @@ def regex_filter_out(url, e=None):
e.get('request_method', 'get').lower(), items[0]) e.get('request_method', 'get').lower(), items[0])
else: else:
items[0] = ':http://localhost:get %s' % items[0] 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]): if regex.match(items[0]):
rewritten = '?'.join([regex.sub(value, items[0])] + items[1:]) rewritten = '?'.join([regex.sub(value, items[0])] + items[1:])
log_rewrite('routes_out: [%s] -> %s' % (url, rewritten)) log_rewrite('routes_out: [%s] -> %s' % (url, rewritten))
+7 -6
View File
@@ -702,17 +702,17 @@ def formstyle_bootstrap(form, fields):
_submit = False _submit = False
if isinstance(controls, INPUT): if isinstance(controls, INPUT):
controls['_class'] = 'input-xlarge' controls.add_class('input-xlarge')
if controls['_type'] == 'submit': if controls['_type'] == 'submit':
# flag submit button # flag submit button
_submit = True _submit = True
controls['_class'] = 'btn btn-primary' controls['_class'] = 'btn btn-primary'
if isinstance(controls, SELECT): if isinstance(controls, SELECT):
controls['_class'] = 'input-xlarge' controls.add_class('input-xlarge')
if isinstance(controls, TEXTAREA): if isinstance(controls, TEXTAREA):
controls['_class'] = 'input-xlarge' controls.add_class('input-xlarge')
if isinstance(label, LABEL): if isinstance(label, LABEL):
label['_class'] = 'control-label' label['_class'] = 'control-label'
@@ -1376,8 +1376,8 @@ class SQLFORM(FORM):
# this should never happen but seems to happen to some # this should never happen but seems to happen to some
del fields['delete_this_record'] del fields['delete_this_record']
for field in self.table: for field in self.table:
if not field.name in fields and field.writable==False \ if not field.name in fields and field.writable is False \
and field.update is None: and field.update is None and field.compute is None:
if record_id and self.record: if record_id and self.record:
fields[field.name] = self.record[field.name] fields[field.name] = self.record[field.name]
elif not self.table[field.name].default is None: elif not self.table[field.name].default is None:
@@ -1664,7 +1664,8 @@ class SQLFORM(FORM):
redirect(referrer) redirect(referrer)
def gridbutton(buttonclass='buttonadd', buttontext='Add', def gridbutton(buttonclass='buttonadd', buttontext='Add',
buttonurl=url(args=[]),callback=None,delete=None,trap=True): buttonurl=url(args=[]), callback=None,
delete=None, trap=True):
if showbuttontext: if showbuttontext:
if callback: if callback:
return A(SPAN(_class=ui.get(buttonclass)), return A(SPAN(_class=ui.get(buttonclass)),
+14 -11
View File
@@ -839,6 +839,7 @@ class Auth(object):
table_event = None, table_event = None,
table_cas = None, table_cas = None,
showid = False, showid = False,
use_username = False,
login_email_validate = True, login_email_validate = True,
login_userfield = None, login_userfield = None,
logout_onlogout = None, logout_onlogout = None,
@@ -1060,7 +1061,6 @@ class Auth(object):
request = current.request request = current.request
session = current.session session = current.session
auth = session.auth auth = session.auth
self.use_username = None # None means postpone detection
self.user_groups = auth and auth.user_groups or {} self.user_groups = auth and auth.user_groups or {}
if auth and auth.last_visit and auth.last_visit + \ if auth and auth.last_visit and auth.last_visit + \
datetime.timedelta(days=0, seconds=auth.expiration) > request.now: datetime.timedelta(days=0, seconds=auth.expiration) > request.now:
@@ -1251,21 +1251,21 @@ class Auth(object):
else: else:
login = A(T('Login'), _href=href('login')) login = A(T('Login'), _href=href('login'))
register = A(T('Register'), _href=href('register')) register = A(T('Register'), _href=href('register'))
retrieve_username = A(T('Forgot username?'), _href=href('retrieve_username')) retrieve_username = A(
lost_password = A(T('Lost password?'), _href=href('request_reset_password')) 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') bar = SPAN(s1, login, s3, _class='auth_navbar')
if not 'register' in self.settings.actions_disabled: if not 'register' in self.settings.actions_disabled:
bar.insert(-1, s2) bar.insert(-1, s2)
bar.insert(-1, register) bar.insert(-1, register)
if self.use_username is None: if self.settings.use_username and not 'retrieve_username' \
# should always be false if auth.define_tables() is called in self.settings.actions_disabled:
self.use_username = 'username' in self.table_user().fields
if self.use_username and \
not 'retrieve_username' in self.settings.actions_disabled:
bar.insert(-1, s2) bar.insert(-1, s2)
bar.insert(-1, retrieve_username) 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, s2)
bar.insert(-1, lost_password) bar.insert(-1, lost_password)
return bar return bar
@@ -1357,7 +1357,7 @@ class Auth(object):
writable=False,readable=False, writable=False,readable=False,
label=T('Modified By'))) 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): migrate=True, fake_migrate=False):
""" """
to be called unless tables are defined manually to be called unless tables are defined manually
@@ -1375,7 +1375,10 @@ class Auth(object):
db = self.db db = self.db
settings = self.settings settings = self.settings
self.use_username = username if username is None:
username = settings.use_username
else:
settings.use_username = username
if not self.signature: if not self.signature:
self.define_signature() self.define_signature()
if signature==True: if signature==True: