has_key is deprecated, converting uses to use "in" operator.
This commit is contained in:
parent
243c3843bd
commit
285ffeddf3
@ -146,7 +146,7 @@ def verify_email(request):
|
|||||||
you are lucky :)
|
you are lucky :)
|
||||||
"""
|
"""
|
||||||
# If we don't have userid and token parameters, we can't do anything; 404
|
# If we don't have userid and token parameters, we can't do anything; 404
|
||||||
if not request.GET.has_key('userid') or not request.GET.has_key('token'):
|
if not 'userid' in request.GET or not 'token' in request.GET:
|
||||||
return render_404(request)
|
return render_404(request)
|
||||||
|
|
||||||
user = request.db.User.find_one(
|
user = request.db.User.find_one(
|
||||||
@ -307,6 +307,6 @@ def _process_for_token(request):
|
|||||||
formdata = {
|
formdata = {
|
||||||
'vars': formdata_vars,
|
'vars': formdata_vars,
|
||||||
'has_userid_and_token':
|
'has_userid_and_token':
|
||||||
formdata_vars.has_key('userid') and formdata_vars.has_key('token')}
|
'userid' in formdata_vars and 'token' in formdata_vars}
|
||||||
|
|
||||||
return formdata
|
return formdata
|
||||||
|
@ -148,7 +148,7 @@ class RegisterMigration(object):
|
|||||||
"""
|
"""
|
||||||
def __init__(self, migration_number, migration_registry=MIGRATIONS):
|
def __init__(self, migration_number, migration_registry=MIGRATIONS):
|
||||||
assert migration_number > 0, "Migration number must be > 0!"
|
assert migration_number > 0, "Migration number must be > 0!"
|
||||||
assert not migration_registry.has_key(migration_number), \
|
assert migration_number not in migration_registry, \
|
||||||
"Duplicate migration numbers detected! That's not allowed!"
|
"Duplicate migration numbers detected! That's not allowed!"
|
||||||
|
|
||||||
self.migration_number = migration_number
|
self.migration_number = migration_number
|
||||||
|
@ -61,7 +61,7 @@ def main_cli():
|
|||||||
|
|
||||||
subparsers = parser.add_subparsers(help='sub-command help')
|
subparsers = parser.add_subparsers(help='sub-command help')
|
||||||
for command_name, command_struct in SUBCOMMAND_MAP.iteritems():
|
for command_name, command_struct in SUBCOMMAND_MAP.iteritems():
|
||||||
if command_struct.has_key('help'):
|
if 'help' in command_struct:
|
||||||
subparser = subparsers.add_parser(
|
subparser = subparsers.add_parser(
|
||||||
command_name, help=command_struct['help'])
|
command_name, help=command_struct['help'])
|
||||||
else:
|
else:
|
||||||
|
@ -103,10 +103,10 @@ def get_jinja_loader(user_template_path=None):
|
|||||||
|
|
||||||
|
|
||||||
def get_staticdirector(app_config):
|
def get_staticdirector(app_config):
|
||||||
if app_config.has_key('direct_remote_path'):
|
if 'direct_remote_path' in app_config:
|
||||||
return staticdirect.RemoteStaticDirect(
|
return staticdirect.RemoteStaticDirect(
|
||||||
app_config['direct_remote_path'].strip())
|
app_config['direct_remote_path'].strip())
|
||||||
elif app_config.has_key('direct_remote_paths'):
|
elif 'direct_remote_paths' in app_config:
|
||||||
direct_remote_path_lines = app_config[
|
direct_remote_path_lines = app_config[
|
||||||
'direct_remote_paths'].strip().splitlines()
|
'direct_remote_paths'].strip().splitlines()
|
||||||
return staticdirect.MultiRemoteStaticDirect(
|
return staticdirect.MultiRemoteStaticDirect(
|
||||||
|
@ -40,7 +40,7 @@ def setup_celery_from_config(app_config, global_config,
|
|||||||
- set_environ: if set, this will CELERY_CONFIG_MODULE to the
|
- set_environ: if set, this will CELERY_CONFIG_MODULE to the
|
||||||
settings_module
|
settings_module
|
||||||
"""
|
"""
|
||||||
if global_config.has_key('celery'):
|
if 'celery' in global_config:
|
||||||
celery_conf = global_config['celery']
|
celery_conf = global_config['celery']
|
||||||
else:
|
else:
|
||||||
celery_conf = {}
|
celery_conf = {}
|
||||||
@ -49,16 +49,16 @@ def setup_celery_from_config(app_config, global_config,
|
|||||||
|
|
||||||
# set up mongodb stuff
|
# set up mongodb stuff
|
||||||
celery_settings['CELERY_RESULT_BACKEND'] = 'mongodb'
|
celery_settings['CELERY_RESULT_BACKEND'] = 'mongodb'
|
||||||
if not celery_settings.has_key('BROKER_BACKEND'):
|
if 'BROKER_BACKEND' not in celery_settings:
|
||||||
celery_settings['BROKER_BACKEND'] = 'mongodb'
|
celery_settings['BROKER_BACKEND'] = 'mongodb'
|
||||||
|
|
||||||
celery_mongo_settings = {}
|
celery_mongo_settings = {}
|
||||||
|
|
||||||
if app_config.has_key('db_host'):
|
if 'db_host' in app_config:
|
||||||
celery_mongo_settings['host'] = app_config['db_host']
|
celery_mongo_settings['host'] = app_config['db_host']
|
||||||
if celery_settings['BROKER_BACKEND'] == 'mongodb':
|
if celery_settings['BROKER_BACKEND'] == 'mongodb':
|
||||||
celery_settings['BROKER_HOST'] = app_config['db_host']
|
celery_settings['BROKER_HOST'] = app_config['db_host']
|
||||||
if app_config.has_key('db_port'):
|
if 'db_port' in app_config:
|
||||||
celery_mongo_settings['port'] = app_config['db_port']
|
celery_mongo_settings['port'] = app_config['db_port']
|
||||||
if celery_settings['BROKER_BACKEND'] == 'mongodb':
|
if celery_settings['BROKER_BACKEND'] == 'mongodb':
|
||||||
celery_settings['BROKER_PORT'] = app_config['db_port']
|
celery_settings['BROKER_PORT'] = app_config['db_port']
|
||||||
|
@ -28,18 +28,18 @@ import urlparse
|
|||||||
import pkg_resources
|
import pkg_resources
|
||||||
import urlparse
|
import urlparse
|
||||||
|
|
||||||
|
|
||||||
class StaticDirect(object):
|
class StaticDirect(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.cache = {}
|
self.cache = {}
|
||||||
|
|
||||||
def __call__(self, filepath):
|
def __call__(self, filepath):
|
||||||
if self.cache.has_key(filepath):
|
if filepath in self.cache:
|
||||||
return self.cache[filepath]
|
return self.cache[filepath]
|
||||||
|
|
||||||
static_direction = self.cache[filepath] = self.get(filepath)
|
static_direction = self.cache[filepath] = self.get(filepath)
|
||||||
return static_direction
|
return static_direction
|
||||||
|
|
||||||
|
|
||||||
def get(self, filepath):
|
def get(self, filepath):
|
||||||
# should be implemented by the individual staticdirector
|
# should be implemented by the individual staticdirector
|
||||||
pass
|
pass
|
||||||
|
@ -40,7 +40,7 @@ def submit_start(request):
|
|||||||
submit_form = submit_forms.SubmitStartForm(request.POST)
|
submit_form = submit_forms.SubmitStartForm(request.POST)
|
||||||
|
|
||||||
if request.method == 'POST' and submit_form.validate():
|
if request.method == 'POST' and submit_form.validate():
|
||||||
if not (request.POST.has_key('file')
|
if not ('file' in request.POST
|
||||||
and isinstance(request.POST['file'], FieldStorage)
|
and isinstance(request.POST['file'], FieldStorage)
|
||||||
and request.POST['file'].file):
|
and request.POST['file'].file):
|
||||||
submit_form.file.errors.append(
|
submit_form.file.errors.append(
|
||||||
|
@ -89,7 +89,7 @@ def get_jinja_env(template_loader, locale):
|
|||||||
|
|
||||||
# If we have a jinja environment set up with this locale, just
|
# If we have a jinja environment set up with this locale, just
|
||||||
# return that one.
|
# return that one.
|
||||||
if SETUP_JINJA_ENVS.has_key(locale):
|
if locale in SETUP_JINJA_ENVS:
|
||||||
return SETUP_JINJA_ENVS[locale]
|
return SETUP_JINJA_ENVS[locale]
|
||||||
|
|
||||||
template_env = jinja2.Environment(
|
template_env = jinja2.Environment(
|
||||||
@ -166,7 +166,7 @@ def setup_user_in_request(request):
|
|||||||
Examine a request and tack on a request.user parameter if that's
|
Examine a request and tack on a request.user parameter if that's
|
||||||
appropriate.
|
appropriate.
|
||||||
"""
|
"""
|
||||||
if not request.session.has_key('user_id'):
|
if not 'user_id' in request.session:
|
||||||
request.user = None
|
request.user = None
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -356,7 +356,7 @@ def get_locale_from_request(request):
|
|||||||
"""
|
"""
|
||||||
request_form = request.GET or request.POST
|
request_form = request.GET or request.POST
|
||||||
|
|
||||||
if request_form.has_key('lang'):
|
if 'lang' in request_form:
|
||||||
return locale_to_lower_upper(request_form['lang'])
|
return locale_to_lower_upper(request_form['lang'])
|
||||||
|
|
||||||
accept_lang_matches = request.accept_language.best_matches()
|
accept_lang_matches = request.accept_language.best_matches()
|
||||||
@ -364,9 +364,9 @@ def get_locale_from_request(request):
|
|||||||
# Your routing can explicitly specify a target language
|
# Your routing can explicitly specify a target language
|
||||||
matchdict = request.matchdict or {}
|
matchdict = request.matchdict or {}
|
||||||
|
|
||||||
if matchdict.has_key('locale'):
|
if 'locale' in matchdict:
|
||||||
target_lang = matchdict['locale']
|
target_lang = matchdict['locale']
|
||||||
elif request.session.has_key('target_lang'):
|
elif 'target_lang' in request.session:
|
||||||
target_lang = request.session['target_lang']
|
target_lang = request.session['target_lang']
|
||||||
# Pull the first acceptable language
|
# Pull the first acceptable language
|
||||||
elif accept_lang_matches:
|
elif accept_lang_matches:
|
||||||
@ -393,9 +393,9 @@ HTML_CLEANER = Cleaner(
|
|||||||
annoying_tags=True,
|
annoying_tags=True,
|
||||||
allow_tags=[
|
allow_tags=[
|
||||||
'div', 'b', 'i', 'em', 'strong', 'p', 'ul', 'ol', 'li', 'a', 'br'],
|
'div', 'b', 'i', 'em', 'strong', 'p', 'ul', 'ol', 'li', 'a', 'br'],
|
||||||
remove_unknown_tags=False, # can't be used with allow_tags
|
remove_unknown_tags=False, # can't be used with allow_tags
|
||||||
safe_attrs_only=True,
|
safe_attrs_only=True,
|
||||||
add_nofollow=True, # for now
|
add_nofollow=True, # for now
|
||||||
host_whitelist=(),
|
host_whitelist=(),
|
||||||
whitelist_tags=set([]))
|
whitelist_tags=set([]))
|
||||||
|
|
||||||
@ -492,7 +492,7 @@ def setup_gettext(locale):
|
|||||||
|
|
||||||
# TODO: fallback nicely on translations from pt_PT to pt if not
|
# TODO: fallback nicely on translations from pt_PT to pt if not
|
||||||
# available, etc.
|
# available, etc.
|
||||||
if SETUP_GETTEXTS.has_key(locale):
|
if locale in SETUP_GETTEXTS:
|
||||||
this_gettext = SETUP_GETTEXTS[locale]
|
this_gettext = SETUP_GETTEXTS[locale]
|
||||||
else:
|
else:
|
||||||
this_gettext = gettext.translation(
|
this_gettext = gettext.translation(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user