you are lucky :)
"""
# 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)
user = request.db.User.find_one(
formdata = {
'vars': formdata_vars,
'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
"""
def __init__(self, migration_number, migration_registry=MIGRATIONS):
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!"
self.migration_number = migration_number
subparsers = parser.add_subparsers(help='sub-command help')
for command_name, command_struct in SUBCOMMAND_MAP.iteritems():
- if command_struct.has_key('help'):
+ if 'help' in command_struct:
subparser = subparsers.add_parser(
command_name, help=command_struct['help'])
else:
def get_staticdirector(app_config):
- if app_config.has_key('direct_remote_path'):
+ if 'direct_remote_path' in app_config:
return staticdirect.RemoteStaticDirect(
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_paths'].strip().splitlines()
return staticdirect.MultiRemoteStaticDirect(
- set_environ: if set, this will CELERY_CONFIG_MODULE to the
settings_module
"""
- if global_config.has_key('celery'):
+ if 'celery' in global_config:
celery_conf = global_config['celery']
else:
celery_conf = {}
-
+
celery_settings = {}
# set up mongodb stuff
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_mongo_settings = {}
- if app_config.has_key('db_host'):
+ if 'db_host' in app_config:
celery_mongo_settings['host'] = app_config['db_host']
if celery_settings['BROKER_BACKEND'] == 'mongodb':
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']
if celery_settings['BROKER_BACKEND'] == 'mongodb':
celery_settings['BROKER_PORT'] = app_config['db_port']
# Staticdirect infrastructure.
# Borrowed largely from cc.engine
# by Chris Webber & Creative Commons
-#
+#
# This needs documentation!
####################################
import pkg_resources
import urlparse
+
class StaticDirect(object):
def __init__(self):
self.cache = {}
def __call__(self, filepath):
- if self.cache.has_key(filepath):
+ if filepath in self.cache:
return self.cache[filepath]
static_direction = self.cache[filepath] = self.get(filepath)
return static_direction
-
def get(self, filepath):
# should be implemented by the individual staticdirector
submit_form = submit_forms.SubmitStartForm(request.POST)
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 request.POST['file'].file):
submit_form.file.errors.append(
# If we have a jinja environment set up with this locale, just
# return that one.
- if SETUP_JINJA_ENVS.has_key(locale):
+ if locale in SETUP_JINJA_ENVS:
return SETUP_JINJA_ENVS[locale]
template_env = jinja2.Environment(
Examine a request and tack on a request.user parameter if that's
appropriate.
"""
- if not request.session.has_key('user_id'):
+ if not 'user_id' in request.session:
request.user = None
return
"""
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'])
accept_lang_matches = request.accept_language.best_matches()
# Your routing can explicitly specify a target language
matchdict = request.matchdict or {}
- if matchdict.has_key('locale'):
+ if 'locale' in matchdict:
target_lang = matchdict['locale']
- elif request.session.has_key('target_lang'):
+ elif 'target_lang' in request.session:
target_lang = request.session['target_lang']
# Pull the first acceptable language
elif accept_lang_matches:
annoying_tags=True,
allow_tags=[
'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,
- add_nofollow=True, # for now
+ add_nofollow=True, # for now
host_whitelist=(),
whitelist_tags=set([]))
# TODO: fallback nicely on translations from pt_PT to pt if not
# available, etc.
- if SETUP_GETTEXTS.has_key(locale):
+ if locale in SETUP_GETTEXTS:
this_gettext = SETUP_GETTEXTS[locale]
else:
this_gettext = gettext.translation(