mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	magic-removal: Made django.db.models.options.default_names UPPERCASE and a tuple
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@1739 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
		| @@ -4,20 +4,18 @@ from django.db.models.fields import AutoField | |||||||
| from django.db.models.loading import get_installed_model_modules | from django.db.models.loading import get_installed_model_modules | ||||||
| from django.db.models.query import orderlist2sql | from django.db.models.query import orderlist2sql | ||||||
| from django.db.models.exceptions import FieldDoesNotExist | from django.db.models.exceptions import FieldDoesNotExist | ||||||
|  |  | ||||||
| from bisect import bisect | from bisect import bisect | ||||||
|  |  | ||||||
| import re | import re | ||||||
|  |  | ||||||
| # Calculate the module_name using a poor-man's pluralization. | # Calculate the module_name using a poor-man's pluralization. | ||||||
| get_module_name = lambda class_name: class_name.lower() + 's' | get_module_name = lambda class_name: class_name.lower() + 's' | ||||||
|  |  | ||||||
| # Calculate the verbose_name by converting from InitialCaps to "lowercase with spaces". | # Calculate the verbose_name by converting from InitialCaps to "lowercase with spaces". | ||||||
| get_verbose_name = lambda class_name: re.sub('([A-Z])', ' \\1', class_name).lower().strip() | get_verbose_name = lambda class_name: re.sub('([A-Z])', ' \\1', class_name).lower().strip() | ||||||
|  |  | ||||||
|  | DEFAULT_NAMES = ('module_name', 'verbose_name', 'verbose_name_plural', 'db_table', 'ordering', | ||||||
| default_names = ['module_name','verbose_name','verbose_name_plural','db_table','ordering',  |  | ||||||
|                   'unique_together', 'admin','where_constraints', 'exceptions', 'permissions', |                   'unique_together', 'admin','where_constraints', 'exceptions', 'permissions', | ||||||
|                   'get_latest_by','order_with_respect_to', 'module_constants'] |                   'get_latest_by','order_with_respect_to', 'module_constants') | ||||||
|  |  | ||||||
| class Options: | class Options: | ||||||
|     def __init__(self, meta): |     def __init__(self, meta): | ||||||
| @@ -41,7 +39,7 @@ class Options: | |||||||
|         meta_attrs = self.meta.__dict__ |         meta_attrs = self.meta.__dict__ | ||||||
|         del meta_attrs['__module__'] |         del meta_attrs['__module__'] | ||||||
|         del meta_attrs['__doc__'] |         del meta_attrs['__doc__'] | ||||||
|         for attr_name in default_names: |         for attr_name in DEFAULT_NAMES: | ||||||
|             setattr(self, attr_name, meta_attrs.pop(attr_name, getattr(self, attr_name))) |             setattr(self, attr_name, meta_attrs.pop(attr_name, getattr(self, attr_name))) | ||||||
|         if meta_attrs != {}: |         if meta_attrs != {}: | ||||||
|             raise TypeError, "'class META' got invalid attribute(s): %s" % ','.join(meta_attrs.keys()) |             raise TypeError, "'class META' got invalid attribute(s): %s" % ','.join(meta_attrs.keys()) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user