fixed some pep8 stuff
This commit is contained in:
@@ -53,3 +53,4 @@ if 0:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -481,3 +481,4 @@ def create_missing_app_folders(request):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+6
-5
@@ -46,13 +46,13 @@ class CacheAbstract(object):
|
||||
Main function is now to provide referenced api documentation.
|
||||
|
||||
Use CacheInRam or CacheOnDisk instead which are derived from this class.
|
||||
|
||||
|
||||
Attentions, Michele says:
|
||||
|
||||
There are signatures inside gdbm files that are used directly
|
||||
by the python gdbm adapter that often are lagging behind in the
|
||||
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.
|
||||
Using gdbm directly from C would work, because there is backward
|
||||
compatibility, but not from python!
|
||||
@@ -258,7 +258,7 @@ class CacheOnDisk(CacheAbstract):
|
||||
on self.locker first. Replaces the close method of the
|
||||
returned shelf instance with one that releases the lock upon
|
||||
closing."""
|
||||
|
||||
|
||||
storage = None
|
||||
locker = None
|
||||
locked = False
|
||||
@@ -296,7 +296,7 @@ class CacheOnDisk(CacheAbstract):
|
||||
self.initialized = False
|
||||
self.request = request
|
||||
self.folder = folder
|
||||
|
||||
|
||||
def initialize(self):
|
||||
if self.initialized: return
|
||||
else: self.initialized = True
|
||||
@@ -468,7 +468,7 @@ class Cache(object):
|
||||
"""
|
||||
allow replacing cache.ram with cache.with_prefix(cache.ram,'prefix')
|
||||
it will add prefix to all the cache keys used.
|
||||
"""
|
||||
"""
|
||||
return lambda key, f, time_expire=DEFAULT_TIME_EXPIRE, prefix=prefix:\
|
||||
cache_model(prefix + key, f, time_expire)
|
||||
|
||||
@@ -492,3 +492,4 @@ def lazy_cache(key=None,time_expire=None,cache_model='ram'):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -58,3 +58,4 @@ def getcfs(key, filename, filter=None):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+2
-1
@@ -371,7 +371,7 @@ _base_environment_['SQLField'] = SQLField # for backward compatibility
|
||||
_base_environment_['SQLFORM'] = SQLFORM
|
||||
_base_environment_['SQLTABLE'] = SQLTABLE
|
||||
_base_environment_['LOAD'] = LOAD
|
||||
|
||||
|
||||
def build_environment(request, response, session, store_current=True):
|
||||
"""
|
||||
Build the environment dictionary into which web2py files are executed.
|
||||
@@ -707,3 +707,4 @@ if __name__ == '__main__':
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -724,3 +724,4 @@ def contenttype(filename, default='text/plain'):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -264,3 +264,4 @@ if __name__=='__main__':
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -244,3 +244,4 @@ if __name__=='__main__':
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -6,3 +6,4 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -502,3 +502,4 @@ aes_Rcon = array('B',
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -205,3 +205,4 @@ if __name__=="__main__":
|
||||
print test()
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -3911,3 +3911,4 @@ def parse(url_file_stream_or_string, etag=None, modified=None, agent=None, refer
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class MemcacheClient(object):
|
||||
key,
|
||||
f,
|
||||
time_expire=300,
|
||||
):
|
||||
):
|
||||
key = '%s/%s' % (self.request.application, key)
|
||||
dt = time_expire
|
||||
value = None
|
||||
@@ -44,7 +44,7 @@ class MemcacheClient(object):
|
||||
obj = self.client.get(key)
|
||||
if obj:
|
||||
value = obj[1] + value
|
||||
self.client.set(key, (time.time(), value))
|
||||
self.client.set(key, (time.time(), value))
|
||||
return value
|
||||
|
||||
def clear(self, key = None):
|
||||
@@ -65,3 +65,4 @@ class MemcacheClient(object):
|
||||
|
||||
def flush_all(self,*a,**b):
|
||||
return self.client.delete(*a,**b)
|
||||
|
||||
|
||||
@@ -91,3 +91,4 @@ def autoretry_datastore_timeouts(attempts=5.0, interval=0.1, exponent=2.0):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -68,3 +68,4 @@ def pdf_from_html(html):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -20,3 +20,4 @@ def button(merchant_id="123456789012345",
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -10,3 +10,4 @@ from gluon.dal import DAL, Field, Table, Query, Set, Expression, Row, Rows, driv
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -59,3 +59,4 @@ def THUMB(image, nx=120, ny=120, gae=False, name='thumb'):
|
||||
return image
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -912,3 +912,4 @@ if __name__ == '__main__':
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -128,3 +128,4 @@ if __name__ == "__main__":
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -130,3 +130,4 @@ if __name__ == '__main__':
|
||||
test()
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -172,3 +172,4 @@ if __name__ == '__main__':
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -10,3 +10,4 @@ from fpdf import *
|
||||
# import warnings
|
||||
# warnings.warn("pyfpdf package name is deprecated, please use fpdf instead")
|
||||
|
||||
|
||||
|
||||
@@ -965,3 +965,4 @@ if __name__ == '__main__':
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -168,3 +168,4 @@ class RedisClient(object):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ class MockTable(object):
|
||||
|
||||
class MockQuery(object):
|
||||
"""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):
|
||||
self.field = field
|
||||
@@ -187,15 +187,15 @@ class MockQuery(object):
|
||||
|
||||
class RecordDeleter(object):
|
||||
"""Dumb record deleter to support sessions2trash.py"""
|
||||
|
||||
|
||||
def __init__(self, db, key, keyprefix):
|
||||
self.db, self.key, self.keyprefix = db, key, keyprefix
|
||||
|
||||
|
||||
def __call__(self):
|
||||
id_idx = "%s:id_idx" % self.keyprefix
|
||||
#remove from the index
|
||||
self.db.srem(id_idx, self.key)
|
||||
#remove the key itself
|
||||
self.db.delete(self.key)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -593,3 +593,4 @@ if __name__ == '__main__':
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -271,3 +271,4 @@ if __name__=='__main__':
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -152,3 +152,4 @@ if __name__ == "__main__":
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -117,3 +117,4 @@ def sms_email(number,provider):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -880,3 +880,4 @@ if __name__ == '__main__':
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -67,3 +67,4 @@ if __name__=='__main__':
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -248,3 +248,4 @@ class TaskBarIcon:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -96,3 +96,4 @@ if __name__=='__main__':
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -521,3 +521,4 @@ class mobilize(object):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ mostly for testing purposes
|
||||
|
||||
- customizable
|
||||
- supports basic auth
|
||||
- supports cookies
|
||||
- supports cookies
|
||||
- supports session cookies (tested with web2py sessions)
|
||||
- detects broken session
|
||||
- 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):
|
||||
self.url = self.app+url
|
||||
|
||||
|
||||
# if this POST form requires a postback do it
|
||||
if data and '_formname' in data and self.postbacks and \
|
||||
self.history and self.history[-1][1]!=self.url:
|
||||
@@ -202,3 +202,4 @@ if __name__ == '__main__':
|
||||
test_web2py_registration_and_login()
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -195,3 +195,4 @@ if __name__ == "__main__":
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -188,3 +188,4 @@ class TrackImporter(object):
|
||||
return file
|
||||
|
||||
TRACK_IMPORTER = TrackImporter()
|
||||
|
||||
|
||||
+9
-8
@@ -500,7 +500,7 @@ class ConnectionPool(object):
|
||||
|
||||
# ## 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 callable(action):
|
||||
action(self)
|
||||
@@ -599,7 +599,7 @@ class BaseAdapter(ConnectionPool):
|
||||
support_distributed_transaction = False
|
||||
uploads_in_blob = False
|
||||
can_select_for_update = True
|
||||
|
||||
|
||||
TRUE = 'T'
|
||||
FALSE = 'F'
|
||||
types = {
|
||||
@@ -1661,7 +1661,7 @@ class BaseAdapter(ConnectionPool):
|
||||
|
||||
def prepare(self, key):
|
||||
if self.connection: self.connection.prepare()
|
||||
|
||||
|
||||
def commit_prepared(self, key):
|
||||
if self.connection: self.connection.commit()
|
||||
|
||||
@@ -6572,7 +6572,7 @@ def smart_query(fields,text):
|
||||
elif field._db._adapter.dbengine=='google:datastore' and \
|
||||
field.type in ('list:integer', 'list:string', 'list:reference'):
|
||||
if op == 'contains': new_query = field.contains(value)
|
||||
else: raise RuntimeError, "Invalid operation"
|
||||
else: raise RuntimeError, "Invalid operation"
|
||||
else: raise RuntimeError, "Invalid operation"
|
||||
if neg: new_query = ~new_query
|
||||
if query is None:
|
||||
@@ -6596,7 +6596,7 @@ class DAL(object):
|
||||
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'):
|
||||
THREAD_LOCAL.db_instances = {}
|
||||
if not hasattr(THREAD_LOCAL,'db_instances_zombie'):
|
||||
@@ -6746,9 +6746,9 @@ class DAL(object):
|
||||
kwargs = dict(db=self,uri=uri,
|
||||
pool_size=pool_size,
|
||||
folder=folder,
|
||||
db_codec=db_codec,
|
||||
db_codec=db_codec,
|
||||
credential_decoder=credential_decoder,
|
||||
driver_args=driver_args or {},
|
||||
driver_args=driver_args or {},
|
||||
adapter_args=adapter_args or {},
|
||||
do_connect=do_connect)
|
||||
self._adapter = ADAPTERS[self._dbname](**kwargs)
|
||||
@@ -7184,7 +7184,7 @@ def index():
|
||||
|
||||
def close(self):
|
||||
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.remove(self)
|
||||
if not db_group:
|
||||
@@ -9548,3 +9548,4 @@ DAL.Table = Table # was necessary in gluon/globals.py session.connect
|
||||
if __name__ == '__main__':
|
||||
import doctest
|
||||
doctest.testmod()
|
||||
|
||||
|
||||
@@ -193,3 +193,4 @@ gluon.main.global_settings.debugging = True
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -79,3 +79,4 @@ def decoder(buffer):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -398,3 +398,4 @@ def abspath(*relpath, **base):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+13
-12
@@ -251,11 +251,11 @@ class Response(Storage):
|
||||
if item.endswith('.css'):
|
||||
has_css = True
|
||||
files.append(item)
|
||||
|
||||
|
||||
if have_minify and ((self.optimize_css and has_css) or (self.optimize_js and has_js)):
|
||||
# cache for 5 minutes by default
|
||||
key = hashlib.md5(repr(files)).hexdigest()
|
||||
|
||||
|
||||
cache = self.cache_includes or (current.cache.ram, 60*5)
|
||||
def call_minify(files=files):
|
||||
return minify.minify(files,
|
||||
@@ -344,7 +344,7 @@ class Response(Storage):
|
||||
os.path.getsize(filename)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
||||
env = request.env
|
||||
# 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 \
|
||||
@@ -388,7 +388,7 @@ class Response(Storage):
|
||||
headers['Content-Disposition'] = \
|
||||
'attachment; filename=%s' % filename
|
||||
return self.stream(stream, chunk_size=chunk_size, request=request)
|
||||
|
||||
|
||||
|
||||
def json(self, data, default=None):
|
||||
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)) \
|
||||
for row in i.db._timings]) \
|
||||
for i in THREAD_LOCAL.instances]
|
||||
dbtables = dict([(regex_nopasswd.sub('******',i.uri),
|
||||
{'defined':
|
||||
sorted(list(set(i.db.tables) -
|
||||
dbtables = dict([(regex_nopasswd.sub('******',i.uri),
|
||||
{'defined':
|
||||
sorted(list(set(i.db.tables) -
|
||||
set(i.db._LAZY_TABLES.keys()))) or
|
||||
'[no defined tables]',
|
||||
'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_data_name = 'session_data_%s' % masterapp.lower()
|
||||
response.session_cookie_expires = cookie_expires
|
||||
|
||||
|
||||
# Load session data from cookie
|
||||
cookies = request.cookies
|
||||
|
||||
@@ -505,7 +505,7 @@ class Session(Storage):
|
||||
session_cookie_data = cookies[response.session_data_name].value
|
||||
else:
|
||||
session_cookie_data = None
|
||||
|
||||
|
||||
# if we are supposed to use cookie based session data
|
||||
if cookie_key:
|
||||
response.session_storage_type = 'cookie'
|
||||
@@ -658,11 +658,11 @@ class Session(Storage):
|
||||
name = response.session_data_name
|
||||
value = secure_dumps(dict(self),response.session_cookie_key, compression_level=response.session_cookie_compression_level)
|
||||
expires = response.session_cookie_expires
|
||||
rcookies = response.cookies
|
||||
rcookies.pop(name,None)
|
||||
rcookies = response.cookies
|
||||
rcookies.pop(name,None)
|
||||
rcookies[name] = value
|
||||
rcookies[name]['path'] = '/'
|
||||
if expires:
|
||||
if expires:
|
||||
rcookies[name]['expires'] = expires.strftime(FMT)
|
||||
return True
|
||||
|
||||
@@ -751,3 +751,4 @@ class Session(Storage):
|
||||
del response.session_file
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
@@ -349,3 +349,4 @@ if __name__ == '__main__':
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+2
-1
@@ -2064,7 +2064,7 @@ class FORM(DIV):
|
||||
message_onfailure = kwargs.get('message_onfailure',
|
||||
current.T("Errors in form, please check it out."))
|
||||
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."))
|
||||
next = kwargs.get('next',None)
|
||||
for key in ('message_onsuccess','message_onfailure','onsuccess',
|
||||
@@ -2535,3 +2535,4 @@ class MARKMIN(XmlComponent):
|
||||
if __name__ == '__main__':
|
||||
import doctest
|
||||
doctest.testmod()
|
||||
|
||||
|
||||
@@ -156,3 +156,4 @@ def redirect(location, how=303, client_side=False):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -114,3 +114,4 @@ for module in base_modules + contributed_modules:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+17
-16
@@ -166,7 +166,7 @@ def read_possible_plural_rules():
|
||||
pname = modname+'.py'
|
||||
nplurals = getattr(module,'nplurals', DEFAULT_NPLURALS)
|
||||
get_plural_id = getattr(
|
||||
module,'get_plural_id',
|
||||
module,'get_plural_id',
|
||||
DEFAULT_GET_PLURAL_ID)
|
||||
construct_plural_form = getattr(
|
||||
module,'construct_plural_form',
|
||||
@@ -210,7 +210,7 @@ def read_possible_languages_aux(langdir):
|
||||
nplurals, # nplurals for current language
|
||||
get_plural_id, # get_plural_id() for current language
|
||||
construct_plural_form) # construct_plural_form() for current language
|
||||
|
||||
|
||||
plurals = {}
|
||||
flist = oslistdir(langdir)
|
||||
# scan languages directory for plural dict files:
|
||||
@@ -223,7 +223,7 @@ def read_possible_languages_aux(langdir):
|
||||
for fname in flist:
|
||||
if regex_langfile.match(fname) or fname == 'default.py':
|
||||
fname_with_path = pjoin(langdir,fname)
|
||||
d = read_dict(fname_with_path)
|
||||
d = read_dict(fname_with_path)
|
||||
lang = fname[:-3]
|
||||
langcode = d.get('!langcode!', lang if lang != 'default'
|
||||
else DEFAULT_LANGUAGE)
|
||||
@@ -241,7 +241,7 @@ def read_possible_languages_aux(langdir):
|
||||
if deflangcode not in langs:
|
||||
# create language from default.py:
|
||||
langs[deflangcode] = deflang[:2]+(0,)+deflang[3:]
|
||||
|
||||
|
||||
return langs
|
||||
|
||||
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
|
||||
http_accept_language to determine a translation file.
|
||||
notice 2:
|
||||
notice 2:
|
||||
en and en-en are considered different languages!
|
||||
notice 3:
|
||||
notice 3:
|
||||
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
|
||||
"""
|
||||
|
||||
@@ -489,7 +489,7 @@ class translator(object):
|
||||
languages[0], (tuple, list)):
|
||||
languages = languages[0]
|
||||
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')
|
||||
if pl_info[2]==0: # langfile_mtime
|
||||
# if languages/default.py is not found
|
||||
@@ -505,7 +505,7 @@ class translator(object):
|
||||
self.current_languages = list(languages)
|
||||
self.force(self.http_accept_language)
|
||||
|
||||
|
||||
|
||||
def plural(self, word, n):
|
||||
""" get plural form of word for number *n*
|
||||
NOTE: *word" MUST be defined in current language
|
||||
@@ -619,7 +619,7 @@ class translator(object):
|
||||
self.language_file,
|
||||
({},allocate_lock()))
|
||||
set_plural(language)
|
||||
self.accepted_language = language
|
||||
self.accepted_language = language
|
||||
return languages
|
||||
self.accepted_language = language or self.current_languages[0]
|
||||
self.language_file = self.default_language_file
|
||||
@@ -676,7 +676,7 @@ class translator(object):
|
||||
message = self.params_substitution(message, symbols)
|
||||
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):
|
||||
"""
|
||||
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
|
||||
start with ##. this is to allow markmin syntax to be translated
|
||||
"""
|
||||
if isinstance(message, unicode):
|
||||
message = message.encode('utf8')
|
||||
if isinstance(prefix, unicode):
|
||||
prefix = prefix.encode('utf8')
|
||||
if isinstance(message, unicode):
|
||||
message = message.encode('utf8')
|
||||
if isinstance(prefix, unicode):
|
||||
prefix = prefix.encode('utf8')
|
||||
key = prefix+message
|
||||
mt = self.t.get(key, None)
|
||||
if mt is not None: return mt
|
||||
@@ -831,7 +831,7 @@ class translator(object):
|
||||
"""
|
||||
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))
|
||||
if symbols or symbols == 0 or symbols == "":
|
||||
if isinstance(symbols, dict):
|
||||
@@ -905,3 +905,4 @@ def update_all_languages(application_path):
|
||||
if __name__ == '__main__':
|
||||
import doctest
|
||||
doctest.testmod()
|
||||
|
||||
|
||||
+7
-6
@@ -235,7 +235,7 @@ def serve_controller(request, response, session):
|
||||
default_headers = [
|
||||
('Content-Type', contenttype('.'+request.extension)),
|
||||
('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())),
|
||||
('Pragma', 'no-cache')]
|
||||
for key,value in default_headers:
|
||||
@@ -440,7 +440,7 @@ def wsgibase(environ, responder):
|
||||
local_hosts = global_settings.local_hosts
|
||||
client = get_client(env)
|
||||
x_req_with = str(env.http_x_requested_with).lower()
|
||||
|
||||
|
||||
request.update(
|
||||
client = client,
|
||||
folder = abspath('applications',app) + os.sep,
|
||||
@@ -524,14 +524,14 @@ def wsgibase(environ, responder):
|
||||
import gluon.debug
|
||||
# activate the debugger
|
||||
gluon.debug.dbg.do_debug(mainpyfile=request.folder)
|
||||
|
||||
|
||||
serve_controller(request, response, session)
|
||||
|
||||
except HTTP, http_response:
|
||||
|
||||
if static_file:
|
||||
return http_response.to(responder,env=env)
|
||||
|
||||
|
||||
if request.body:
|
||||
request.body.close()
|
||||
|
||||
@@ -557,9 +557,9 @@ def wsgibase(environ, responder):
|
||||
# if session not in db try store session on filesystem
|
||||
# this must be done after trying to commit database!
|
||||
# ##################################################
|
||||
|
||||
|
||||
session._try_store_in_cookie_or_file(request, response)
|
||||
|
||||
|
||||
if request.cid:
|
||||
if response.flash:
|
||||
http_response.headers['web2py-component-flash'] = urllib2.quote(xmlescape(response.flash).replace('\n',''))
|
||||
@@ -858,3 +858,4 @@ class HttpServer(object):
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
@@ -15,3 +15,4 @@ class MessageBoxHandler(logging.Handler):
|
||||
tkMessageBox.showinfo('info1', msg)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -33,3 +33,4 @@ regex_extend = re.compile(\
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+2
-1
@@ -330,7 +330,7 @@ def crondance(applications_parent, ctype='soft', startup=False, apps=None):
|
||||
commands = command
|
||||
|
||||
# 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.
|
||||
shell = False
|
||||
|
||||
@@ -348,3 +348,4 @@ def crondance(applications_parent, ctype='soft', startup=False, apps=None):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# portalocker.py
|
||||
# portalocker.py
|
||||
# Cross-platform (posix/nt) API for flock-style file locking.
|
||||
# Requires python 1.5.2 or better.
|
||||
|
||||
@@ -142,7 +142,7 @@ class LockedFile(object):
|
||||
def __del__(self):
|
||||
if not self.file is None:
|
||||
self.close()
|
||||
|
||||
|
||||
def read_locked(filename):
|
||||
fp = LockedFile(filename, 'r')
|
||||
data = fp.read()
|
||||
@@ -165,3 +165,4 @@ if __name__=='__main__':
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1718,3 +1718,4 @@ ADAPTERS['all'] = reduce(lambda a,b:a.union(b),(x for x in ADAPTERS.values()))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+2
-1
@@ -100,7 +100,7 @@ class TicketStorage(Storage):
|
||||
table = self._get_table(self.db, self.tablename, app)
|
||||
rows = self.db(table.ticket_id == ticket_id).select()
|
||||
return cPickle.loads(rows[0].ticket_data) if rows else {}
|
||||
|
||||
|
||||
|
||||
|
||||
class RestrictedError(Exception):
|
||||
@@ -312,3 +312,4 @@ def snapshot(info=None, context=5, code=None, environment=None):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+7
-6
@@ -197,7 +197,7 @@ def url_out(request, environ, application, controller, function,
|
||||
host = request.env.http_host
|
||||
if not scheme or scheme is True:
|
||||
scheme = request.env.get('wsgi_url_scheme', 'http').lower() \
|
||||
if request else 'http'
|
||||
if request else 'http'
|
||||
if host:
|
||||
host_port = host if not port else host.split(':',1)[0]+':%s'%port
|
||||
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 '')
|
||||
return e
|
||||
|
||||
|
||||
|
||||
def sluggify(key):
|
||||
return key.lower().replace('.','_')
|
||||
|
||||
@@ -609,7 +609,7 @@ def regex_url_in(request, environ):
|
||||
if not match:
|
||||
raise HTTP(400,
|
||||
routes.error_message % 'invalid request',
|
||||
web2py_error='invalid path')
|
||||
web2py_error='invalid path')
|
||||
elif match.group('c')=='static':
|
||||
application = match.group('a')
|
||||
version, filename = None, match.group('z')
|
||||
@@ -623,9 +623,9 @@ def regex_url_in(request, environ):
|
||||
else:
|
||||
# ##################################################
|
||||
# parse application, controller and function
|
||||
# ##################################################
|
||||
request.application = match.group('a') or routes.default_application
|
||||
request.controller = match.group('c') or routes.default_controller
|
||||
# ##################################################
|
||||
request.application = match.group('a') or routes.default_application
|
||||
request.controller = match.group('c') or routes.default_controller
|
||||
request.function = match.group('f') or routes.default_function
|
||||
request.raw_extension = match.group('e')
|
||||
request.extension = request.raw_extension or 'html'
|
||||
@@ -1316,3 +1316,4 @@ def get_effective_router(appname):
|
||||
if not routers or appname not in routers:
|
||||
return None
|
||||
return Storage(routers[appname]) # return a copy
|
||||
|
||||
|
||||
@@ -1881,3 +1881,4 @@ if __name__=='__main__':
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -229,3 +229,4 @@ def sanitize(text, permitted_tags=[
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+5
-4
@@ -430,7 +430,7 @@ class Scheduler(MetaScheduler):
|
||||
current._scheduler = self
|
||||
|
||||
self.define_tables(db,migrate=migrate)
|
||||
|
||||
|
||||
def now(self):
|
||||
return self.utc_time and datetime.datetime.utcnow() or datetime.datetime.now()
|
||||
|
||||
@@ -440,7 +440,7 @@ class Scheduler(MetaScheduler):
|
||||
scheduler_task.application_name.default= '%s/%s' % (
|
||||
current.request.application, current.request.controller
|
||||
)
|
||||
|
||||
|
||||
def define_tables(self,db,migrate):
|
||||
from gluon.dal import DEFAULT
|
||||
logger.debug('defining tables (migrate=%s)' % migrate)
|
||||
@@ -482,7 +482,7 @@ class Scheduler(MetaScheduler):
|
||||
Field('assigned_worker_name',default='',writable=False),
|
||||
on_define=self.set_requirements,
|
||||
migrate=migrate,format='%(task_name)s')
|
||||
|
||||
|
||||
|
||||
db.define_table(
|
||||
'scheduler_run',
|
||||
@@ -855,7 +855,7 @@ class Scheduler(MetaScheduler):
|
||||
If output == True, returns also the last scheduler_run record
|
||||
scheduler_run record is fetched by a left join, so it can
|
||||
have all fields == None
|
||||
|
||||
|
||||
"""
|
||||
from gluon.dal import Query
|
||||
sr, st = self.db.scheduler_run, self.db.scheduler_task
|
||||
@@ -962,3 +962,4 @@ def main():
|
||||
|
||||
if __name__=='__main__':
|
||||
main()
|
||||
|
||||
|
||||
@@ -118,3 +118,4 @@ def rss(feed):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -38,3 +38,4 @@ global_settings.is_jython = \
|
||||
str(sys.copyright).find('Jython') > 0
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -431,3 +431,4 @@ if __name__ == '__main__':
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -10,3 +10,4 @@ from dal import DAL, Field, Table, Query, Set, Expression, Row, Rows, DRIVERS, B
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+10
-9
@@ -243,7 +243,7 @@ class ListWidget(StringWidget):
|
||||
attributes['_style'] = 'list-style:none'
|
||||
nvalue = value or ['']
|
||||
items = [LI(INPUT(_id=_id, _class=_class, _name=_name,
|
||||
value=v, hideerror=k<len(nvalue)-1,
|
||||
value=v, hideerror=k<len(nvalue)-1,
|
||||
requires=requires),
|
||||
**attributes) for (k,v) in enumerate(nvalue)]
|
||||
script=SCRIPT("""
|
||||
@@ -897,8 +897,8 @@ class SQLFORM(FORM):
|
||||
# if no fields are provided, build it from the provided table
|
||||
# will only use writable or readable fields, unless forced to ignore
|
||||
if fields is None:
|
||||
fields = [f.name for f in table if
|
||||
(ignore_rw or f.writable or f.readable) and
|
||||
fields = [f.name for f in table if
|
||||
(ignore_rw or f.writable or f.readable) and
|
||||
(readonly or not f.compute)]
|
||||
self.fields = fields
|
||||
|
||||
@@ -1260,8 +1260,8 @@ class SQLFORM(FORM):
|
||||
if self.record_changed and self.detect_record_change:
|
||||
message_onchange = \
|
||||
kwargs.setdefault("message_onchange",
|
||||
current.T("A record change was detected. " +
|
||||
"Consecutive update self-submissions " +
|
||||
current.T("A record change was detected. " +
|
||||
"Consecutive update self-submissions " +
|
||||
"are not allowed. Try re-submitting or " +
|
||||
"refreshing the form page."))
|
||||
if message_onchange is not None:
|
||||
@@ -1574,7 +1574,7 @@ class SQLFORM(FORM):
|
||||
_id='w2p_field_%s' % name,
|
||||
_class='w2p_query_row hidden',
|
||||
_style='display:inline'))
|
||||
|
||||
|
||||
criteria.insert(0,SELECT(
|
||||
_id="w2p_query_fields",
|
||||
_onchange="jQuery('.w2p_query_row').hide();jQuery('#w2p_field_'+jQuery('#w2p_query_fields').val().replace('.','-')).show();",
|
||||
@@ -1596,7 +1596,7 @@ class SQLFORM(FORM):
|
||||
""")
|
||||
return CAT(
|
||||
DIV(_id="w2p_query_panel",_class='hidden',*criteria),fadd)
|
||||
|
||||
|
||||
|
||||
|
||||
@staticmethod
|
||||
@@ -1718,7 +1718,7 @@ class SQLFORM(FORM):
|
||||
'create' in request.args or
|
||||
'delete' in request.args or
|
||||
'edit' in request.args)):
|
||||
session.flash = T('not authorized')
|
||||
session.flash = T('not authorized')
|
||||
redirect(referrer)
|
||||
|
||||
def gridbutton(buttonclass='buttonadd', buttontext='Add',
|
||||
@@ -2270,7 +2270,7 @@ class SQLFORM(FORM):
|
||||
else:
|
||||
break
|
||||
if nargs>len(args)+1:
|
||||
query = (field == id)
|
||||
query = (field == id)
|
||||
if isinstance(linked_tables,dict):
|
||||
linked_tables = linked_tables.get(table._tablename,[])
|
||||
if linked_tables is None or referee in linked_tables:
|
||||
@@ -2747,3 +2747,4 @@ class ExporterXML(ExportClass):
|
||||
out.write('</row>\n')
|
||||
out.write('</rows>')
|
||||
return str(out.getvalue())
|
||||
|
||||
|
||||
+3
-2
@@ -38,7 +38,7 @@ class Storage(dict):
|
||||
>>> print o.a
|
||||
None
|
||||
"""
|
||||
__slots__=()
|
||||
__slots__=()
|
||||
__setattr__ = dict.__setitem__
|
||||
__delattr__ = dict.__delitem__
|
||||
__getitem__ = dict.get
|
||||
@@ -47,7 +47,7 @@ class Storage(dict):
|
||||
# http://stackoverflow.com/questions/5247250/why-does-pickle-getstate-accept-as-a-return-value-the-very-instance-it-requi
|
||||
__getstate__ = lambda self: None
|
||||
__copy__ = lambda self: Storage(self)
|
||||
|
||||
|
||||
def getlist(self,key):
|
||||
"""
|
||||
Return a Storage value as a list.
|
||||
@@ -265,3 +265,4 @@ if __name__ == '__main__':
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -118,3 +118,4 @@ def stream_file_or_304_or_206(
|
||||
else:
|
||||
wrapped = streamer(stream, chunk_size=chunk_size, bytes=bytes)
|
||||
raise HTTP(status, wrapped, **headers)
|
||||
|
||||
|
||||
+3
-2
@@ -216,7 +216,7 @@ class TemplateParser(object):
|
||||
# These are used for re-indentation.
|
||||
# Indent + 1
|
||||
re_block = compile('^(elif |else:|except:|except |finally:).*$',DOTALL)
|
||||
|
||||
|
||||
# Indent - 1
|
||||
re_unblock = compile('^(return|continue|break|raise)( .*)?$', DOTALL)
|
||||
# Indent - 1
|
||||
@@ -504,7 +504,7 @@ class TemplateParser(object):
|
||||
self.content.nodes = []
|
||||
|
||||
t_content = t.content
|
||||
|
||||
|
||||
# Set our include, unique by filename
|
||||
t_content.blocks['__include__' + filename] = buf
|
||||
|
||||
@@ -896,3 +896,4 @@ if __name__ == '__main__':
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+14
-13
@@ -625,7 +625,7 @@ class Mail(object):
|
||||
for k,v in headers.iteritems():
|
||||
payload[k] = encoded_or_raw(v.decode(encoding))
|
||||
result = {}
|
||||
try:
|
||||
try:
|
||||
if self.settings.server == 'logging':
|
||||
logger.warn('email not sent\n%s\nFrom: %s\nTo: %s\nSubject: %s\n\n%s\n%s\n' % \
|
||||
('-'*40,sender,
|
||||
@@ -1042,7 +1042,7 @@ class Auth(object):
|
||||
def url(self, f=None, args=None, vars=None, scheme=False):
|
||||
if args is None: args=[]
|
||||
if vars is None: vars={}
|
||||
return URL(c=self.settings.controller,
|
||||
return URL(c=self.settings.controller,
|
||||
f=f, args=args, vars=vars,scheme=scheme)
|
||||
|
||||
def here(self):
|
||||
@@ -1089,7 +1089,7 @@ class Auth(object):
|
||||
url_index = URL(controller,'index')
|
||||
url_login = URL(controller,function,args='login')
|
||||
# ## what happens after registration?
|
||||
|
||||
|
||||
settings = self.settings = Settings()
|
||||
settings.update(Auth.default_settings)
|
||||
settings.update(
|
||||
@@ -1299,7 +1299,7 @@ class Auth(object):
|
||||
|
||||
if asdropdown:
|
||||
bar.insert(-1, LI('',_class='divider'))
|
||||
if self.user_id:
|
||||
if self.user_id:
|
||||
bar = LI(A(prefix, user_identifier, _href='#'),
|
||||
bar,_class='dropdown')
|
||||
else:
|
||||
@@ -1362,7 +1362,7 @@ class Auth(object):
|
||||
T = current.T
|
||||
reference_user = 'reference %s' % settings.table_user_name
|
||||
def lazy_user (auth = self):
|
||||
return auth.user_id
|
||||
return auth.user_id
|
||||
def represent(id,record=None,s=settings):
|
||||
try:
|
||||
user = s.table_user(id)
|
||||
@@ -1425,7 +1425,7 @@ class Auth(object):
|
||||
elif isinstance(signature,self.db.Table):
|
||||
signature_list = [signature]
|
||||
else:
|
||||
signature_list = signature
|
||||
signature_list = signature
|
||||
is_not_empty = IS_NOT_EMPTY(error_message=self.messages.is_empty)
|
||||
is_crypted = CRYPT(key=settings.hmac_key,
|
||||
min_length=settings.password_min_length)
|
||||
@@ -1698,7 +1698,7 @@ class Auth(object):
|
||||
"""
|
||||
perform basic login.
|
||||
reads current.request.env.http_authorization
|
||||
and returns basic_allowed,basic_accepted,user
|
||||
and returns basic_allowed,basic_accepted,user
|
||||
"""
|
||||
if not self.settings.allow_basic_login:
|
||||
return (False,False,False)
|
||||
@@ -1715,7 +1715,7 @@ class Auth(object):
|
||||
user = Storage(self.table_user()._filter_fields(user,id=True))
|
||||
if 'password' in user: del user.password
|
||||
current.session.auth = Storage(
|
||||
user = user,
|
||||
user = user,
|
||||
last_visit = current.request.now,
|
||||
expiration = self.settings.expiration,
|
||||
hmac_key = web2py_uuid())
|
||||
@@ -2182,7 +2182,7 @@ class Auth(object):
|
||||
self.add_membership(self.settings.everybody_group_id, form.vars.id)
|
||||
if self.settings.registration_requires_verification:
|
||||
link = self.url('user',args=('verify_email',key),scheme=True)
|
||||
|
||||
|
||||
if not self.settings.mailer or \
|
||||
not self.settings.mailer.send(
|
||||
to=form.vars.email,
|
||||
@@ -2204,7 +2204,7 @@ class Auth(object):
|
||||
session.flash = self.messages.registration_successful
|
||||
user = self.db(
|
||||
table_user[username] == form.vars[username]
|
||||
).select().first()
|
||||
).select().first()
|
||||
self.login_user(user)
|
||||
session.flash = self.messages.logged_in
|
||||
self.log_event(log, form.vars)
|
||||
@@ -2561,7 +2561,7 @@ class Auth(object):
|
||||
reset_password_key = str(int(time.time()))+'-' + web2py_uuid()
|
||||
link = self.url('user',
|
||||
args=('reset_password',reset_password_key),
|
||||
scheme=True)
|
||||
scheme=True)
|
||||
if self.settings.mailer.send(
|
||||
to=user.email,
|
||||
subject=self.messages.reset_password_subject,
|
||||
@@ -4476,7 +4476,7 @@ class PluginManager(object):
|
||||
settings.installed = True
|
||||
settings.update(
|
||||
(k,v) for k,v in defaults.items() if not k in settings)
|
||||
|
||||
|
||||
def __getattr__(self, key):
|
||||
if not key in self.__dict__:
|
||||
self.__dict__[key] = Storage()
|
||||
@@ -4660,7 +4660,7 @@ class Wiki(object):
|
||||
# WIKI ACCESS POLICY
|
||||
def not_authorized(self,page=None):
|
||||
raise HTTP(401)
|
||||
def can_read(self,page):
|
||||
def can_read(self,page):
|
||||
if 'everybody' in page.can_read or not self.manage_permissions:
|
||||
return True
|
||||
elif self.auth.user:
|
||||
@@ -5027,3 +5027,4 @@ if __name__ == '__main__':
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -655,3 +655,4 @@ if __name__ == '__main__':
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+4
-3
@@ -208,11 +208,11 @@ def web2py_uuid(ctokens=UNPACKED_CTOKENS):
|
||||
if HAVE_URANDOM:
|
||||
urand_longs = struct.unpack('=QQ', fast_urandom16())
|
||||
byte_s = struct.pack('=QQ',
|
||||
rand_longs[0]^urand_longs[0]^ctokens[0],
|
||||
rand_longs[0]^urand_longs[0]^ctokens[0],
|
||||
rand_longs[1]^urand_longs[1]^ctokens[1])
|
||||
else:
|
||||
byte_s = struct.pack('=QQ',
|
||||
rand_longs[0]^ctokens[0],
|
||||
byte_s = struct.pack('=QQ',
|
||||
rand_longs[0]^ctokens[0],
|
||||
rand_longs[1]^ctokens[1])
|
||||
return str(uuid.UUID(bytes=byte_s, version=4))
|
||||
|
||||
@@ -261,3 +261,4 @@ def is_valid_ip_address(address):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+2
-1
@@ -2797,7 +2797,7 @@ class IS_STRONG(object):
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, min=None, max=None, upper=None, lower=None, number=None,
|
||||
def __init__(self, min=None, max=None, upper=None, lower=None, number=None,
|
||||
entropy=None,
|
||||
special=None, specials=r'~!@#$%^&*()_+-=?<>,.:;{}[]|',
|
||||
invalid=' "', error_message=None, es=False):
|
||||
@@ -3256,3 +3256,4 @@ if __name__ == '__main__':
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1227,3 +1227,4 @@ end tell
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -173,3 +173,4 @@ if __name__ == '__main__':
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -26,3 +26,4 @@ def handler(request, response, methods):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user