portable html.py
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 1.99.7 (2012-03-12 15:56:12) dev
|
Version 1.99.7 (2012-03-12 17:47:52) dev
|
||||||
|
|||||||
+14
-8
@@ -15,19 +15,18 @@ import types
|
|||||||
import urllib
|
import urllib
|
||||||
import base64
|
import base64
|
||||||
import sanitizer
|
import sanitizer
|
||||||
import rewrite
|
|
||||||
import itertools
|
import itertools
|
||||||
import decoder
|
import decoder
|
||||||
import copy_reg
|
import copy_reg
|
||||||
import cPickle
|
import cPickle
|
||||||
import marshal
|
import marshal
|
||||||
|
|
||||||
from HTMLParser import HTMLParser
|
from HTMLParser import HTMLParser
|
||||||
from htmlentitydefs import name2codepoint
|
from htmlentitydefs import name2codepoint
|
||||||
from contrib.markmin.markmin2html import render
|
|
||||||
|
|
||||||
from storage import Storage
|
from storage import Storage
|
||||||
from highlight import highlight
|
|
||||||
from utils import web2py_uuid, hmac_hash
|
from utils import web2py_uuid, hmac_hash
|
||||||
|
from highlight import highlight
|
||||||
|
|
||||||
regex_crlf = re.compile('\r|\n')
|
regex_crlf = re.compile('\r|\n')
|
||||||
|
|
||||||
@@ -227,6 +226,8 @@ def URL(
|
|||||||
:raises SyntaxError: when a CRLF is found in the generated url
|
:raises SyntaxError: when a CRLF is found in the generated url
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from rewrite import url_out # done here in case used not-in web2py
|
||||||
|
|
||||||
if args in (None,[]): args = []
|
if args in (None,[]): args = []
|
||||||
vars = vars or {}
|
vars = vars or {}
|
||||||
application = None
|
application = None
|
||||||
@@ -342,8 +343,8 @@ def URL(
|
|||||||
|
|
||||||
if regex_crlf.search(join([application, controller, function, other])):
|
if regex_crlf.search(join([application, controller, function, other])):
|
||||||
raise SyntaxError, 'CRLF Injection Detected'
|
raise SyntaxError, 'CRLF Injection Detected'
|
||||||
url = rewrite.url_out(r, env, application, controller, function,
|
url = url_out(r, env, application, controller, function,
|
||||||
args, other, scheme, host, port)
|
args, other, scheme, host, port)
|
||||||
return url
|
return url
|
||||||
|
|
||||||
|
|
||||||
@@ -1659,6 +1660,10 @@ class INPUT(DIV):
|
|||||||
return DIV.xml(self) + DIV(self.errors[name], _class='error',
|
return DIV.xml(self) + DIV(self.errors[name], _class='error',
|
||||||
errors=None, _id='%s__error' % name).xml()
|
errors=None, _id='%s__error' % name).xml()
|
||||||
else:
|
else:
|
||||||
|
if self['_class'] and self['_class'].endswith('invalidinput'):
|
||||||
|
self['_class'] = self['_class'][:-12]
|
||||||
|
if self['_class'] == '':
|
||||||
|
self['_class'] = None
|
||||||
return DIV.xml(self)
|
return DIV.xml(self)
|
||||||
|
|
||||||
|
|
||||||
@@ -2005,7 +2010,7 @@ class BEAUTIFY(DIV):
|
|||||||
example::
|
example::
|
||||||
|
|
||||||
>>> BEAUTIFY(['a', 'b', {'hello': 'world'}]).xml()
|
>>> BEAUTIFY(['a', 'b', {'hello': 'world'}]).xml()
|
||||||
'<div><table><tr><td><div>a</div></td></tr><tr><td><div>b</div></td></tr><tr><td><div><table><tr><td style="font-weight:bold;">hello</td><td valign="top">:</td><td><div>world</div></td></tr></table></div></td></tr></table></div>'
|
'<div><table><tr><td><div>a</div></td></tr><tr><td><div>b</div></td></tr><tr><td><div><table><tr><td style="font-weight:bold;vertical-align:top">hello</td><td valign="top">:</td><td><div>world</div></td></tr></table></div></td></tr></table></div>'
|
||||||
|
|
||||||
turns any list, dictionary, etc into decent looking html.
|
turns any list, dictionary, etc into decent looking html.
|
||||||
Two special attributes are
|
Two special attributes are
|
||||||
@@ -2191,7 +2196,7 @@ def test():
|
|||||||
>>> print form.accepts({'myvar':'34'}, formname=None)
|
>>> print form.accepts({'myvar':'34'}, formname=None)
|
||||||
False
|
False
|
||||||
>>> print form.xml()
|
>>> print form.xml()
|
||||||
<form action="" enctype="multipart/form-data" method="post"><input name="myvar" type="text" value="34" /><div class="error" id="myvar__error">invalid expression</div></form>
|
<form action="" enctype="multipart/form-data" method="post"><input class="invalidinput" name="myvar" type="text" value="34" /><div class="error" id="myvar__error">invalid expression</div></form>
|
||||||
>>> print form.accepts({'myvar':'4'}, formname=None, keepvalues=True)
|
>>> print form.accepts({'myvar':'4'}, formname=None, keepvalues=True)
|
||||||
True
|
True
|
||||||
>>> print form.xml()
|
>>> print form.xml()
|
||||||
@@ -2205,7 +2210,7 @@ def test():
|
|||||||
>>> print form.accepts({'myvar':'as df'}, formname=None)
|
>>> print form.accepts({'myvar':'as df'}, formname=None)
|
||||||
False
|
False
|
||||||
>>> print form.xml()
|
>>> print form.xml()
|
||||||
<form action=\"\" enctype=\"multipart/form-data\" method=\"post\"><input name=\"myvar\" type=\"text\" value=\"as df\" /><div class=\"error\" id=\"myvar__error\">only alphanumeric!</div></form>
|
<form action=\"\" enctype=\"multipart/form-data\" method=\"post\"><input class=\"invalidinput\" name=\"myvar\" type=\"text\" value=\"as df\" /><div class=\"error\" id=\"myvar__error\">only alphanumeric!</div></form>
|
||||||
>>> session={}
|
>>> session={}
|
||||||
>>> form=FORM(INPUT(value=\"Hello World\", _name=\"var\", requires=IS_MATCH('^\w+$')))
|
>>> form=FORM(INPUT(value=\"Hello World\", _name=\"var\", requires=IS_MATCH('^\w+$')))
|
||||||
>>> if form.accepts({}, session,formname=None): print 'passed'
|
>>> if form.accepts({}, session,formname=None): print 'passed'
|
||||||
@@ -2326,6 +2331,7 @@ class MARKMIN(XmlComponent):
|
|||||||
"""
|
"""
|
||||||
calls the gluon.contrib.markmin render function to convert the wiki syntax
|
calls the gluon.contrib.markmin render function to convert the wiki syntax
|
||||||
"""
|
"""
|
||||||
|
from contrib.markmin.markmin2html import render
|
||||||
return render(self.text,extra=self.extra,allowed=self.allowed,sep=self.sep)
|
return render(self.text,extra=self.extra,allowed=self.allowed,sep=self.sep)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user