fixed some pep8 stuff

This commit is contained in:
mdipierro
2012-10-19 09:40:17 -05:00
parent de2337dfe3
commit d552eb2eeb
128 changed files with 267 additions and 140 deletions
+1 -1
View File
@@ -1 +1 @@
Version 2.1.1 (2012-10-18 18:20:45) dev Version 2.1.1 (2012-10-19 09:40:10) dev
+2
View File
@@ -8,3 +8,5 @@
+1
View File
@@ -310,3 +310,4 @@ if __name__=='__main__':
+1
View File
@@ -7,3 +7,4 @@ def webapp_add_wsgi_middleware(app):
@@ -444,3 +444,4 @@ def ccache():
+16 -15
View File
@@ -51,7 +51,7 @@ def interact():
lineno = web_debugger.lineno lineno = web_debugger.lineno
if filename: if filename:
lines = dict([(i+1, l) for (i, l) in enumerate( lines = dict([(i+1, l) for (i, l) in enumerate(
[l.strip("\n").strip("\r") for l [l.strip("\n").strip("\r") for l
in open(filename).readlines()])]) in open(filename).readlines()])])
filename = os.path.basename(filename) filename = os.path.basename(filename)
else: else:
@@ -76,9 +76,9 @@ def interact():
response.flash = T('"User Exception" debug mode. ' response.flash = T('"User Exception" debug mode. '
'An error ticket could be issued!') 'An error ticket could be issued!')
return dict(app=app, data="", return dict(app=app, data="",
filename=web_debugger.filename, lines=lines, lineno=lineno, filename=web_debugger.filename, lines=lines, lineno=lineno,
f_globals=f_globals, f_locals=f_locals, f_globals=f_globals, f_locals=f_locals,
exception=web_debugger.exception_info) exception=web_debugger.exception_info)
def step(): def step():
@@ -120,8 +120,8 @@ def breakpoints():
# Get all .py files # Get all .py files
files = listdir(apath('', r=request), '.*\.py$') files = listdir(apath('', r=request), '.*\.py$')
files = [filename for filename in files files = [filename for filename in files
if filename and 'languages' not in filename if filename and 'languages' not in filename
and not filename.startswith("admin") and not filename.startswith("admin")
and not filename.startswith("examples")] and not filename.startswith("examples")]
@@ -129,16 +129,16 @@ def breakpoints():
Field('filename', requires=IS_IN_SET(files), label=T("Filename")), Field('filename', requires=IS_IN_SET(files), label=T("Filename")),
Field('lineno', 'integer', label=T("Line number"), Field('lineno', 'integer', label=T("Line number"),
requires=IS_NOT_EMPTY()), requires=IS_NOT_EMPTY()),
Field('temporary', 'boolean', label=T("Temporary"), Field('temporary', 'boolean', label=T("Temporary"),
comment=T("deleted after first hit")), comment=T("deleted after first hit")),
Field('condition', 'string', label=T("Condition"), Field('condition', 'string', label=T("Condition"),
comment=T("honored only if the expression evaluates to true")), comment=T("honored only if the expression evaluates to true")),
) )
if form.accepts(request.vars, session): if form.accepts(request.vars, session):
filename = os.path.join(request.env['applications_parent'], filename = os.path.join(request.env['applications_parent'],
'applications', form.vars.filename) 'applications', form.vars.filename)
err = qdb_debugger.do_set_breakpoint(filename, err = qdb_debugger.do_set_breakpoint(filename,
form.vars.lineno, form.vars.lineno,
form.vars.temporary, form.vars.temporary,
form.vars.condition) form.vars.condition)
@@ -150,9 +150,9 @@ def breakpoints():
qdb_debugger.do_clear(item[7:]) qdb_debugger.do_clear(item[7:])
breakpoints = [{'number': bp[0], 'filename': os.path.basename(bp[1]), breakpoints = [{'number': bp[0], 'filename': os.path.basename(bp[1]),
'path': bp[1], 'lineno': bp[2], 'path': bp[1], 'lineno': bp[2],
'temporary': bp[3], 'enabled': bp[4], 'hits': bp[5], 'temporary': bp[3], 'enabled': bp[4], 'hits': bp[5],
'condition': bp[6]} 'condition': bp[6]}
for bp in qdb_debugger.do_list_breakpoint()] for bp in qdb_debugger.do_list_breakpoint()]
return dict(breakpoints=breakpoints, form=form) return dict(breakpoints=breakpoints, form=form)
@@ -160,11 +160,11 @@ def breakpoints():
def toggle_breakpoint(): def toggle_breakpoint():
"Set or clear a breakpoint" "Set or clear a breakpoint"
lineno = None lineno = None
ok = None ok = None
try: try:
filename = os.path.join(request.env['applications_parent'], filename = os.path.join(request.env['applications_parent'],
'applications', request.vars.filename) 'applications', request.vars.filename)
if not request.vars.data: if not request.vars.data:
# ace send us the line number! # ace send us the line number!
@@ -184,7 +184,7 @@ def toggle_breakpoint():
no, bp_filename, bp_lineno, temporary, enabled, hits, cond = bp no, bp_filename, bp_lineno, temporary, enabled, hits, cond = bp
if filename == bp_filename and lineno == bp_lineno: if filename == bp_filename and lineno == bp_lineno:
err = qdb_debugger.do_clear_breakpoint(filename, lineno) err = qdb_debugger.do_clear_breakpoint(filename, lineno)
response.flash = T("Removed Breakpoint on %s at line %s", ( response.flash = T("Removed Breakpoint on %s at line %s", (
filename, lineno)) filename, lineno))
ok = False ok = False
break break
@@ -199,3 +199,4 @@ def toggle_breakpoint():
session.flash = str(e) session.flash = str(e)
return response.json({'ok': ok, 'lineno': lineno}) return response.json({'ok': ok, 'lineno': lineno})
+10 -9
View File
@@ -213,7 +213,7 @@ def site():
else: else:
session.flash = \ session.flash = \
DIV(T('unable to create application "%s"' % appname), DIV(T('unable to create application "%s"' % appname),
PRE(error)) PRE(error))
redirect(URL(r=request)) redirect(URL(r=request))
elif form_update.accepted: elif form_update.accepted:
@@ -241,18 +241,18 @@ def site():
DIV(T('Unable to download app because:'),PRE(str(e))) DIV(T('Unable to download app because:'),PRE(str(e)))
redirect(URL(r=request)) redirect(URL(r=request))
fname = form_update.vars.url fname = form_update.vars.url
elif form_update.accepted and form_update.vars.file: elif form_update.accepted and form_update.vars.file:
fname = request.vars.file.filename fname = request.vars.file.filename
f = request.vars.file.file f = request.vars.file.file
else: else:
session.flash = 'No file uploaded and no URL specified' session.flash = 'No file uploaded and no URL specified'
redirect(URL(r=request)) 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,
request, fname, request, fname,
overwrite=form_update.vars.overwrite) overwrite=form_update.vars.overwrite)
if f and installed: if f and installed:
@@ -282,7 +282,7 @@ def site():
apps = sorted(apps,lambda a,b:cmp(a.upper(),b.upper())) apps = sorted(apps,lambda a,b:cmp(a.upper(),b.upper()))
return dict(app=None, apps=apps, myversion=myversion, return dict(app=None, apps=apps, myversion=myversion,
form_create=form_create, form_update=form_update) form_create=form_create, form_update=form_update)
@@ -340,7 +340,7 @@ def pack_plugin():
def upgrade_web2py(): def upgrade_web2py():
dialog = FORM.confirm(T('Upgrade'), dialog = FORM.confirm(T('Upgrade'),
{T('Cancel'):URL('site')}) {T('Cancel'):URL('site')})
if dialog.accepted: if dialog.accepted:
(success, error) = upgrade(request) (success, error) = upgrade(request)
if success: if success:
@@ -355,7 +355,7 @@ def uninstall():
dialog = FORM.confirm(T('Uninstall'), dialog = FORM.confirm(T('Uninstall'),
{T('Cancel'):URL('site')}) {T('Cancel'):URL('site')})
if dialog.accepted: if dialog.accepted:
if MULTI_USER_MODE: if MULTI_USER_MODE:
if is_manager() and db(db.app.name==app).delete(): if is_manager() and db(db.app.name==app).delete():
@@ -1227,7 +1227,7 @@ def create_file():
if request.vars.plugin and not filename.startswith('plugin_%s/' % request.vars.plugin): if request.vars.plugin and not filename.startswith('plugin_%s/' % request.vars.plugin):
filename = 'plugin_%s/%s' % (request.vars.plugin, filename) filename = 'plugin_%s/%s' % (request.vars.plugin, filename)
text = '' text = ''
else: else:
redirect(request.vars.sender+anchor) redirect(request.vars.sender+anchor)
@@ -1641,7 +1641,7 @@ def git_pull():
session.flash = GIT_MISSING session.flash = GIT_MISSING
redirect(URL('site')) redirect(URL('site'))
dialog = FORM.confirm(T('Pull'), dialog = FORM.confirm(T('Pull'),
{T('Cancel'):URL('site')}) {T('Cancel'):URL('site')})
if dialog.accepted: if dialog.accepted:
try: try:
repo = Repo(os.path.join(apath(r=request),app)) repo = Repo(os.path.join(apath(r=request),app))
@@ -1698,3 +1698,4 @@ def git_push():
redirect(URL('site')) redirect(URL('site'))
return dict(app=app,form=form) return dict(app=app,form=form)
+1
View File
@@ -91,3 +91,4 @@ def callback():
return (output+errors).replace('\n','<br/>') return (output+errors).replace('\n','<br/>')
@@ -82,3 +82,4 @@ def revision():
) )
+4 -3
View File
@@ -26,7 +26,7 @@ def deploy():
kill() kill()
except: except:
pass pass
ignore_apps = [item for item in apps if not item in form.vars.applications] ignore_apps = [item for item in apps if not item in form.vars.applications]
regex = re.compile('\(applications/\(.*') regex = re.compile('\(applications/\(.*')
w2p_origin = os.getcwd() w2p_origin = os.getcwd()
@@ -44,13 +44,13 @@ def deploy():
#shutil.copytree(appsrc,appdest) #shutil.copytree(appsrc,appdest)
index.add(['wsgi/'+osname+'/applications/'+i]) index.add(['wsgi/'+osname+'/applications/'+i])
new_commit = index.commit("Deploy from Web2py IDE") new_commit = index.commit("Deploy from Web2py IDE")
origin = repo.remotes.origin origin = repo.remotes.origin
origin.push origin.push
origin.push() origin.push()
#Git code ends here #Git code ends here
return dict(form=form,command=cmd) return dict(form=form,command=cmd)
class EXISTS(object): class EXISTS(object):
def __init__(self, error_message='file not found'): def __init__(self, error_message='file not found'):
self.error_message = error_message self.error_message = error_message
@@ -58,3 +58,4 @@ class EXISTS(object):
if os.path.exists(value): if os.path.exists(value):
return (value,None) return (value,None)
return (value,self.error_message) return (value,self.error_message)
@@ -8,3 +8,4 @@ def about():
return locals() return locals()
+1
View File
@@ -45,3 +45,4 @@ def reset():
return 'done' return 'done'
@@ -29,3 +29,4 @@ def profiler():
return data return data
@@ -90,7 +90,7 @@ def attach_debugger(host='localhost', port=6000, authkey='secret password'):
if isinstance(authkey, unicode): if isinstance(authkey, unicode):
authkey = authkey.encode('utf8') authkey = authkey.encode('utf8')
if not hasattr(gluon.debug, 'qdb_listener'): if not hasattr(gluon.debug, 'qdb_listener'):
# create a remote debugger server and wait for connection # create a remote debugger server and wait for connection
address = (host, port) # family is deduced to be 'AF_INET' address = (host, port) # family is deduced to be 'AF_INET'
@@ -128,3 +128,4 @@ def call():
session.forget() session.forget()
return service() return service()
+1
View File
@@ -556,3 +556,4 @@ def call(): return service()
os.unlink(file) os.unlink(file)
+3 -2
View File
@@ -13,9 +13,9 @@ TEXT_EDITOR = 'codemirror' or 'ace' or 'edit_area' or 'amy'
## Editor Color scheme (only for ace) ## Editor Color scheme (only for ace)
TEXT_EDITOR_THEME = ( TEXT_EDITOR_THEME = (
"chrome", "clouds", "clouds_midnight", "cobalt", "crimson_editor", "dawn", "chrome", "clouds", "clouds_midnight", "cobalt", "crimson_editor", "dawn",
"dreamweaver", "eclipse", "idle_fingers", "kr_theme", "merbivore", "dreamweaver", "eclipse", "idle_fingers", "kr_theme", "merbivore",
"merbivore_soft", "monokai", "mono_industrial", "pastel_on_dark", "merbivore_soft", "monokai", "mono_industrial", "pastel_on_dark",
"solarized_dark", "solarized_light", "textmate", "tomorrow", "solarized_dark", "solarized_light", "textmate", "tomorrow",
"tomorrow_night", "tomorrow_night_blue", "tomorrow_night_bright", "tomorrow_night", "tomorrow_night_blue", "tomorrow_night_bright",
"tomorrow_night_eighties", "twilight", "vibrant_ink")[0] "tomorrow_night_eighties", "twilight", "vibrant_ink")[0]
@@ -80,3 +80,4 @@ if 'adminLanguage' in request.cookies and not (request.cookies['adminLanguage']
T.force(request.cookies['adminLanguage'].value) T.force(request.cookies['adminLanguage'].value)
+1
View File
@@ -30,3 +30,4 @@ from gluon.restricted import *
from gluon.compileapp import compile_application, remove_compiled_application from gluon.compileapp import compile_application, remove_compiled_application
+2 -1
View File
@@ -147,7 +147,7 @@ if request.controller == "webservices":
time.sleep(10) time.sleep(10)
raise HTTP(403,"Not authorized") raise HTTP(403,"Not authorized")
elif not session.authorized and not \ elif not session.authorized and not \
(request.controller+'/'+request.function in (request.controller+'/'+request.function in
('default/index','default/user','plugin_jqmobile/index','plugin_jqmobile/about')): ('default/index','default/user','plugin_jqmobile/index','plugin_jqmobile/about')):
if request.env.query_string: if request.env.query_string:
@@ -169,3 +169,4 @@ if request.controller=='appadmin' and DEMO_MODE:
session.flash = 'Appadmin disabled in demo mode' session.flash = 'Appadmin disabled in demo mode'
redirect(URL('default','sites')) redirect(URL('default','sites'))
+1
View File
@@ -36,3 +36,4 @@ def searchbox(elementid):
return TAG[''](LABEL(IMG(_id="search_start",_src=URL('static', 'images/search.png'), _alt=T('filter')), _class='icon', _for=elementid), ' ', INPUT(_id=elementid, _type='text', _size=12)) return TAG[''](LABEL(IMG(_id="search_start",_src=URL('static', 'images/search.png'), _alt=T('filter')), _class='icon', _for=elementid), ' ', INPUT(_id=elementid, _type='text', _size=12))
+1
View File
@@ -38,3 +38,4 @@ def is_manager():
return False return False
+2 -1
View File
@@ -26,7 +26,7 @@ if not session.authorized:
else: else:
response.menu.append((T('Logout'), False, response.menu.append((T('Logout'), False,
URL(_a,'default',f='logout'))) URL(_a,'default',f='logout')))
response.menu.append((T('Debug'), False, response.menu.append((T('Debug'), False,
URL(_a, 'debug','interact'))) URL(_a, 'debug','interact')))
if os.path.exists('applications/examples'): if os.path.exists('applications/examples'):
@@ -35,3 +35,4 @@ else:
response.menu.append((T('Help'), False, 'http://web2py.com/examples')) response.menu.append((T('Help'), False, 'http://web2py.com/examples'))
@@ -3,3 +3,4 @@ response.files.append(URL('static','plugin_multiselect/multi-select.css'))
response.files.append(URL('static','plugin_multiselect/start.js')) response.files.append(URL('static','plugin_multiselect/start.js'))
@@ -21,3 +21,4 @@ def fade():
@@ -444,3 +444,4 @@ def ccache():
@@ -49,3 +49,4 @@ def cache_controller_and_view():
return response.render(d) return response.render(d)
@@ -74,3 +74,4 @@ def changelog():
filename = os.path.join(request.env.gluon_parent, 'CHANGELOG') filename = os.path.join(request.env.gluon_parent, 'CHANGELOG')
return response.render(dict(changelog=MARKMIN(read_file(filename)))) return response.render(dict(changelog=MARKMIN(read_file(filename))))
@@ -26,3 +26,4 @@ def form():
@@ -80,3 +80,4 @@ def vars():
@@ -23,3 +23,4 @@ def basic():
@@ -11,3 +11,4 @@ def counter():
@@ -138,3 +138,4 @@ Quoted text
def ajaxwiki_onclick(): def ajaxwiki_onclick():
return MARKMIN(request.vars.text).xml() return MARKMIN(request.vars.text).xml()
@@ -8,3 +8,4 @@ def index():
#sheet.cell('r0c3',value='=r0c0+r0c1+r0c2',readonly=True) #sheet.cell('r0c3',value='=r0c0+r0c1+r0c2',readonly=True)
return dict(sheet=sheet) return dict(sheet=sheet)
@@ -34,3 +34,4 @@ def beautify():
@@ -47,3 +47,4 @@ def code_feed_reader(project,mode='div'):
+1
View File
@@ -38,3 +38,4 @@ def get_content(b=None,\
return html return html
+1
View File
@@ -43,3 +43,4 @@ def toggle_menuclass(cssclass='pressed',menuid='headermenu'):
else: else:
return '' return ''
@@ -444,3 +444,4 @@ def ccache():
@@ -71,3 +71,4 @@ def data():
LOAD('default','data.load',args='tables',ajax=True,user_signature=True) LOAD('default','data.load',args='tables',ajax=True,user_signature=True)
""" """
return dict(form=crud()) return dict(form=crud())
+2 -1
View File
@@ -11,7 +11,7 @@
if not request.env.web2py_runtime_gae: if not request.env.web2py_runtime_gae:
## if NOT running on Google App Engine use SQLite or other DB ## if NOT running on Google App Engine use SQLite or other DB
db = DAL('sqlite://storage.sqlite') db = DAL('sqlite://storage.sqlite')
else: else:
## connect to Google BigTable (optional 'google:datastore://namespace') ## connect to Google BigTable (optional 'google:datastore://namespace')
db = DAL('google:datastore') db = DAL('google:datastore')
@@ -81,3 +81,4 @@ use_janrain(auth,filename='private/janrain.key')
## after defining tables, uncomment below to enable auditing ## after defining tables, uncomment below to enable auditing
# auth.enable_record_versioning(db) # auth.enable_record_versioning(db)
+2 -1
View File
@@ -33,7 +33,7 @@ def _():
# shortcuts # shortcuts
app = request.application app = request.application
ctr = request.controller ctr = request.controller
# useful links to internal and external resources # useful links to internal and external resources
response.menu+=[ response.menu+=[
(SPAN('web2py',_class='highlighted'),False, 'http://web2py.com', [ (SPAN('web2py',_class='highlighted'),False, 'http://web2py.com', [
(T('My Sites'),False,URL('admin','default','site')), (T('My Sites'),False,URL('admin','default','site')),
@@ -99,3 +99,4 @@ def _():
)] )]
_() _()
+1
View File
@@ -66,3 +66,4 @@ wsgiref.handlers.CGIHandler().run(gluon.main.wsgibase)
+1
View File
@@ -56,3 +56,4 @@ fcgi.WSGIServer(application, bindAddress='/tmp/fcgi.sock').run()
+1
View File
@@ -102,3 +102,4 @@ if __name__ == '__main__':
+1
View File
@@ -53,3 +53,4 @@ if 0:
+1
View File
@@ -481,3 +481,4 @@ def create_missing_app_folders(request):
+6 -5
View File
@@ -46,13 +46,13 @@ class CacheAbstract(object):
Main function is now to provide referenced api documentation. Main function is now to provide referenced api documentation.
Use CacheInRam or CacheOnDisk instead which are derived from this class. Use CacheInRam or CacheOnDisk instead which are derived from this class.
Attentions, Michele says: Attentions, Michele says:
There are signatures inside gdbm files that are used directly There are signatures inside gdbm files that are used directly
by the python gdbm adapter that often are lagging behind in the by the python gdbm adapter that often are lagging behind in the
detection code in python part. detection code in python part.
On every occasion that a gdbm store is probed by the python adapter, On every occasion that a gdbm store is probed by the python adapter,
the probe fails, because gdbm file version is newer. the probe fails, because gdbm file version is newer.
Using gdbm directly from C would work, because there is backward Using gdbm directly from C would work, because there is backward
compatibility, but not from python! compatibility, but not from python!
@@ -258,7 +258,7 @@ class CacheOnDisk(CacheAbstract):
on self.locker first. Replaces the close method of the on self.locker first. Replaces the close method of the
returned shelf instance with one that releases the lock upon returned shelf instance with one that releases the lock upon
closing.""" closing."""
storage = None storage = None
locker = None locker = None
locked = False locked = False
@@ -296,7 +296,7 @@ class CacheOnDisk(CacheAbstract):
self.initialized = False self.initialized = False
self.request = request self.request = request
self.folder = folder self.folder = folder
def initialize(self): def initialize(self):
if self.initialized: return if self.initialized: return
else: self.initialized = True else: self.initialized = True
@@ -468,7 +468,7 @@ class Cache(object):
""" """
allow replacing cache.ram with cache.with_prefix(cache.ram,'prefix') allow replacing cache.ram with cache.with_prefix(cache.ram,'prefix')
it will add prefix to all the cache keys used. it will add prefix to all the cache keys used.
""" """
return lambda key, f, time_expire=DEFAULT_TIME_EXPIRE, prefix=prefix:\ return lambda key, f, time_expire=DEFAULT_TIME_EXPIRE, prefix=prefix:\
cache_model(prefix + key, f, time_expire) cache_model(prefix + key, f, time_expire)
@@ -492,3 +492,4 @@ def lazy_cache(key=None,time_expire=None,cache_model='ram'):
+1
View File
@@ -58,3 +58,4 @@ def getcfs(key, filename, filter=None):
+2 -1
View File
@@ -371,7 +371,7 @@ _base_environment_['SQLField'] = SQLField # for backward compatibility
_base_environment_['SQLFORM'] = SQLFORM _base_environment_['SQLFORM'] = SQLFORM
_base_environment_['SQLTABLE'] = SQLTABLE _base_environment_['SQLTABLE'] = SQLTABLE
_base_environment_['LOAD'] = LOAD _base_environment_['LOAD'] = LOAD
def build_environment(request, response, session, store_current=True): def build_environment(request, response, session, store_current=True):
""" """
Build the environment dictionary into which web2py files are executed. Build the environment dictionary into which web2py files are executed.
@@ -707,3 +707,4 @@ if __name__ == '__main__':
+1
View File
@@ -724,3 +724,4 @@ def contenttype(filename, default='text/plain'):
+1
View File
@@ -264,3 +264,4 @@ if __name__=='__main__':
+1
View File
@@ -244,3 +244,4 @@ if __name__=='__main__':
+1
View File
@@ -6,3 +6,4 @@
+1
View File
@@ -502,3 +502,4 @@ aes_Rcon = array('B',
) )
+1
View File
@@ -205,3 +205,4 @@ if __name__=="__main__":
print test() print test()
+1
View File
@@ -3911,3 +3911,4 @@ def parse(url_file_stream_or_string, etag=None, modified=None, agent=None, refer
+3 -2
View File
@@ -24,7 +24,7 @@ class MemcacheClient(object):
key, key,
f, f,
time_expire=300, time_expire=300,
): ):
key = '%s/%s' % (self.request.application, key) key = '%s/%s' % (self.request.application, key)
dt = time_expire dt = time_expire
value = None value = None
@@ -44,7 +44,7 @@ class MemcacheClient(object):
obj = self.client.get(key) obj = self.client.get(key)
if obj: if obj:
value = obj[1] + value value = obj[1] + value
self.client.set(key, (time.time(), value)) self.client.set(key, (time.time(), value))
return value return value
def clear(self, key = None): def clear(self, key = None):
@@ -65,3 +65,4 @@ class MemcacheClient(object):
def flush_all(self,*a,**b): def flush_all(self,*a,**b):
return self.client.delete(*a,**b) return self.client.delete(*a,**b)
+1
View File
@@ -91,3 +91,4 @@ def autoretry_datastore_timeouts(attempts=5.0, interval=0.1, exponent=2.0):
+1
View File
@@ -68,3 +68,4 @@ def pdf_from_html(html):
+1
View File
@@ -20,3 +20,4 @@ def button(merchant_id="123456789012345",
+1
View File
@@ -10,3 +10,4 @@ from gluon.dal import DAL, Field, Table, Query, Set, Expression, Row, Rows, driv
+1
View File
@@ -59,3 +59,4 @@ def THUMB(image, nx=120, ny=120, gae=False, name='thumb'):
return image return image
+1
View File
@@ -912,3 +912,4 @@ if __name__ == '__main__':
+1
View File
@@ -128,3 +128,4 @@ if __name__ == "__main__":
+1
View File
@@ -130,3 +130,4 @@ if __name__ == '__main__':
test() test()
+1
View File
@@ -172,3 +172,4 @@ if __name__ == '__main__':
+1
View File
@@ -10,3 +10,4 @@ from fpdf import *
# import warnings # import warnings
# warnings.warn("pyfpdf package name is deprecated, please use fpdf instead") # warnings.warn("pyfpdf package name is deprecated, please use fpdf instead")
+1
View File
@@ -965,3 +965,4 @@ if __name__ == '__main__':
+1
View File
@@ -168,3 +168,4 @@ class RedisClient(object):
+5 -5
View File
@@ -127,7 +127,7 @@ class MockTable(object):
class MockQuery(object): class MockQuery(object):
"""a fake Query object that supports querying by id """a fake Query object that supports querying by id
and listing all keys. No other operation is supported and listing all keys. No other operation is supported
""" """
def __init__(self, field=None, db=None, prefix=None, session_expiry=False): def __init__(self, field=None, db=None, prefix=None, session_expiry=False):
self.field = field self.field = field
@@ -187,15 +187,15 @@ class MockQuery(object):
class RecordDeleter(object): class RecordDeleter(object):
"""Dumb record deleter to support sessions2trash.py""" """Dumb record deleter to support sessions2trash.py"""
def __init__(self, db, key, keyprefix): def __init__(self, db, key, keyprefix):
self.db, self.key, self.keyprefix = db, key, keyprefix self.db, self.key, self.keyprefix = db, key, keyprefix
def __call__(self): def __call__(self):
id_idx = "%s:id_idx" % self.keyprefix id_idx = "%s:id_idx" % self.keyprefix
#remove from the index #remove from the index
self.db.srem(id_idx, self.key) self.db.srem(id_idx, self.key)
#remove the key itself #remove the key itself
self.db.delete(self.key) self.db.delete(self.key)
+1
View File
@@ -593,3 +593,4 @@ if __name__ == '__main__':
+1
View File
@@ -271,3 +271,4 @@ if __name__=='__main__':
+1
View File
@@ -152,3 +152,4 @@ if __name__ == "__main__":
+1
View File
@@ -117,3 +117,4 @@ def sms_email(number,provider):
+1
View File
@@ -880,3 +880,4 @@ if __name__ == '__main__':
+1
View File
@@ -67,3 +67,4 @@ if __name__=='__main__':
+1
View File
@@ -248,3 +248,4 @@ class TaskBarIcon:
+1
View File
@@ -96,3 +96,4 @@ if __name__=='__main__':
+1
View File
@@ -521,3 +521,4 @@ class mobilize(object):
+3 -2
View File
@@ -7,7 +7,7 @@ mostly for testing purposes
- customizable - customizable
- supports basic auth - supports basic auth
- supports cookies - supports cookies
- supports session cookies (tested with web2py sessions) - supports session cookies (tested with web2py sessions)
- detects broken session - detects broken session
- detects web2py form postbacks and handles formname and formkey - detects web2py form postbacks and handles formname and formkey
@@ -51,7 +51,7 @@ class WebClient(object):
def post(self,url,data=None,cookies=None,headers=None,auth=None): def post(self,url,data=None,cookies=None,headers=None,auth=None):
self.url = self.app+url self.url = self.app+url
# if this POST form requires a postback do it # if this POST form requires a postback do it
if data and '_formname' in data and self.postbacks and \ if data and '_formname' in data and self.postbacks and \
self.history and self.history[-1][1]!=self.url: self.history and self.history[-1][1]!=self.url:
@@ -202,3 +202,4 @@ if __name__ == '__main__':
test_web2py_registration_and_login() test_web2py_registration_and_login()
+1
View File
@@ -195,3 +195,4 @@ if __name__ == "__main__":
+1
View File
@@ -188,3 +188,4 @@ class TrackImporter(object):
return file return file
TRACK_IMPORTER = TrackImporter() TRACK_IMPORTER = TrackImporter()
+9 -8
View File
@@ -500,7 +500,7 @@ class ConnectionPool(object):
# ## this allows gluon to commit/rollback all dbs in this thread # ## this allows gluon to commit/rollback all dbs in this thread
def close(self,action='commit',really=True): def close(self,action='commit',really=True):
if action: if action:
if callable(action): if callable(action):
action(self) action(self)
@@ -599,7 +599,7 @@ class BaseAdapter(ConnectionPool):
support_distributed_transaction = False support_distributed_transaction = False
uploads_in_blob = False uploads_in_blob = False
can_select_for_update = True can_select_for_update = True
TRUE = 'T' TRUE = 'T'
FALSE = 'F' FALSE = 'F'
types = { types = {
@@ -1661,7 +1661,7 @@ class BaseAdapter(ConnectionPool):
def prepare(self, key): def prepare(self, key):
if self.connection: self.connection.prepare() if self.connection: self.connection.prepare()
def commit_prepared(self, key): def commit_prepared(self, key):
if self.connection: self.connection.commit() if self.connection: self.connection.commit()
@@ -6572,7 +6572,7 @@ def smart_query(fields,text):
elif field._db._adapter.dbengine=='google:datastore' and \ elif field._db._adapter.dbengine=='google:datastore' and \
field.type in ('list:integer', 'list:string', 'list:reference'): field.type in ('list:integer', 'list:string', 'list:reference'):
if op == 'contains': new_query = field.contains(value) if op == 'contains': new_query = field.contains(value)
else: raise RuntimeError, "Invalid operation" else: raise RuntimeError, "Invalid operation"
else: raise RuntimeError, "Invalid operation" else: raise RuntimeError, "Invalid operation"
if neg: new_query = ~new_query if neg: new_query = ~new_query
if query is None: if query is None:
@@ -6596,7 +6596,7 @@ class DAL(object):
Field('fieldname2')) Field('fieldname2'))
""" """
def __new__(cls, uri='sqlite://dummy.db', *args, **kwargs): def __new__(cls, uri='sqlite://dummy.db', *args, **kwargs):
if not hasattr(THREAD_LOCAL,'db_instances'): if not hasattr(THREAD_LOCAL,'db_instances'):
THREAD_LOCAL.db_instances = {} THREAD_LOCAL.db_instances = {}
if not hasattr(THREAD_LOCAL,'db_instances_zombie'): if not hasattr(THREAD_LOCAL,'db_instances_zombie'):
@@ -6746,9 +6746,9 @@ class DAL(object):
kwargs = dict(db=self,uri=uri, kwargs = dict(db=self,uri=uri,
pool_size=pool_size, pool_size=pool_size,
folder=folder, folder=folder,
db_codec=db_codec, db_codec=db_codec,
credential_decoder=credential_decoder, credential_decoder=credential_decoder,
driver_args=driver_args or {}, driver_args=driver_args or {},
adapter_args=adapter_args or {}, adapter_args=adapter_args or {},
do_connect=do_connect) do_connect=do_connect)
self._adapter = ADAPTERS[self._dbname](**kwargs) self._adapter = ADAPTERS[self._dbname](**kwargs)
@@ -7184,7 +7184,7 @@ def index():
def close(self): def close(self):
self._adapter.close() self._adapter.close()
if self._db_uid in THREAD_LOCAL.db_instances: if self._db_uid in THREAD_LOCAL.db_instances:
db_group = THREAD_LOCAL.db_instances[self._db_uid] db_group = THREAD_LOCAL.db_instances[self._db_uid]
db_group.remove(self) db_group.remove(self)
if not db_group: if not db_group:
@@ -9548,3 +9548,4 @@ DAL.Table = Table # was necessary in gluon/globals.py session.connect
if __name__ == '__main__': if __name__ == '__main__':
import doctest import doctest
doctest.testmod() doctest.testmod()
+1
View File
@@ -193,3 +193,4 @@ gluon.main.global_settings.debugging = True
+1
View File
@@ -79,3 +79,4 @@ def decoder(buffer):
+1
View File
@@ -398,3 +398,4 @@ def abspath(*relpath, **base):
+13 -12
View File
@@ -251,11 +251,11 @@ class Response(Storage):
if item.endswith('.css'): if item.endswith('.css'):
has_css = True has_css = True
files.append(item) files.append(item)
if have_minify and ((self.optimize_css and has_css) or (self.optimize_js and has_js)): if have_minify and ((self.optimize_css and has_css) or (self.optimize_js and has_js)):
# cache for 5 minutes by default # cache for 5 minutes by default
key = hashlib.md5(repr(files)).hexdigest() key = hashlib.md5(repr(files)).hexdigest()
cache = self.cache_includes or (current.cache.ram, 60*5) cache = self.cache_includes or (current.cache.ram, 60*5)
def call_minify(files=files): def call_minify(files=files):
return minify.minify(files, return minify.minify(files,
@@ -344,7 +344,7 @@ class Response(Storage):
os.path.getsize(filename) os.path.getsize(filename)
except OSError: except OSError:
pass pass
env = request.env env = request.env
# Internet Explorer < 9.0 will not allow downloads over SSL unless caching is enabled # Internet Explorer < 9.0 will not allow downloads over SSL unless caching is enabled
if request.is_https and isinstance(env.http_user_agent,str) and \ if request.is_https and isinstance(env.http_user_agent,str) and \
@@ -388,7 +388,7 @@ class Response(Storage):
headers['Content-Disposition'] = \ headers['Content-Disposition'] = \
'attachment; filename=%s' % filename 'attachment; filename=%s' % filename
return self.stream(stream, chunk_size=chunk_size, request=request) return self.stream(stream, chunk_size=chunk_size, request=request)
def json(self, data, default=None): def json(self, data, default=None):
return json(data, default = default or custom_json) return json(data, default = default or custom_json)
@@ -425,9 +425,9 @@ class Response(Storage):
dbstats = [TABLE(*[TR(PRE(row[0]),'%.2fms' % (row[1]*1000)) \ dbstats = [TABLE(*[TR(PRE(row[0]),'%.2fms' % (row[1]*1000)) \
for row in i.db._timings]) \ for row in i.db._timings]) \
for i in THREAD_LOCAL.instances] for i in THREAD_LOCAL.instances]
dbtables = dict([(regex_nopasswd.sub('******',i.uri), dbtables = dict([(regex_nopasswd.sub('******',i.uri),
{'defined': {'defined':
sorted(list(set(i.db.tables) - sorted(list(set(i.db.tables) -
set(i.db._LAZY_TABLES.keys()))) or set(i.db._LAZY_TABLES.keys()))) or
'[no defined tables]', '[no defined tables]',
'lazy': sorted(i.db._LAZY_TABLES.keys()) or 'lazy': sorted(i.db._LAZY_TABLES.keys()) or
@@ -489,7 +489,7 @@ class Session(Storage):
response.session_id_name = 'session_id_%s' % masterapp.lower() response.session_id_name = 'session_id_%s' % masterapp.lower()
response.session_data_name = 'session_data_%s' % masterapp.lower() response.session_data_name = 'session_data_%s' % masterapp.lower()
response.session_cookie_expires = cookie_expires response.session_cookie_expires = cookie_expires
# Load session data from cookie # Load session data from cookie
cookies = request.cookies cookies = request.cookies
@@ -505,7 +505,7 @@ class Session(Storage):
session_cookie_data = cookies[response.session_data_name].value session_cookie_data = cookies[response.session_data_name].value
else: else:
session_cookie_data = None session_cookie_data = None
# if we are supposed to use cookie based session data # if we are supposed to use cookie based session data
if cookie_key: if cookie_key:
response.session_storage_type = 'cookie' response.session_storage_type = 'cookie'
@@ -658,11 +658,11 @@ class Session(Storage):
name = response.session_data_name name = response.session_data_name
value = secure_dumps(dict(self),response.session_cookie_key, compression_level=response.session_cookie_compression_level) value = secure_dumps(dict(self),response.session_cookie_key, compression_level=response.session_cookie_compression_level)
expires = response.session_cookie_expires expires = response.session_cookie_expires
rcookies = response.cookies rcookies = response.cookies
rcookies.pop(name,None) rcookies.pop(name,None)
rcookies[name] = value rcookies[name] = value
rcookies[name]['path'] = '/' rcookies[name]['path'] = '/'
if expires: if expires:
rcookies[name]['expires'] = expires.strftime(FMT) rcookies[name]['expires'] = expires.strftime(FMT)
return True return True
@@ -751,3 +751,4 @@ class Session(Storage):
del response.session_file del response.session_file
except: except:
pass pass
+1
View File
@@ -349,3 +349,4 @@ if __name__ == '__main__':
+2 -1
View File
@@ -2064,7 +2064,7 @@ class FORM(DIV):
message_onfailure = kwargs.get('message_onfailure', message_onfailure = kwargs.get('message_onfailure',
current.T("Errors in form, please check it out.")) current.T("Errors in form, please check it out."))
message_onchange = kwargs.get('message_onchange', message_onchange = kwargs.get('message_onchange',
current.T("Form consecutive submissions not allowed. " + current.T("Form consecutive submissions not allowed. " +
"Try re-submitting or refreshing the form page.")) "Try re-submitting or refreshing the form page."))
next = kwargs.get('next',None) next = kwargs.get('next',None)
for key in ('message_onsuccess','message_onfailure','onsuccess', for key in ('message_onsuccess','message_onfailure','onsuccess',
@@ -2535,3 +2535,4 @@ class MARKMIN(XmlComponent):
if __name__ == '__main__': if __name__ == '__main__':
import doctest import doctest
doctest.testmod() doctest.testmod()
+1
View File
@@ -156,3 +156,4 @@ def redirect(location, how=303, client_side=False):
+1
View File
@@ -114,3 +114,4 @@ for module in base_modules + contributed_modules:
+17 -16
View File
@@ -166,7 +166,7 @@ def read_possible_plural_rules():
pname = modname+'.py' pname = modname+'.py'
nplurals = getattr(module,'nplurals', DEFAULT_NPLURALS) nplurals = getattr(module,'nplurals', DEFAULT_NPLURALS)
get_plural_id = getattr( get_plural_id = getattr(
module,'get_plural_id', module,'get_plural_id',
DEFAULT_GET_PLURAL_ID) DEFAULT_GET_PLURAL_ID)
construct_plural_form = getattr( construct_plural_form = getattr(
module,'construct_plural_form', module,'construct_plural_form',
@@ -210,7 +210,7 @@ def read_possible_languages_aux(langdir):
nplurals, # nplurals for current language nplurals, # nplurals for current language
get_plural_id, # get_plural_id() for current language get_plural_id, # get_plural_id() for current language
construct_plural_form) # construct_plural_form() for current language construct_plural_form) # construct_plural_form() for current language
plurals = {} plurals = {}
flist = oslistdir(langdir) flist = oslistdir(langdir)
# scan languages directory for plural dict files: # scan languages directory for plural dict files:
@@ -223,7 +223,7 @@ def read_possible_languages_aux(langdir):
for fname in flist: for fname in flist:
if regex_langfile.match(fname) or fname == 'default.py': if regex_langfile.match(fname) or fname == 'default.py':
fname_with_path = pjoin(langdir,fname) fname_with_path = pjoin(langdir,fname)
d = read_dict(fname_with_path) d = read_dict(fname_with_path)
lang = fname[:-3] lang = fname[:-3]
langcode = d.get('!langcode!', lang if lang != 'default' langcode = d.get('!langcode!', lang if lang != 'default'
else DEFAULT_LANGUAGE) else DEFAULT_LANGUAGE)
@@ -241,7 +241,7 @@ def read_possible_languages_aux(langdir):
if deflangcode not in langs: if deflangcode not in langs:
# create language from default.py: # create language from default.py:
langs[deflangcode] = deflang[:2]+(0,)+deflang[3:] langs[deflangcode] = deflang[:2]+(0,)+deflang[3:]
return langs return langs
def read_possible_languages(appdir): def read_possible_languages(appdir):
@@ -403,11 +403,11 @@ class translator(object):
notice 1: there is no need to force since, by default, T uses notice 1: there is no need to force since, by default, T uses
http_accept_language to determine a translation file. http_accept_language to determine a translation file.
notice 2: notice 2:
en and en-en are considered different languages! en and en-en are considered different languages!
notice 3: notice 3:
if language xx-yy is not found force() probes other similar if language xx-yy is not found force() probes other similar
languages using such algorithm: languages using such algorithm:
xx-yy.py -> xx.py -> xx-yy*.py -> xx*.py xx-yy.py -> xx.py -> xx-yy*.py -> xx*.py
""" """
@@ -489,7 +489,7 @@ class translator(object):
languages[0], (tuple, list)): languages[0], (tuple, list)):
languages = languages[0] languages = languages[0]
if not languages or languages[0] is None: if not languages or languages[0] is None:
# set default language from default.py/DEFAULT_LANGUAGE # set default language from default.py/DEFAULT_LANGUAGE
pl_info = self.get_possible_languages_info('default') pl_info = self.get_possible_languages_info('default')
if pl_info[2]==0: # langfile_mtime if pl_info[2]==0: # langfile_mtime
# if languages/default.py is not found # if languages/default.py is not found
@@ -505,7 +505,7 @@ class translator(object):
self.current_languages = list(languages) self.current_languages = list(languages)
self.force(self.http_accept_language) self.force(self.http_accept_language)
def plural(self, word, n): def plural(self, word, n):
""" get plural form of word for number *n* """ get plural form of word for number *n*
NOTE: *word" MUST be defined in current language NOTE: *word" MUST be defined in current language
@@ -619,7 +619,7 @@ class translator(object):
self.language_file, self.language_file,
({},allocate_lock())) ({},allocate_lock()))
set_plural(language) set_plural(language)
self.accepted_language = language self.accepted_language = language
return languages return languages
self.accepted_language = language or self.current_languages[0] self.accepted_language = language or self.current_languages[0]
self.language_file = self.default_language_file self.language_file = self.default_language_file
@@ -676,7 +676,7 @@ class translator(object):
message = self.params_substitution(message, symbols) message = self.params_substitution(message, symbols)
return XML(message.translate(ttab_out)) return XML(message.translate(ttab_out))
def M(self, message, symbols={}, language=None, def M(self, message, symbols={}, language=None,
lazy=None, filter=None, ftag=None): lazy=None, filter=None, ftag=None):
""" """
get cached translated markmin-message with inserted parametes get cached translated markmin-message with inserted parametes
@@ -710,10 +710,10 @@ class translator(object):
the ## notation is ignored in multiline strings and strings that the ## notation is ignored in multiline strings and strings that
start with ##. this is to allow markmin syntax to be translated start with ##. this is to allow markmin syntax to be translated
""" """
if isinstance(message, unicode): if isinstance(message, unicode):
message = message.encode('utf8') message = message.encode('utf8')
if isinstance(prefix, unicode): if isinstance(prefix, unicode):
prefix = prefix.encode('utf8') prefix = prefix.encode('utf8')
key = prefix+message key = prefix+message
mt = self.t.get(key, None) mt = self.t.get(key, None)
if mt is not None: return mt if mt is not None: return mt
@@ -831,7 +831,7 @@ class translator(object):
""" """
get cached translated message with inserted parameters(symbols) get cached translated message with inserted parameters(symbols)
""" """
message = get_from_cache(self.cache, message, message = get_from_cache(self.cache, message,
lambda: self.get_t(message)) lambda: self.get_t(message))
if symbols or symbols == 0 or symbols == "": if symbols or symbols == 0 or symbols == "":
if isinstance(symbols, dict): if isinstance(symbols, dict):
@@ -905,3 +905,4 @@ def update_all_languages(application_path):
if __name__ == '__main__': if __name__ == '__main__':
import doctest import doctest
doctest.testmod() doctest.testmod()
+7 -6
View File
@@ -235,7 +235,7 @@ def serve_controller(request, response, session):
default_headers = [ default_headers = [
('Content-Type', contenttype('.'+request.extension)), ('Content-Type', contenttype('.'+request.extension)),
('Cache-Control','no-store, no-cache, must-revalidate, post-check=0, pre-check=0'), ('Cache-Control','no-store, no-cache, must-revalidate, post-check=0, pre-check=0'),
('Expires', time.strftime('%a, %d %b %Y %H:%M:%S GMT', ('Expires', time.strftime('%a, %d %b %Y %H:%M:%S GMT',
time.gmtime())), time.gmtime())),
('Pragma', 'no-cache')] ('Pragma', 'no-cache')]
for key,value in default_headers: for key,value in default_headers:
@@ -440,7 +440,7 @@ def wsgibase(environ, responder):
local_hosts = global_settings.local_hosts local_hosts = global_settings.local_hosts
client = get_client(env) client = get_client(env)
x_req_with = str(env.http_x_requested_with).lower() x_req_with = str(env.http_x_requested_with).lower()
request.update( request.update(
client = client, client = client,
folder = abspath('applications',app) + os.sep, folder = abspath('applications',app) + os.sep,
@@ -524,14 +524,14 @@ def wsgibase(environ, responder):
import gluon.debug import gluon.debug
# activate the debugger # activate the debugger
gluon.debug.dbg.do_debug(mainpyfile=request.folder) gluon.debug.dbg.do_debug(mainpyfile=request.folder)
serve_controller(request, response, session) serve_controller(request, response, session)
except HTTP, http_response: except HTTP, http_response:
if static_file: if static_file:
return http_response.to(responder,env=env) return http_response.to(responder,env=env)
if request.body: if request.body:
request.body.close() request.body.close()
@@ -557,9 +557,9 @@ def wsgibase(environ, responder):
# if session not in db try store session on filesystem # if session not in db try store session on filesystem
# this must be done after trying to commit database! # this must be done after trying to commit database!
# ################################################## # ##################################################
session._try_store_in_cookie_or_file(request, response) session._try_store_in_cookie_or_file(request, response)
if request.cid: if request.cid:
if response.flash: if response.flash:
http_response.headers['web2py-component-flash'] = urllib2.quote(xmlescape(response.flash).replace('\n','')) http_response.headers['web2py-component-flash'] = urllib2.quote(xmlescape(response.flash).replace('\n',''))
@@ -858,3 +858,4 @@ class HttpServer(object):
except: except:
pass pass
+1
View File
@@ -15,3 +15,4 @@ class MessageBoxHandler(logging.Handler):
tkMessageBox.showinfo('info1', msg) tkMessageBox.showinfo('info1', msg)
+1
View File
@@ -33,3 +33,4 @@ regex_extend = re.compile(\
+2 -1
View File
@@ -330,7 +330,7 @@ def crondance(applications_parent, ctype='soft', startup=False, apps=None):
commands = command commands = command
# from python docs: # from python docs:
# You do not need shell=True to run a batch file or # You do not need shell=True to run a batch file or
# console-based executable. # console-based executable.
shell = False shell = False
@@ -348,3 +348,4 @@ def crondance(applications_parent, ctype='soft', startup=False, apps=None):
+3 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# portalocker.py # portalocker.py
# Cross-platform (posix/nt) API for flock-style file locking. # Cross-platform (posix/nt) API for flock-style file locking.
# Requires python 1.5.2 or better. # Requires python 1.5.2 or better.
@@ -142,7 +142,7 @@ class LockedFile(object):
def __del__(self): def __del__(self):
if not self.file is None: if not self.file is None:
self.close() self.close()
def read_locked(filename): def read_locked(filename):
fp = LockedFile(filename, 'r') fp = LockedFile(filename, 'r')
data = fp.read() data = fp.read()
@@ -165,3 +165,4 @@ if __name__=='__main__':
+1
View File
@@ -1718,3 +1718,4 @@ ADAPTERS['all'] = reduce(lambda a,b:a.union(b),(x for x in ADAPTERS.values()))
+2 -1
View File
@@ -100,7 +100,7 @@ class TicketStorage(Storage):
table = self._get_table(self.db, self.tablename, app) table = self._get_table(self.db, self.tablename, app)
rows = self.db(table.ticket_id == ticket_id).select() rows = self.db(table.ticket_id == ticket_id).select()
return cPickle.loads(rows[0].ticket_data) if rows else {} return cPickle.loads(rows[0].ticket_data) if rows else {}
class RestrictedError(Exception): class RestrictedError(Exception):
@@ -312,3 +312,4 @@ def snapshot(info=None, context=5, code=None, environment=None):
+7 -6
View File
@@ -197,7 +197,7 @@ def url_out(request, environ, application, controller, function,
host = request.env.http_host host = request.env.http_host
if not scheme or scheme is True: if not scheme or scheme is True:
scheme = request.env.get('wsgi_url_scheme', 'http').lower() \ scheme = request.env.get('wsgi_url_scheme', 'http').lower() \
if request else 'http' if request else 'http'
if host: if host:
host_port = host if not port else host.split(':',1)[0]+':%s'%port host_port = host if not port else host.split(':',1)[0]+':%s'%port
url = '%s://%s%s' % (scheme, host_port, url) url = '%s://%s%s' % (scheme, host_port, url)
@@ -579,7 +579,7 @@ def regex_filter_in(e):
e['REQUEST_URI'] = e['PATH_INFO'] + (query and ('?' + query) or '') e['REQUEST_URI'] = e['PATH_INFO'] + (query and ('?' + query) or '')
return e return e
def sluggify(key): def sluggify(key):
return key.lower().replace('.','_') return key.lower().replace('.','_')
@@ -609,7 +609,7 @@ def regex_url_in(request, environ):
if not match: if not match:
raise HTTP(400, raise HTTP(400,
routes.error_message % 'invalid request', routes.error_message % 'invalid request',
web2py_error='invalid path') web2py_error='invalid path')
elif match.group('c')=='static': elif match.group('c')=='static':
application = match.group('a') application = match.group('a')
version, filename = None, match.group('z') version, filename = None, match.group('z')
@@ -623,9 +623,9 @@ def regex_url_in(request, environ):
else: else:
# ################################################## # ##################################################
# parse application, controller and function # parse application, controller and function
# ################################################## # ##################################################
request.application = match.group('a') or routes.default_application request.application = match.group('a') or routes.default_application
request.controller = match.group('c') or routes.default_controller request.controller = match.group('c') or routes.default_controller
request.function = match.group('f') or routes.default_function request.function = match.group('f') or routes.default_function
request.raw_extension = match.group('e') request.raw_extension = match.group('e')
request.extension = request.raw_extension or 'html' request.extension = request.raw_extension or 'html'
@@ -1316,3 +1316,4 @@ def get_effective_router(appname):
if not routers or appname not in routers: if not routers or appname not in routers:
return None return None
return Storage(routers[appname]) # return a copy return Storage(routers[appname]) # return a copy
+1
View File
@@ -1881,3 +1881,4 @@ if __name__=='__main__':

Some files were not shown because too many files have changed in this diff Show More