Merge pull request #1861 from milmazz/E251

Fixed flake8 E251 violations
This commit is contained in:
Alex Gaynor 2013-11-03 09:42:31 -08:00
commit 91078f5669
24 changed files with 194 additions and 194 deletions

View File

@ -96,8 +96,8 @@ def result_headers(cl):
ordering_field_columns = cl.get_ordering_field_columns() ordering_field_columns = cl.get_ordering_field_columns()
for i, field_name in enumerate(cl.list_display): for i, field_name in enumerate(cl.list_display):
text, attr = label_for_field(field_name, cl.model, text, attr = label_for_field(field_name, cl.model,
model_admin = cl.model_admin, model_admin=cl.model_admin,
return_attr = True return_attr=True
) )
if attr: if attr:
# Potentially not sortable # Potentially not sortable

View File

@ -21,9 +21,9 @@ class LatestCommentFeed(Feed):
def items(self): def items(self):
qs = comments.get_model().objects.filter( qs = comments.get_model().objects.filter(
site__pk = self.site.pk, site__pk=self.site.pk,
is_public = True, is_public=True,
is_removed = False, is_removed=False,
) )
return qs.order_by('-submit_date')[:40] return qs.order_by('-submit_date')[:40]

View File

@ -132,16 +132,16 @@ class CommentDetailsForm(CommentSecurityForm):
method to add extra fields onto a custom comment model. method to add extra fields onto a custom comment model.
""" """
return dict( return dict(
content_type = ContentType.objects.get_for_model(self.target_object), content_type=ContentType.objects.get_for_model(self.target_object),
object_pk = force_text(self.target_object._get_pk_val()), object_pk=force_text(self.target_object._get_pk_val()),
user_name = self.cleaned_data["name"], user_name=self.cleaned_data["name"],
user_email = self.cleaned_data["email"], user_email=self.cleaned_data["email"],
user_url = self.cleaned_data["url"], user_url=self.cleaned_data["url"],
comment = self.cleaned_data["comment"], comment=self.cleaned_data["comment"],
submit_date = timezone.now(), submit_date=timezone.now(),
site_id = settings.SITE_ID, site_id=settings.SITE_ID,
is_public = True, is_public=True,
is_removed = False, is_removed=False,
) )
def check_for_duplicate_comment(self, new): def check_for_duplicate_comment(self, new):
@ -152,11 +152,11 @@ class CommentDetailsForm(CommentSecurityForm):
possible_duplicates = self.get_comment_model()._default_manager.using( possible_duplicates = self.get_comment_model()._default_manager.using(
self.target_object._state.db self.target_object._state.db
).filter( ).filter(
content_type = new.content_type, content_type=new.content_type,
object_pk = new.object_pk, object_pk=new.object_pk,
user_name = new.user_name, user_name=new.user_name,
user_email = new.user_email, user_email=new.user_email,
user_url = new.user_url, user_url=new.user_url,
) )
for old in possible_duplicates: for old in possible_duplicates:
if old.submit_date.date() == new.submit_date.date() and old.comment == new.comment: if old.submit_date.date() == new.submit_date.date() and old.comment == new.comment:

View File

@ -35,8 +35,8 @@ class BaseCommentNode(six.with_metaclass(RenameBaseCommentNodeMethods, template.
if tokens[3] != 'as': if tokens[3] != 'as':
raise template.TemplateSyntaxError("Third argument in %r must be 'as'" % tokens[0]) raise template.TemplateSyntaxError("Third argument in %r must be 'as'" % tokens[0])
return cls( return cls(
object_expr = parser.compile_filter(tokens[2]), object_expr=parser.compile_filter(tokens[2]),
as_varname = tokens[4], as_varname=tokens[4],
) )
# {% get_whatever for app.model pk as varname %} # {% get_whatever for app.model pk as varname %}
@ -44,9 +44,9 @@ class BaseCommentNode(six.with_metaclass(RenameBaseCommentNodeMethods, template.
if tokens[4] != 'as': if tokens[4] != 'as':
raise template.TemplateSyntaxError("Fourth argument in %r must be 'as'" % tokens[0]) raise template.TemplateSyntaxError("Fourth argument in %r must be 'as'" % tokens[0])
return cls( return cls(
ctype = BaseCommentNode.lookup_content_type(tokens[2], tokens[0]), ctype=BaseCommentNode.lookup_content_type(tokens[2], tokens[0]),
object_pk_expr = parser.compile_filter(tokens[3]), object_pk_expr=parser.compile_filter(tokens[3]),
as_varname = tokens[5] as_varname=tokens[5]
) )
else: else:
@ -83,9 +83,9 @@ class BaseCommentNode(six.with_metaclass(RenameBaseCommentNodeMethods, template.
return self.comment_model.objects.none() return self.comment_model.objects.none()
qs = self.comment_model.objects.filter( qs = self.comment_model.objects.filter(
content_type = ctype, content_type=ctype,
object_pk = smart_text(object_pk), object_pk=smart_text(object_pk),
site__pk = settings.SITE_ID, site__pk=settings.SITE_ID,
) )
# The is_public and is_removed fields are implementation details of the # The is_public and is_removed fields are implementation details of the
@ -166,8 +166,8 @@ class RenderCommentFormNode(CommentFormNode):
# {% render_comment_form for app.models pk %} # {% render_comment_form for app.models pk %}
elif len(tokens) == 4: elif len(tokens) == 4:
return cls( return cls(
ctype = BaseCommentNode.lookup_content_type(tokens[2], tokens[0]), ctype=BaseCommentNode.lookup_content_type(tokens[2], tokens[0]),
object_pk_expr = parser.compile_filter(tokens[3]) object_pk_expr=parser.compile_filter(tokens[3])
) )
def render(self, context): def render(self, context):
@ -202,8 +202,8 @@ class RenderCommentListNode(CommentListNode):
# {% render_comment_list for app.models pk %} # {% render_comment_list for app.models pk %}
elif len(tokens) == 4: elif len(tokens) == 4:
return cls( return cls(
ctype = BaseCommentNode.lookup_content_type(tokens[2], tokens[0]), ctype=BaseCommentNode.lookup_content_type(tokens[2], tokens[0]),
object_pk_expr = parser.compile_filter(tokens[3]) object_pk_expr=parser.compile_filter(tokens[3])
) )
def render(self, context): def render(self, context):

View File

@ -99,40 +99,40 @@ def perform_flag(request, comment):
Actually perform the flagging of a comment from a request. Actually perform the flagging of a comment from a request.
""" """
flag, created = comments.models.CommentFlag.objects.get_or_create( flag, created = comments.models.CommentFlag.objects.get_or_create(
comment = comment, comment=comment,
user = request.user, user=request.user,
flag = comments.models.CommentFlag.SUGGEST_REMOVAL flag=comments.models.CommentFlag.SUGGEST_REMOVAL
) )
signals.comment_was_flagged.send( signals.comment_was_flagged.send(
sender = comment.__class__, sender=comment.__class__,
comment = comment, comment=comment,
flag = flag, flag=flag,
created = created, created=created,
request = request, request=request,
) )
def perform_delete(request, comment): def perform_delete(request, comment):
flag, created = comments.models.CommentFlag.objects.get_or_create( flag, created = comments.models.CommentFlag.objects.get_or_create(
comment = comment, comment=comment,
user = request.user, user=request.user,
flag = comments.models.CommentFlag.MODERATOR_DELETION flag=comments.models.CommentFlag.MODERATOR_DELETION
) )
comment.is_removed = True comment.is_removed = True
comment.save() comment.save()
signals.comment_was_flagged.send( signals.comment_was_flagged.send(
sender = comment.__class__, sender=comment.__class__,
comment = comment, comment=comment,
flag = flag, flag=flag,
created = created, created=created,
request = request, request=request,
) )
def perform_approve(request, comment): def perform_approve(request, comment):
flag, created = comments.models.CommentFlag.objects.get_or_create( flag, created = comments.models.CommentFlag.objects.get_or_create(
comment = comment, comment=comment,
user = request.user, user=request.user,
flag = comments.models.CommentFlag.MODERATOR_APPROVAL, flag=comments.models.CommentFlag.MODERATOR_APPROVAL,
) )
comment.is_removed = False comment.is_removed = False
@ -140,24 +140,24 @@ def perform_approve(request, comment):
comment.save() comment.save()
signals.comment_was_flagged.send( signals.comment_was_flagged.send(
sender = comment.__class__, sender=comment.__class__,
comment = comment, comment=comment,
flag = flag, flag=flag,
created = created, created=created,
request = request, request=request,
) )
# Confirmation views. # Confirmation views.
flag_done = confirmation_view( flag_done = confirmation_view(
template = "comments/flagged.html", template="comments/flagged.html",
doc = 'Displays a "comment was flagged" success page.' doc='Displays a "comment was flagged" success page.'
) )
delete_done = confirmation_view( delete_done = confirmation_view(
template = "comments/deleted.html", template="comments/deleted.html",
doc = 'Displays a "comment was deleted" success page.' doc='Displays a "comment was deleted" success page.'
) )
approve_done = confirmation_view( approve_done = confirmation_view(
template = "comments/approved.html", template="comments/approved.html",
doc = 'Displays a "comment was approved" success page.' doc='Displays a "comment was approved" success page.'
) )

View File

@ -276,14 +276,14 @@ class ReverseGenericRelatedObjectsDescriptor(object):
join_cols = self.field.get_joining_columns(reverse_join=True)[0] join_cols = self.field.get_joining_columns(reverse_join=True)[0]
manager = RelatedManager( manager = RelatedManager(
model = rel_model, model=rel_model,
instance = instance, instance=instance,
source_col_name = qn(join_cols[0]), source_col_name=qn(join_cols[0]),
target_col_name = qn(join_cols[1]), target_col_name=qn(join_cols[1]),
content_type = content_type, content_type=content_type,
content_type_field_name = self.field.content_type_field_name, content_type_field_name=self.field.content_type_field_name,
object_id_field_name = self.field.object_id_field_name, object_id_field_name=self.field.object_id_field_name,
prefetch_cache_name = self.field.attname, prefetch_cache_name=self.field.attname,
) )
return manager return manager
@ -329,15 +329,15 @@ def create_generic_related_manager(superclass):
manager = getattr(self.model, kwargs.pop('manager')) manager = getattr(self.model, kwargs.pop('manager'))
manager_class = create_generic_related_manager(manager.__class__) manager_class = create_generic_related_manager(manager.__class__)
return manager_class( return manager_class(
model = self.model, model=self.model,
instance = self.instance, instance=self.instance,
symmetrical = self.symmetrical, symmetrical=self.symmetrical,
source_col_name = self.source_col_name, source_col_name=self.source_col_name,
target_col_name = self.target_col_name, target_col_name=self.target_col_name,
content_type = self.content_type, content_type=self.content_type,
content_type_field_name = self.content_type_field_name, content_type_field_name=self.content_type_field_name,
object_id_field_name = self.object_id_field_name, object_id_field_name=self.object_id_field_name,
prefetch_cache_name = self.prefetch_cache_name, prefetch_cache_name=self.prefetch_cache_name,
) )
do_not_call_in_templates = True do_not_call_in_templates = True

View File

@ -43,9 +43,9 @@ class ContentTypeManager(models.Manager):
# needed around opts.verbose_name_raw because name_raw might be a # needed around opts.verbose_name_raw because name_raw might be a
# django.utils.functional.__proxy__ object. # django.utils.functional.__proxy__ object.
ct, created = self.get_or_create( ct, created = self.get_or_create(
app_label = opts.app_label, app_label=opts.app_label,
model = opts.model_name, model=opts.model_name,
defaults = {'name': smart_text(opts.verbose_name_raw)}, defaults={'name': smart_text(opts.verbose_name_raw)},
) )
self._add_to_cache(self.db, ct) self._add_to_cache(self.db, ct)

View File

@ -271,9 +271,9 @@ class ContentTypesTests(TestCase):
is defined anymore. is defined anymore.
""" """
ct = ContentType.objects.create( ct = ContentType.objects.create(
name = 'Old model', name='Old model',
app_label = 'contenttypes', app_label='contenttypes',
model = 'OldModel', model='OldModel',
) )
self.assertEqual(six.text_type(ct), 'Old model') self.assertEqual(six.text_type(ct), 'Old model')
self.assertIsNone(ct.model_class()) self.assertIsNone(ct.model_class())

View File

@ -6,10 +6,10 @@ from django.utils.translation import ugettext, ugettext_lazy as _
class FlatpageForm(forms.ModelForm): class FlatpageForm(forms.ModelForm):
url = forms.RegexField(label=_("URL"), max_length=100, regex=r'^[-\w/\.~]+$', url = forms.RegexField(label=_("URL"), max_length=100, regex=r'^[-\w/\.~]+$',
help_text = _("Example: '/about/contact/'. Make sure to have leading" help_text=_("Example: '/about/contact/'. Make sure to have leading"
" and trailing slashes."), " and trailing slashes."),
error_message = _("This value must contain only letters, numbers," error_message=_("This value must contain only letters, numbers,"
" dots, underscores, dashes, slashes or tildes.")) " dots, underscores, dashes, slashes or tildes."))
class Meta: class Meta:
model = FlatPage model = FlatPage

View File

@ -87,7 +87,7 @@ class FlatpageMiddlewareTests(TestCase):
@override_settings( @override_settings(
APPEND_SLASH = True, APPEND_SLASH=True,
LOGIN_URL='/accounts/login/', LOGIN_URL='/accounts/login/',
MIDDLEWARE_CLASSES=( MIDDLEWARE_CLASSES=(
'django.middleware.common.CommonMiddleware', 'django.middleware.common.CommonMiddleware',

View File

@ -75,7 +75,7 @@ class FlatpageViewTests(TestCase):
@override_settings( @override_settings(
APPEND_SLASH = True, APPEND_SLASH=True,
LOGIN_URL='/accounts/login/', LOGIN_URL='/accounts/login/',
MIDDLEWARE_CLASSES=( MIDDLEWARE_CLASSES=(
'django.middleware.common.CommonMiddleware', 'django.middleware.common.CommonMiddleware',

View File

@ -58,12 +58,12 @@ class BaseTests(object):
def setUp(self): def setUp(self):
self.settings_override = override_settings_tags( self.settings_override = override_settings_tags(
TEMPLATE_DIRS = (), TEMPLATE_DIRS=(),
TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS, TEMPLATE_CONTEXT_PROCESSORS=global_settings.TEMPLATE_CONTEXT_PROCESSORS,
MESSAGE_TAGS = '', MESSAGE_TAGS='',
MESSAGE_STORAGE = '%s.%s' % (self.storage_class.__module__, MESSAGE_STORAGE='%s.%s' % (self.storage_class.__module__,
self.storage_class.__name__), self.storage_class.__name__),
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer', SESSION_SERIALIZER='django.contrib.sessions.serializers.JSONSerializer',
) )
self.settings_override.enable() self.settings_override.enable()

View File

@ -121,23 +121,23 @@ class Feed(object):
link = add_domain(current_site.domain, link, request.is_secure()) link = add_domain(current_site.domain, link, request.is_secure())
feed = self.feed_type( feed = self.feed_type(
title = self.__get_dynamic_attr('title', obj), title=self.__get_dynamic_attr('title', obj),
subtitle = self.__get_dynamic_attr('subtitle', obj), subtitle=self.__get_dynamic_attr('subtitle', obj),
link = link, link=link,
description = self.__get_dynamic_attr('description', obj), description=self.__get_dynamic_attr('description', obj),
language = settings.LANGUAGE_CODE, language=settings.LANGUAGE_CODE,
feed_url = add_domain( feed_url=add_domain(
current_site.domain, current_site.domain,
self.__get_dynamic_attr('feed_url', obj) or request.path, self.__get_dynamic_attr('feed_url', obj) or request.path,
request.is_secure(), request.is_secure(),
), ),
author_name = self.__get_dynamic_attr('author_name', obj), author_name=self.__get_dynamic_attr('author_name', obj),
author_link = self.__get_dynamic_attr('author_link', obj), author_link=self.__get_dynamic_attr('author_link', obj),
author_email = self.__get_dynamic_attr('author_email', obj), author_email=self.__get_dynamic_attr('author_email', obj),
categories = self.__get_dynamic_attr('categories', obj), categories=self.__get_dynamic_attr('categories', obj),
feed_copyright = self.__get_dynamic_attr('feed_copyright', obj), feed_copyright=self.__get_dynamic_attr('feed_copyright', obj),
feed_guid = self.__get_dynamic_attr('feed_guid', obj), feed_guid=self.__get_dynamic_attr('feed_guid', obj),
ttl = self.__get_dynamic_attr('ttl', obj), ttl=self.__get_dynamic_attr('ttl', obj),
**self.feed_extra_kwargs(obj) **self.feed_extra_kwargs(obj)
) )
@ -175,9 +175,9 @@ class Feed(object):
enc_url = self.__get_dynamic_attr('item_enclosure_url', item) enc_url = self.__get_dynamic_attr('item_enclosure_url', item)
if enc_url: if enc_url:
enc = feedgenerator.Enclosure( enc = feedgenerator.Enclosure(
url = smart_text(enc_url), url=smart_text(enc_url),
length = smart_text(self.__get_dynamic_attr('item_enclosure_length', item)), length=smart_text(self.__get_dynamic_attr('item_enclosure_length', item)),
mime_type = smart_text(self.__get_dynamic_attr('item_enclosure_mime_type', item)) mime_type=smart_text(self.__get_dynamic_attr('item_enclosure_mime_type', item))
) )
author_name = self.__get_dynamic_attr('item_author_name', item) author_name = self.__get_dynamic_attr('item_author_name', item)
if author_name is not None: if author_name is not None:
@ -197,20 +197,20 @@ class Feed(object):
updateddate = make_aware(updateddate, tz) updateddate = make_aware(updateddate, tz)
feed.add_item( feed.add_item(
title = title, title=title,
link = link, link=link,
description = description, description=description,
unique_id = self.__get_dynamic_attr('item_guid', item, link), unique_id=self.__get_dynamic_attr('item_guid', item, link),
unique_id_is_permalink = self.__get_dynamic_attr( unique_id_is_permalink=self.__get_dynamic_attr(
'item_guid_is_permalink', item), 'item_guid_is_permalink', item),
enclosure = enc, enclosure=enc,
pubdate = pubdate, pubdate=pubdate,
updateddate = updateddate, updateddate=updateddate,
author_name = author_name, author_name=author_name,
author_email = author_email, author_email=author_email,
author_link = author_link, author_link=author_link,
categories = self.__get_dynamic_attr('item_categories', item), categories=self.__get_dynamic_attr('item_categories', item),
item_copyright = self.__get_dynamic_attr('item_copyright', item), item_copyright=self.__get_dynamic_attr('item_copyright', item),
**self.item_extra_kwargs(item) **self.item_extra_kwargs(item)
) )
return feed return feed

View File

@ -38,7 +38,7 @@ def _samefile(src, dst):
os.path.normcase(os.path.abspath(dst))) os.path.normcase(os.path.abspath(dst)))
def file_move_safe(old_file_name, new_file_name, chunk_size = 1024*64, allow_overwrite=False): def file_move_safe(old_file_name, new_file_name, chunk_size=1024*64, allow_overwrite=False):
""" """
Moves a file from one location to another in the safest way possible. Moves a file from one location to another in the safest way possible.

View File

@ -193,13 +193,13 @@ class MemoryFileUploadHandler(FileUploadHandler):
self.file.seek(0) self.file.seek(0)
return InMemoryUploadedFile( return InMemoryUploadedFile(
file = self.file, file=self.file,
field_name = self.field_name, field_name=self.field_name,
name = self.file_name, name=self.file_name,
content_type = self.content_type, content_type=self.content_type,
size = file_size, size=file_size,
charset = self.charset, charset=self.charset,
content_type_extra = self.content_type_extra content_type_extra=self.content_type_extra
) )

View File

@ -239,7 +239,7 @@ class Command(NoArgsCommand):
if settings.configured: if settings.configured:
settings.USE_I18N = True settings.USE_I18N = True
else: else:
settings.configure(USE_I18N = True) settings.configure(USE_I18N=True)
self.invoked_for_django = False self.invoked_for_django = False
if os.path.isdir(os.path.join('conf', 'locale')): if os.path.isdir(os.path.join('conf', 'locale')):

View File

@ -81,10 +81,10 @@ class MigrationAutodetector(object):
self.add_to_migration( self.add_to_migration(
app_label, app_label,
operations.CreateModel( operations.CreateModel(
name = model_state.name, name=model_state.name,
fields = model_state.fields, fields=model_state.fields,
options = model_state.options, options=model_state.options,
bases = model_state.bases, bases=model_state.bases,
) )
) )
# Phase 2 is progressively adding pending models, splitting up into two # Phase 2 is progressively adding pending models, splitting up into two
@ -99,10 +99,10 @@ class MigrationAutodetector(object):
self.add_to_migration( self.add_to_migration(
app_label, app_label,
operations.CreateModel( operations.CreateModel(
name = model_state.name, name=model_state.name,
fields = model_state.fields, fields=model_state.fields,
options = model_state.options, options=model_state.options,
bases = model_state.bases, bases=model_state.bases,
) )
) )
for field_name, other_app_label, other_model_name in related_fields: for field_name, other_app_label, other_model_name in related_fields:
@ -119,10 +119,10 @@ class MigrationAutodetector(object):
self.add_to_migration( self.add_to_migration(
app_label, app_label,
operations.CreateModel( operations.CreateModel(
name = model_state.name, name=model_state.name,
fields = [(n, f) for n, f in model_state.fields if n not in bad_fields], fields=[(n, f) for n, f in model_state.fields if n not in bad_fields],
options = model_state.options, options=model_state.options,
bases = model_state.bases, bases=model_state.bases,
) )
) )
# Add the bad fields to be made in a phase 3 # Add the bad fields to be made in a phase 3
@ -135,11 +135,11 @@ class MigrationAutodetector(object):
self.add_to_migration( self.add_to_migration(
app_label, app_label,
operations.AddField( operations.AddField(
model_name = model_name, model_name=model_name,
name = field_name, name=field_name,
field = model_state.get_field_by_name(field_name), field=model_state.get_field_by_name(field_name),
), ),
new = True, new=True,
) )
if app_label != other_app_label: if app_label != other_app_label:
self.add_dependency(app_label, other_app_label) self.add_dependency(app_label, other_app_label)
@ -172,9 +172,9 @@ class MigrationAutodetector(object):
self.add_to_migration( self.add_to_migration(
app_label, app_label,
operations.RenameField( operations.RenameField(
model_name = model_name, model_name=model_name,
old_name = removed_field_name, old_name=removed_field_name,
new_name = field_name, new_name=field_name,
) )
) )
old_field_names.remove(removed_field_name) old_field_names.remove(removed_field_name)
@ -189,9 +189,9 @@ class MigrationAutodetector(object):
self.add_to_migration( self.add_to_migration(
app_label, app_label,
operations.AddField( operations.AddField(
model_name = model_name, model_name=model_name,
name = field_name, name=field_name,
field = field, field=field,
) )
) )
# Old fields # Old fields
@ -199,8 +199,8 @@ class MigrationAutodetector(object):
self.add_to_migration( self.add_to_migration(
app_label, app_label,
operations.RemoveField( operations.RemoveField(
model_name = model_name, model_name=model_name,
name = field_name, name=field_name,
) )
) )
# The same fields # The same fields
@ -212,9 +212,9 @@ class MigrationAutodetector(object):
self.add_to_migration( self.add_to_migration(
app_label, app_label,
operations.AlterField( operations.AlterField(
model_name = model_name, model_name=model_name,
name = field_name, name=field_name,
field = new_model_state.get_field_by_name(field_name), field=new_model_state.get_field_by_name(field_name),
) )
) )
# unique_together changes # unique_together changes
@ -222,8 +222,8 @@ class MigrationAutodetector(object):
self.add_to_migration( self.add_to_migration(
app_label, app_label,
operations.AlterUniqueTogether( operations.AlterUniqueTogether(
name = model_name, name=model_name,
unique_together = new_model_state.options.get("unique_together", set()), unique_together=new_model_state.options.get("unique_together", set()),
) )
) )
# Alright, now add internal dependencies # Alright, now add internal dependencies

View File

@ -26,7 +26,7 @@ class ProjectState(object):
def clone(self): def clone(self):
"Returns an exact copy of this ProjectState" "Returns an exact copy of this ProjectState"
return ProjectState( return ProjectState(
models = dict((k, v.clone()) for k, v in self.models.items()) models=dict((k, v.clone()) for k, v in self.models.items())
) )
def render(self): def render(self):
@ -137,11 +137,11 @@ class ModelState(object):
fields.append((name, field_class(*args, **kwargs))) fields.append((name, field_class(*args, **kwargs)))
# Now make a copy # Now make a copy
return self.__class__( return self.__class__(
app_label = self.app_label, app_label=self.app_label,
name = self.name, name=self.name,
fields = fields, fields=fields,
options = dict(self.options), options=dict(self.options),
bases = self.bases, bases=self.bases,
) )
def render(self, app_cache): def render(self, app_cache):

View File

@ -43,20 +43,20 @@ def _initialize():
app_store=ModelDict(), app_store=ModelDict(),
# Mapping of installed app_labels to model modules for that app. # Mapping of installed app_labels to model modules for that app.
app_labels = {}, app_labels={},
# Mapping of app_labels to a dictionary of model names to model code. # Mapping of app_labels to a dictionary of model names to model code.
# May contain apps that are not installed. # May contain apps that are not installed.
app_models=ModelDict(), app_models=ModelDict(),
# Mapping of app_labels to errors raised when trying to import the app. # Mapping of app_labels to errors raised when trying to import the app.
app_errors = {}, app_errors={},
# Pending lookups for lazy relations # Pending lookups for lazy relations
pending_lookups = {}, pending_lookups={},
# -- Everything below here is only used when populating the cache -- # -- Everything below here is only used when populating the cache --
loads_installed = True, loads_installed=True,
loaded=False, loaded=False,
handled=set(), handled=set(),
postponed=[], postponed=[],

View File

@ -9,7 +9,7 @@ import traceback
import weakref import weakref
def safeRef(target, onDelete = None): def safeRef(target, onDelete=None):
"""Return a *safe* weak reference to a callable target """Return a *safe* weak reference to a callable target
target -- the object to be weakly referenced, if it's a target -- the object to be weakly referenced, if it's a

View File

@ -249,29 +249,29 @@ class BaseForm(object):
def as_table(self): def as_table(self):
"Returns this form rendered as HTML <tr>s -- excluding the <table></table>." "Returns this form rendered as HTML <tr>s -- excluding the <table></table>."
return self._html_output( return self._html_output(
normal_row = '<tr%(html_class_attr)s><th>%(label)s</th><td>%(errors)s%(field)s%(help_text)s</td></tr>', normal_row='<tr%(html_class_attr)s><th>%(label)s</th><td>%(errors)s%(field)s%(help_text)s</td></tr>',
error_row = '<tr><td colspan="2">%s</td></tr>', error_row='<tr><td colspan="2">%s</td></tr>',
row_ender = '</td></tr>', row_ender='</td></tr>',
help_text_html = '<br /><span class="helptext">%s</span>', help_text_html='<br /><span class="helptext">%s</span>',
errors_on_separate_row = False) errors_on_separate_row=False)
def as_ul(self): def as_ul(self):
"Returns this form rendered as HTML <li>s -- excluding the <ul></ul>." "Returns this form rendered as HTML <li>s -- excluding the <ul></ul>."
return self._html_output( return self._html_output(
normal_row = '<li%(html_class_attr)s>%(errors)s%(label)s %(field)s%(help_text)s</li>', normal_row='<li%(html_class_attr)s>%(errors)s%(label)s %(field)s%(help_text)s</li>',
error_row = '<li>%s</li>', error_row='<li>%s</li>',
row_ender = '</li>', row_ender='</li>',
help_text_html = ' <span class="helptext">%s</span>', help_text_html=' <span class="helptext">%s</span>',
errors_on_separate_row = False) errors_on_separate_row=False)
def as_p(self): def as_p(self):
"Returns this form rendered as HTML <p>s." "Returns this form rendered as HTML <p>s."
return self._html_output( return self._html_output(
normal_row = '<p%(html_class_attr)s>%(label)s %(field)s%(help_text)s</p>', normal_row='<p%(html_class_attr)s>%(label)s %(field)s%(help_text)s</p>',
error_row = '%s', error_row='%s',
row_ender = '</p>', row_ender='</p>',
help_text_html = ' <span class="helptext">%s</span>', help_text_html=' <span class="helptext">%s</span>',
errors_on_separate_row = True) errors_on_separate_row=True)
def non_field_errors(self): def non_field_errors(self):
""" """

View File

@ -495,7 +495,7 @@ class BoundaryIter(six.Iterator):
stream.unget(chunk[-rollback:]) stream.unget(chunk[-rollback:])
return chunk[:-rollback] return chunk[:-rollback]
def _find_boundary(self, data, eof = False): def _find_boundary(self, data, eof=False):
""" """
Finds a multipart boundary in data. Finds a multipart boundary in data.

View File

@ -196,7 +196,7 @@ class CsrfViewMiddleware(object):
# the expiry timer. # the expiry timer.
response.set_cookie(settings.CSRF_COOKIE_NAME, response.set_cookie(settings.CSRF_COOKIE_NAME,
request.META["CSRF_COOKIE"], request.META["CSRF_COOKIE"],
max_age = 60 * 60 * 24 * 7 * 52, max_age=60 * 60 * 24 * 7 * 52,
domain=settings.CSRF_COOKIE_DOMAIN, domain=settings.CSRF_COOKIE_DOMAIN,
path=settings.CSRF_COOKIE_PATH, path=settings.CSRF_COOKIE_PATH,
secure=settings.CSRF_COOKIE_SECURE, secure=settings.CSRF_COOKIE_SECURE,

View File

@ -126,9 +126,9 @@ class TemplateResponseMixin(object):
""" """
response_kwargs.setdefault('content_type', self.content_type) response_kwargs.setdefault('content_type', self.content_type)
return self.response_class( return self.response_class(
request = self.request, request=self.request,
template = self.get_template_names(), template=self.get_template_names(),
context = context, context=context,
**response_kwargs **response_kwargs
) )