Changeset 2771
- Timestamp:
- 04/28/06 15:56:58 (2 years ago)
- Files:
-
- django/branches/magic-removal/django/contrib/admin/templatetags/admin_list.py (modified) (2 diffs)
- django/branches/magic-removal/django/contrib/admin/templatetags/admin_modify.py (modified) (2 diffs)
- django/branches/magic-removal/django/core/handlers/modpython.py (modified) (1 diff)
- django/branches/magic-removal/django/core/handlers/wsgi.py (modified) (1 diff)
- django/branches/magic-removal/django/core/management.py (modified) (2 diffs)
- django/branches/magic-removal/django/core/servers/basehttp.py (modified) (1 diff)
- django/branches/magic-removal/django/db/models/fields/__init__.py (modified) (2 diffs)
- django/branches/magic-removal/django/db/models/fields/related.py (modified) (2 diffs)
- django/branches/magic-removal/django/db/models/options.py (modified) (1 diff)
- django/branches/magic-removal/django/db/models/related.py (modified) (1 diff)
- django/branches/magic-removal/django/forms/__init__.py (modified) (2 diffs)
- django/branches/magic-removal/django/template/__init__.py (modified) (3 diffs)
- django/branches/magic-removal/django/template/loader_tags.py (modified) (2 diffs)
- django/branches/magic-removal/django/utils/functional.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/magic-removal/django/contrib/admin/templatetags/admin_list.py
r2700 r2771 18 18 def paginator_number(cl,i): 19 19 if i == DOT: 20 return '... '20 return '... ' 21 21 elif i == cl.page_num: 22 return '<span class="this-page">%d</span> ' % (i+1)22 return '<span class="this-page">%d</span> ' % (i+1) 23 23 else: 24 return '<a href="%s"%s>%d</a> ' % (cl.get_query_string({PAGE_VAR: i}), (i == cl.paginator.pages-1 and ' class="end"' or ''), i+1)24 return '<a href="%s"%s>%d</a> ' % (cl.get_query_string({PAGE_VAR: i}), (i == cl.paginator.pages-1 and ' class="end"' or ''), i+1) 25 25 paginator_number = register.simple_tag(paginator_number) 26 26 … … 168 168 result_repr = escape(str(field_val)) 169 169 if result_repr == '': 170 result_repr = ' '170 result_repr = ' ' 171 171 if first: # First column is a special case 172 172 first = False django/branches/magic-removal/django/contrib/admin/templatetags/admin_modify.py
r2700 r2771 103 103 104 104 def use_raw_id_admin(self): 105 return isinstance(self.field.rel, (models.ManyToOneRel, models.ManyToManyRel)) \105 return isinstance(self.field.rel, (models.ManyToOneRel, models.ManyToManyRel)) \ 106 106 and self.field.rel.raw_id_admin 107 107 … … 184 184 f = bound_field.field 185 185 if f.rel and isinstance(f.rel, models.ManyToManyRel) and f.rel.filter_interface: 186 return '<script type="text/javascript">addEvent(window, "load", function(e) {' \186 return '<script type="text/javascript">addEvent(window, "load", function(e) {' \ 187 187 ' SelectFilter.init("id_%s", "%s", %s, "%s"); });</script>\n' % ( 188 188 f.name, f.verbose_name, f.rel.filter_interface-1, settings.ADMIN_MEDIA_PREFIX) django/branches/magic-removal/django/core/handlers/modpython.py
r2641 r2771 33 33 def _get_request(self): 34 34 if not hasattr(self, '_request'): 35 self._request = datastructures.MergeDict(self.POST, self.GET)35 self._request = datastructures.MergeDict(self.POST, self.GET) 36 36 return self._request 37 37 django/branches/magic-removal/django/core/handlers/wsgi.py
r2715 r2771 80 80 def _get_request(self): 81 81 if not hasattr(self, '_request'): 82 self._request = datastructures.MergeDict(self.POST, self.GET)82 self._request = datastructures.MergeDict(self.POST, self.GET) 83 83 return self._request 84 84 django/branches/magic-removal/django/core/management.py
r2763 r2771 160 160 field_output.append(style.SQL_KEYWORD('PRIMARY KEY')) 161 161 if f.rel: 162 if f.rel.to in models_already_seen:163 field_output.append(style.SQL_KEYWORD('REFERENCES') + ' ' + \164 style.SQL_TABLE(backend.quote_name(f.rel.to._meta.db_table)) + ' (' + \165 style.SQL_FIELD(backend.quote_name(f.rel.to._meta.get_field(f.rel.field_name).column)) + ')'166 )167 else:168 # We haven't yet created the table to which this field169 # is related, so save it for later.170 pr = pending_references.setdefault(f.rel.to, []).append((klass, f))162 if f.rel.to in models_already_seen: 163 field_output.append(style.SQL_KEYWORD('REFERENCES') + ' ' + \ 164 style.SQL_TABLE(backend.quote_name(f.rel.to._meta.db_table)) + ' (' + \ 165 style.SQL_FIELD(backend.quote_name(f.rel.to._meta.get_field(f.rel.field_name).column)) + ')' 166 ) 167 else: 168 # We haven't yet created the table to which this field 169 # is related, so save it for later. 170 pr = pending_references.setdefault(f.rel.to, []).append((klass, f)) 171 171 table_output.append(' '.join(field_output)) 172 172 if opts.order_with_respect_to: … … 837 837 rel_opts = f.rel.to._meta 838 838 if f.rel.to not in models.get_models(): 839 e.add(opts, "'%s' has relation with uninstalled model %s" % (f.name, rel_opts.object_name))839 e.add(opts, "'%s' has relation with uninstalled model %s" % (f.name, rel_opts.object_name)) 840 840 841 841 rel_name = RelatedObject(f.rel.to, cls, f).get_accessor_name() django/branches/magic-removal/django/core/servers/basehttp.py
r2702 r2771 384 384 385 385 if not self.status: 386 raise AssertionError("write() before start_response()")386 raise AssertionError("write() before start_response()") 387 387 388 388 elif not self.headers_sent: django/branches/magic-removal/django/db/models/fields/__init__.py
r2737 r2771 306 306 def _get_val_from_obj(self, obj): 307 307 if obj: 308 return getattr(obj, self.attname)309 else: 310 return self.get_default()308 return getattr(obj, self.attname) 309 else: 310 return self.get_default() 311 311 312 312 def flatten_data(self, follow, obj=None): … … 578 578 579 579 def delete_file(self, instance): 580 if getattr(instance, self.attname):580 if getattr(instance, self.attname): 581 581 file_name = getattr(instance, 'get_%s_filename' % self.name)() 582 582 # If the file exists and no other object of this type references it, django/branches/magic-removal/django/db/models/fields/related.py
r2712 r2771 540 540 setattr(cls, related.get_accessor_name(), SingleRelatedObjectDescriptor(related)) 541 541 if not cls._meta.one_to_one_field: 542 cls._meta.one_to_one_field = self542 cls._meta.one_to_one_field = self 543 543 544 544 class ManyToManyField(RelatedField, Field): … … 614 614 instance_ids = [instance._get_pk_val() for instance in getattr(obj, self.name).all()] 615 615 if self.rel.raw_id_admin: 616 new_data[self.name] = ",".join([str(id) for id in instance_ids])616 new_data[self.name] = ",".join([str(id) for id in instance_ids]) 617 617 else: 618 new_data[self.name] = instance_ids618 new_data[self.name] = instance_ids 619 619 else: 620 620 # In required many-to-many fields with only one available choice, 621 621 # select that one available choice. 622 622 if not self.blank and not self.rel.edit_inline and not self.rel.raw_id_admin: 623 choices_list = self.get_choices_default()624 if len(choices_list) == 1:625 new_data[self.name] = [choices_list[0][0]]623 choices_list = self.get_choices_default() 624 if len(choices_list) == 1: 625 new_data[self.name] = [choices_list[0][0]] 626 626 return new_data 627 627 django/branches/magic-removal/django/db/models/options.py
r2655 r2771 240 240 241 241 def __repr__(self): 242 return "FieldSet: (%s, %s)" % (self.name, self.field_lines)242 return "FieldSet: (%s, %s)" % (self.name, self.field_lines) 243 243 244 244 def bind(self, field_mapping, original, bound_field_set_class): django/branches/magic-removal/django/db/models/related.py
r2534 r2771 53 53 count = len(objects) + self.field.rel.num_extra_on_change 54 54 if self.field.rel.min_num_in_admin: 55 count = max(count, self.field.rel.min_num_in_admin)55 count = max(count, self.field.rel.min_num_in_admin) 56 56 if self.field.rel.max_num_in_admin: 57 count = min(count, self.field.rel.max_num_in_admin)57 count = min(count, self.field.rel.max_num_in_admin) 58 58 59 59 change = count - len(objects) django/branches/magic-removal/django/forms/__init__.py
r2731 r2771 328 328 else: 329 329 try: 330 #individual fields deal with None values themselves331 new_data.setlist(name, [self.__class__.html2python(None)])330 #individual fields deal with None values themselves 331 new_data.setlist(name, [self.__class__.html2python(None)]) 332 332 except EmptyValue: 333 new_data.setlist(name, [])333 new_data.setlist(name, []) 334 334 335 335 … … 349 349 for validator in self.validator_list: 350 350 try: 351 self.run_validator(new_data, validator)351 self.run_validator(new_data, validator) 352 352 except validators.ValidationError, e: 353 353 errors.setdefault(self.field_name, []).extend(e.messages) django/branches/magic-removal/django/template/__init__.py
r2713 r2771 199 199 last_bit = self.template_string[upto:] 200 200 if last_bit: 201 token_tups.append( (last_bit, (upto, upto + len(last_bit))) )201 token_tups.append( (last_bit, (upto, upto + len(last_bit))) ) 202 202 return [self.create_token(tok, (self.origin, loc)) for tok, loc in token_tups] 203 203 … … 246 246 except TemplateSyntaxError, e: 247 247 if not self.compile_function_error(token, e): 248 raise248 raise 249 249 self.extend_nodelist(nodelist, compiled_result, token) 250 250 self.exit_command() … … 732 732 def render(self, context): 733 733 try: 734 output = self.filter_expression.resolve(context)734 output = self.filter_expression.resolve(context) 735 735 except TemplateSyntaxError, e: 736 736 if not hasattr(e, 'source'): django/branches/magic-removal/django/template/loader_tags.py
r2682 r2771 87 87 except: 88 88 if settings.TEMPLATE_DEBUG: 89 raise89 raise 90 90 self.template = None 91 91 … … 101 101 102 102 def render(self, context): 103 try:104 template_name = resolve_variable(self.template_name, context)105 t = get_template(template_name)106 return t.render(context)107 except TemplateSyntaxError, e:108 if settings.TEMPLATE_DEBUG:103 try: 104 template_name = resolve_variable(self.template_name, context) 105 t = get_template(template_name) 106 return t.render(context) 107 except TemplateSyntaxError, e: 108 if settings.TEMPLATE_DEBUG: 109 109 raise 110 return ''111 except:112 return '' # Fail silently for invalid included templates.110 return '' 111 except: 112 return '' # Fail silently for invalid included templates. 113 113 114 114 def do_block(parser, token): django/branches/magic-removal/django/utils/functional.py
r1328 r2771 25 25 # is delivered directly. So the result is memoized. 26 26 def __init__(self, args, kw): 27 self.__func = func28 self.__args = args29 self.__kw = kw30 self.__dispatch = {}31 for resultclass in resultclasses:32 self.__dispatch[resultclass] = {}33 for (k, v) in resultclass.__dict__.items():34 setattr(self, k, self.__promise__(resultclass, k, v))27 self.__func = func 28 self.__args = args 29 self.__kw = kw 30 self.__dispatch = {} 31 for resultclass in resultclasses: 32 self.__dispatch[resultclass] = {} 33 for (k, v) in resultclass.__dict__.items(): 34 setattr(self, k, self.__promise__(resultclass, k, v)) 35 35 36 36 def __promise__(self, klass, funcname, func):
