Merge github.com:web2py/web2py
This commit is contained in:
@@ -625,6 +625,7 @@ CONTENT_TYPE = {
|
||||
'.voc': 'audio/x-voc',
|
||||
'.vor': 'application/vnd.stardivision.writer',
|
||||
'.vst': 'image/x-tga',
|
||||
'.vtt': 'text/vtt',
|
||||
'.wav': 'audio/x-wav',
|
||||
'.wax': 'audio/x-ms-asx',
|
||||
'.wb1': 'application/x-quattropro',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: latin-1 -*-
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by the
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: latin-1 -*-
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by the
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: latin-1 -*-
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by the
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: latin-1 -*-
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by the
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright 2007 Google Inc.
|
||||
#
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by the
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
This file is part of the web2py Web Framework
|
||||
Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu>
|
||||
|
||||
+11
-5
@@ -2570,12 +2570,18 @@ class PostgreSQLAdapter(BaseAdapter):
|
||||
|
||||
|
||||
def LIKE(self,first,second):
|
||||
return '(%s LIKE %s)' % (self.expand(first),
|
||||
self.expand(second,'string'))
|
||||
args = (self.expand(first), self.expand(second,'string'))
|
||||
if not first.type in ('string', 'text', 'json'):
|
||||
return '(CAST(%s AS CHAR) LIKE %s)' % args
|
||||
else:
|
||||
return '(%s LIKE %s)' % args
|
||||
|
||||
def ILIKE(self,first,second):
|
||||
return '(%s ILIKE %s)' % (self.expand(first),
|
||||
self.expand(second,'string'))
|
||||
args = (self.expand(first), self.expand(second,'string'))
|
||||
if not first.type in ('string', 'text', 'json'):
|
||||
return '(CAST(%s AS CHAR) ILIKE %s)' % args
|
||||
else:
|
||||
return '(%s ILIKE %s)' % args
|
||||
|
||||
def REGEXP(self,first,second):
|
||||
return '(%s ~ %s)' % (self.expand(first),
|
||||
@@ -6027,7 +6033,7 @@ class IMAPAdapter(NoSQLAdapter):
|
||||
messages_set = messages_set[int(limitby[0]):int(limitby[1])]
|
||||
|
||||
# keep the requests small for header/flags
|
||||
if any([(field.name in ["content",
|
||||
if any([(field.name in ["content", "size",
|
||||
"attachments", "email"]) for
|
||||
field in fields]):
|
||||
imap_fields = "(RFC822 FLAGS)"
|
||||
|
||||
+2
-2
@@ -2243,9 +2243,9 @@ class BEAUTIFY(DIV):
|
||||
for c in self.components:
|
||||
if hasattr(c, 'value') and not callable(c.value):
|
||||
if c.value:
|
||||
components.append(c.value)
|
||||
components.append(c.value)
|
||||
if hasattr(c, 'xml') and callable(c.xml):
|
||||
components.append(c)
|
||||
c = str(c)
|
||||
continue
|
||||
elif hasattr(c, 'keys') and callable(c.keys):
|
||||
rows = []
|
||||
|
||||
+4
-4
@@ -16,7 +16,7 @@ import logging
|
||||
|
||||
from storage import Storage
|
||||
from http import HTTP
|
||||
from html import BEAUTIFY
|
||||
from html import BEAUTIFY, XML
|
||||
|
||||
logger = logging.getLogger("web2py")
|
||||
|
||||
@@ -131,7 +131,7 @@ class RestrictedError(Exception):
|
||||
try:
|
||||
self.traceback = traceback.format_exc()
|
||||
except:
|
||||
self.traceback = 'no traceback because template parting error'
|
||||
self.traceback = 'no traceback because template parsing error'
|
||||
try:
|
||||
self.snapshot = snapshot(context=10, code=code,
|
||||
environment=self.environment)
|
||||
@@ -243,7 +243,7 @@ def snapshot(info=None, context=5, code=None, environment=None):
|
||||
|
||||
# create a snapshot dict with some basic information
|
||||
s = {}
|
||||
s['pyver'] = 'Python ' + sys.version.split()[0] + ': ' + sys.executable
|
||||
s['pyver'] = 'Python ' + sys.version.split()[0] + ': ' + sys.executable + ' (prefix: %s)' % sys.prefix
|
||||
s['date'] = time.ctime(time.time())
|
||||
|
||||
# start to process frames
|
||||
@@ -319,6 +319,6 @@ def snapshot(info=None, context=5, code=None, environment=None):
|
||||
# add web2py environment variables
|
||||
for k, v in environment.items():
|
||||
if k in ('request', 'response', 'session'):
|
||||
s[k] = BEAUTIFY(v)
|
||||
s[k] = XML(str(BEAUTIFY(v)))
|
||||
|
||||
return s
|
||||
|
||||
+23
-24
@@ -1991,6 +1991,7 @@ class SQLFORM(FORM):
|
||||
csv=(ExporterCSV, 'CSV'),
|
||||
xml=(ExporterXML, 'XML'),
|
||||
html=(ExporterHTML, 'HTML'),
|
||||
json=(ExporterJSON, 'JSON'),
|
||||
tsv_with_hidden_cols=
|
||||
(ExporterTSV, 'TSV (Excel compatible, hidden cols)'),
|
||||
tsv=(ExporterTSV, 'TSV (Excel compatible)'))
|
||||
@@ -2938,11 +2939,10 @@ class ExporterCSV(ExportClass):
|
||||
|
||||
def export(self):
|
||||
if self.rows:
|
||||
return str(self.rows)
|
||||
return self.rows.as_csv()
|
||||
else:
|
||||
return ''
|
||||
|
||||
|
||||
class ExporterHTML(ExportClass):
|
||||
label = 'HTML'
|
||||
file_ext = "html"
|
||||
@@ -2952,18 +2952,10 @@ class ExporterHTML(ExportClass):
|
||||
ExportClass.__init__(self, rows)
|
||||
|
||||
def export(self):
|
||||
out = cStringIO.StringIO()
|
||||
out.write('<html>\n<body>\n<table>\n')
|
||||
if self.rows:
|
||||
colnames = [a.split('.') for a in self.rows.colnames]
|
||||
for row in self.rows.records:
|
||||
out.write('<tr>\n')
|
||||
for col in colnames:
|
||||
out.write('<td>' + str(row[col[0]][col[1]]) + '</td>\n')
|
||||
out.write('</tr>\n')
|
||||
out.write('</table>\n</body>\n</html>')
|
||||
return str(out.getvalue())
|
||||
|
||||
return self.rows.xml()
|
||||
else:
|
||||
return '<html>\n<body>\n<table>\n</table>\n</body>\n</html>'
|
||||
|
||||
class ExporterXML(ExportClass):
|
||||
label = 'XML'
|
||||
@@ -2974,15 +2966,22 @@ class ExporterXML(ExportClass):
|
||||
ExportClass.__init__(self, rows)
|
||||
|
||||
def export(self):
|
||||
out = cStringIO.StringIO()
|
||||
out.write('<rows>\n')
|
||||
if self.rows:
|
||||
colnames = [a.split('.') for a in self.rows.colnames]
|
||||
for row in self.rows.records:
|
||||
out.write('<row>\n')
|
||||
for col in colnames:
|
||||
out.write(
|
||||
'<%s>' % col + str(row[col[0]][col[1]]) + '</%s>\n' % col)
|
||||
out.write('</row>\n')
|
||||
out.write('</rows>')
|
||||
return str(out.getvalue())
|
||||
return self.rows.as_xml()
|
||||
else:
|
||||
return '<rows></rows>'
|
||||
|
||||
class ExporterJSON(ExportClass):
|
||||
label = 'JSON'
|
||||
file_ext = "json"
|
||||
content_type = "application/json"
|
||||
|
||||
def __init__(self, rows):
|
||||
ExportClass.__init__(self, rows)
|
||||
|
||||
def export(self):
|
||||
if self.rows:
|
||||
return self.rows.as_json()
|
||||
else:
|
||||
return 'null'
|
||||
|
||||
|
||||
+37
-17
@@ -3317,14 +3317,17 @@ class Auth(object):
|
||||
restrict_search=False,
|
||||
resolve=True,
|
||||
extra=None,
|
||||
menu_groups=None):
|
||||
menu_groups=None,
|
||||
templates=None):
|
||||
|
||||
if not hasattr(self, '_wiki'):
|
||||
self._wiki = Wiki(self, render=render,
|
||||
manage_permissions=manage_permissions,
|
||||
force_prefix=force_prefix,
|
||||
restrict_search=restrict_search,
|
||||
env=env, extra=extra or {},
|
||||
menu_groups=menu_groups)
|
||||
menu_groups=menu_groups,
|
||||
templates=templates)
|
||||
else:
|
||||
self._wiki.env.update(env or {})
|
||||
# if resolve is set to True, process request as wiki call
|
||||
@@ -4868,7 +4871,9 @@ class Wiki(object):
|
||||
|
||||
def __init__(self, auth, env=None, render='markmin',
|
||||
manage_permissions=False, force_prefix='',
|
||||
restrict_search=False, extra=None, menu_groups=None):
|
||||
restrict_search=False, extra=None,
|
||||
menu_groups=None, templates=None):
|
||||
db = auth.db
|
||||
self.env = env or {}
|
||||
self.env['component'] = Wiki.component
|
||||
if render == 'markmin':
|
||||
@@ -4886,7 +4891,8 @@ class Wiki(object):
|
||||
perms = self.manage_permissions = manage_permissions
|
||||
self.restrict_search = restrict_search
|
||||
self.extra = extra or {}
|
||||
db = auth.db
|
||||
self.templates = templates
|
||||
|
||||
table_definitions = [
|
||||
('wiki_page', {
|
||||
'args':[
|
||||
@@ -4938,6 +4944,10 @@ class Wiki(object):
|
||||
args += value['args']
|
||||
db.define_table(key, *args, **value['vars'])
|
||||
|
||||
if self.templates is None and not self.manage_permissions:
|
||||
self.templates = db.wiki_page.tags.contains('template')&\
|
||||
db.wiki_page.can_read.contains('everybody')
|
||||
|
||||
def update_tags_insert(page, id, db=db):
|
||||
for tag in page.tags or []:
|
||||
tag = tag.strip().lower()
|
||||
@@ -5110,8 +5120,8 @@ class Wiki(object):
|
||||
if slug == 'wiki-menu':
|
||||
db.wiki_page.body.default = \
|
||||
'- Menu Item > @////index\n- - Submenu > http://web2py.com'
|
||||
#else:
|
||||
# db.wiki_page.body.default = db(db.wiki_page.id==from_template).select(db.wiki_page.body)[0].body if int(from_template) > 0 else '## %s\n\npage content' % title_guess
|
||||
else:
|
||||
db.wiki_page.body.default = db(db.wiki_page.id==from_template).select(db.wiki_page.body)[0].body if int(from_template) > 0 else '## %s\n\npage content' % title_guess
|
||||
vars = current.request.post_vars
|
||||
if vars.body:
|
||||
vars.body = vars.body.replace('://%s' % self.host, '://HOSTNAME')
|
||||
@@ -5202,18 +5212,24 @@ class Wiki(object):
|
||||
slugs=db(db.wiki_page.id>0).select(db.wiki_page.id,db.wiki_page.slug)
|
||||
options=[OPTION(row.slug,_value=row.id) for row in slugs]
|
||||
options.insert(0, OPTION('',_value=''))
|
||||
form = SQLFORM.factory(Field("slug", default=current.request.args(1) or self.force_prefix,
|
||||
requires=(IS_SLUG(),
|
||||
IS_NOT_IN_DB(db,db.wiki_page.slug))),
|
||||
#Field("from_template", "reference wiki_page",
|
||||
# requires=IS_EMPTY_OR(IS_IN_DB(db, db.wiki_page, '%(slug)s')),
|
||||
# comment=current.T("Choose Template or empty for new Page")),
|
||||
_class="well span6")
|
||||
form.element("[type=submit]").attributes["_value"] = current.T("Create Page from Slug")
|
||||
fields = [Field("slug", default=current.request.args(1) or
|
||||
self.force_prefix,
|
||||
requires=(IS_SLUG(), IS_NOT_IN_DB(db,db.wiki_page.slug))),]
|
||||
if self.templates:
|
||||
fields.append(
|
||||
Field("from_template", "reference wiki_page",
|
||||
requires=IS_EMPTY_OR(IS_IN_DB(db(self.templates),
|
||||
'%(slug)s')),
|
||||
comment=current.T(
|
||||
"Choose Template or empty for new Page")))
|
||||
form = SQLFORM.factory(*fields, **dict(_class="well span6"))
|
||||
form.element("[type=submit]").attributes["_value"] = \
|
||||
current.T("Create Page from Slug")
|
||||
|
||||
if form.process().accepted:
|
||||
# form.vars.from_template = 0 if not form.vars.from_template else form.vars.from_template
|
||||
redirect(URL(args=('_edit',form.vars.slug,form.vars.from_template or 0))) # added param
|
||||
form.vars.from_template = 0 if not form.vars.from_template \
|
||||
else form.vars.from_template
|
||||
redirect(URL(args=('_edit', form.vars.slug,form.vars.from_template or 0))) # added param
|
||||
return dict(content=form)
|
||||
|
||||
def pages(self):
|
||||
@@ -5266,15 +5282,19 @@ class Wiki(object):
|
||||
base = match.group('base').replace(' ', '')
|
||||
title = match.group('title')
|
||||
link = match.group('link')
|
||||
title_page = None
|
||||
if link.startswith('@'):
|
||||
items = link[2:].split('/')
|
||||
if len(items) > 3:
|
||||
title_page = items[3]
|
||||
link = URL(a=items[0] or None, c=items[1] or None,
|
||||
f=items[2] or None, args=items[3:])
|
||||
parent = tree.get(base[1:], tree[''])
|
||||
subtree = []
|
||||
tree[base] = subtree
|
||||
parent.append((current.T(title), False, link, subtree))
|
||||
parent.append((current.T(title),
|
||||
request.args(0) == title_page,
|
||||
link, subtree))
|
||||
if self.can_see_menu():
|
||||
submenu = []
|
||||
menu.append((current.T('[Wiki]'), None, None, submenu))
|
||||
|
||||
Reference in New Issue
Block a user