From e0c3dd3318f6f4895554521c6bf69676635b1937 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Mon, 1 Aug 2005 21:29:52 +0000 Subject: [PATCH] Refactored meta.py -- created a django.core.meta package, with init.py and fields.py git-svn-id: http://code.djangoproject.com/svn/django/trunk@378 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/core/management.py | 4 +- django/core/{meta.py => meta/__init__.py} | 684 +--------------------- django/core/meta/fields.py | 667 +++++++++++++++++++++ django/models/__init__.py | 23 +- django/templatetags/adminapplist.py | 3 +- django/utils/functional.py | 4 + django/utils/text.py | 3 + django/views/admin/main.py | 34 +- 8 files changed, 712 insertions(+), 710 deletions(-) rename django/core/{meta.py => meta/__init__.py} (71%) create mode 100644 django/core/meta/fields.py create mode 100644 django/utils/functional.py diff --git a/django/core/management.py b/django/core/management.py index a8931de5442..6314ca6ac06 100644 --- a/django/core/management.py +++ b/django/core/management.py @@ -264,7 +264,7 @@ database_check.args = APP_ARGS def get_admin_index(mod): "Returns admin-index template snippet (in list form) for the given module." - from django.core import meta + from django.utils.text import capfirst output = [] app_label = mod._MODELS[0]._meta.app_label output.append('{%% if perms.%s %%}' % app_label) @@ -274,7 +274,7 @@ def get_admin_index(mod): output.append(MODULE_TEMPLATE % { 'app': app_label, 'mod': klass._meta.module_name, - 'name': meta.capfirst(klass._meta.verbose_name_plural), + 'name': capfirst(klass._meta.verbose_name_plural), 'addperm': klass._meta.get_add_permission(), 'changeperm': klass._meta.get_change_permission(), }) diff --git a/django/core/meta.py b/django/core/meta/__init__.py similarity index 71% rename from django/core/meta.py rename to django/core/meta/__init__.py index 98ce768f721..20b5ee68634 100644 --- a/django/core/meta.py +++ b/django/core/meta/__init__.py @@ -1,30 +1,20 @@ +from django.conf import settings from django.core import formfields, validators from django.core import db from django.core.exceptions import ObjectDoesNotExist -from django.conf import settings +from django.core.meta.fields import * +from django.utils.functional import curry +from django.utils.text import capfirst import copy, datetime, os, re, sys, types -# The values to use for "blank" in SelectFields. Will be appended to the start of most "choices" lists. -BLANK_CHOICE_DASH = [("", "---------")] -BLANK_CHOICE_NONE = [("", "None")] - # Admin stages. ADD, CHANGE, BOTH = 1, 2, 3 -# Values for Relation.edit_inline_type. -TABULAR, STACKED = 1, 2 - -# Values for filter_interface. -HORIZONTAL, VERTICAL = 1, 2 - -# Random entropy string used by "default" param. -NOT_PROVIDED = 'oijpwojefiojpanv' - # Size of each "chunk" for get_iterator calls. # Larger values are slightly faster at the expense of more storage space. GET_ITERATOR_CHUNK_SIZE = 100 -# Prefix (in python path style) to location of models. +# Prefix (in Python path style) to location of models. MODEL_PREFIX = 'django.models' # Methods on models with the following prefix will be removed and @@ -37,21 +27,10 @@ MANIPULATOR_FUNCTIONS_PREFIX = '_manipulator_' LOOKUP_SEPARATOR = '__' -RECURSIVE_RELATIONSHIP_CONSTANT = 'self' - #################### # HELPER FUNCTIONS # #################### -# capitalizes first letter of string -capfirst = lambda x: x and x[0].upper() + x[1:] - -# prepares a value for use in a LIKE query -prep_for_like_query = lambda x: str(x).replace("%", "\%").replace("_", "\_") - -# returns the