Changeset 3581
- Timestamp:
- 08/13/06 20:03:32 (2 years ago)
- Files:
-
- django/branches/multiple-db-support/AUTHORS (modified) (3 diffs)
- django/branches/multiple-db-support/django/bin/compile-messages.py (modified) (1 diff)
- django/branches/multiple-db-support/django/conf/global_settings.py (modified) (1 diff)
- django/branches/multiple-db-support/django/conf/project_template/settings.py (modified) (1 diff)
- django/branches/multiple-db-support/django/contrib/admin/templates/admin/change_form.html (modified) (1 diff)
- django/branches/multiple-db-support/django/contrib/admin/templates/admin/edit_inline_tabular.html (modified) (1 diff)
- django/branches/multiple-db-support/django/contrib/admin/urls.py (modified) (1 diff)
- django/branches/multiple-db-support/django/contrib/admin/views/doc.py (modified) (9 diffs)
- django/branches/multiple-db-support/django/contrib/admin/views/main.py (modified) (1 diff)
- django/branches/multiple-db-support/django/contrib/flatpages/README.TXT (modified) (1 diff)
- django/branches/multiple-db-support/django/contrib/sessions/middleware.py (modified) (1 diff)
- django/branches/multiple-db-support/django/core/management.py (modified) (7 diffs)
- django/branches/multiple-db-support/django/core/servers/basehttp.py (modified) (1 diff)
- django/branches/multiple-db-support/django/core/urlresolvers.py (modified) (4 diffs)
- django/branches/multiple-db-support/django/db/backends/ansi/sql.py (modified) (2 diffs)
- django/branches/multiple-db-support/django/db/backends/postgresql_psycopg2/base.py (modified) (1 diff)
- django/branches/multiple-db-support/django/db/models/base.py (modified) (1 diff)
- django/branches/multiple-db-support/django/db/models/fields/__init__.py (modified) (1 diff)
- django/branches/multiple-db-support/django/db/models/__init__.py (modified) (2 diffs)
- django/branches/multiple-db-support/django/db/models/loading.py (modified) (2 diffs)
- django/branches/multiple-db-support/django/db/models/manipulators.py (modified) (1 diff)
- django/branches/multiple-db-support/django/http/__init__.py (modified) (2 diffs)
- django/branches/multiple-db-support/django/template/defaultfilters.py (modified) (2 diffs)
- django/branches/multiple-db-support/django/template/loaders/filesystem.py (modified) (1 diff)
- django/branches/multiple-db-support/django/views/generic/create_update.py (modified) (4 diffs)
- django/branches/multiple-db-support/docs/db-api.txt (modified) (3 diffs)
- django/branches/multiple-db-support/docs/documentation.txt (copied) (copied from django/trunk/docs/documentation.txt)
- django/branches/multiple-db-support/docs/generic_views.txt (modified) (1 diff)
- django/branches/multiple-db-support/docs/model-api.txt (modified) (1 diff)
- django/branches/multiple-db-support/docs/request_response.txt (modified) (2 diffs)
- django/branches/multiple-db-support/docs/sessions.txt (modified) (1 diff)
- django/branches/multiple-db-support/docs/settings.txt (modified) (1 diff)
- django/branches/multiple-db-support/docs/url_dispatch.txt (modified) (1 diff)
- django/branches/multiple-db-support/setup.py (modified) (1 diff)
- django/branches/multiple-db-support/tests/modeltests/empty/models.py (modified) (1 diff)
- django/branches/multiple-db-support/tests/modeltests/lookup/models.py (modified) (4 diffs)
- django/branches/multiple-db-support/tests/othertests/defaultfilters.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/multiple-db-support/AUTHORS
r3523 r3581 61 61 ChaosKCW 62 62 Ian Clelland <clelland@gmail.com> 63 crankycoder@gmail.com 63 64 Matt Croydon <http://www.postneo.com/> 64 65 Jonathan Daugherty (cygnus) <http://www.cprogrammer.org/> … … 126 127 David Schein 127 128 sopel 129 Thomas Steinacher <tom@eggdrop.ch> 128 130 Radek Švarz <http://www.svarz.cz/translate/> 129 131 Swaroop C H <http://www.swaroopch.info> … … 132 134 Tom Insam 133 135 Joe Topjian <http://joe.terrarum.net/geek/code/python/django/> 136 Karen Tracey <graybark@bellsouth.net> 134 137 Amit Upadhyay 135 138 Geert Vanderkelen django/branches/multiple-db-support/django/bin/compile-messages.py
r3427 r3581 15 15 sys.exit(1) 16 16 17 for (dirpath, dirnames, filenames)in os.walk(basedir):17 for dirpath, dirnames, filenames in os.walk(basedir): 18 18 for f in filenames: 19 19 if f.endswith('.po'): django/branches/multiple-db-support/django/conf/global_settings.py
r3427 r3581 256 256 SESSION_COOKIE_AGE = 60 * 60 * 24 * 7 * 2 # Age of cookie, in seconds (default: 2 weeks). 257 257 SESSION_COOKIE_DOMAIN = None # A string like ".lawrence.com", or None for standard domain cookie. 258 SESSION_COOKIE_SECURE = False # Whether the session cookie should be secure (https:// only). 258 259 SESSION_SAVE_EVERY_REQUEST = False # Whether to save the session data on every request. 259 260 SESSION_EXPIRE_AT_BROWSER_CLOSE = False # Whether sessions expire when a user closes his browser. django/branches/multiple-db-support/django/conf/project_template/settings.py
r2980 r3581 61 61 62 62 TEMPLATE_DIRS = ( 63 # Put strings here, like "/home/html/django_templates" .63 # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". 64 64 # Always use forward slashes, even on Windows. 65 # Don't forget to use absolute paths, not relative paths. 65 66 ) 66 67 django/branches/multiple-db-support/django/contrib/admin/templates/admin/change_form.html
r3355 r3581 22 22 </ul> 23 23 {% endif %}{% endif %} 24 <form {% if has_file_field %}enctype="multipart/form-data" {% endif %}action="{{ form_url }}" method="post" >{% block form_top %}{% endblock %}24 <form {% if has_file_field %}enctype="multipart/form-data" {% endif %}action="{{ form_url }}" method="post" id="{{ opts.module_name }}_form">{% block form_top %}{% endblock %} 25 25 <div> 26 26 {% if is_popup %}<input type="hidden" name="_popup" value="1" />{% endif %} django/branches/multiple-db-support/django/contrib/admin/templates/admin/edit_inline_tabular.html
r3355 r3581 8 8 {% endif %} 9 9 {% endfor %} 10 </tr></thead> 10 11 {% for fcw in bound_related_object.form_field_collection_wrappers %} 11 12 {% if change %}{% if original_row_needed %} django/branches/multiple-db-support/django/contrib/admin/urls.py
r3523 r3581 22 22 ('^doc/filters/$', 'django.contrib.admin.views.doc.template_filter_index'), 23 23 ('^doc/views/$', 'django.contrib.admin.views.doc.view_index'), 24 ('^doc/views/jump/$', 'django.contrib.admin.views.doc.jump_to_view'),25 24 ('^doc/views/(?P<view>[^/]+)/$', 'django.contrib.admin.views.doc.view_detail'), 26 25 ('^doc/models/$', 'django.contrib.admin.views.doc.model_index'), django/branches/multiple-db-support/django/contrib/admin/views/doc.py
r3427 r3581 44 44 title, body, metadata = utils.parse_docstring(tag_func.__doc__) 45 45 if title: 46 title = utils.parse_rst(title, 'tag', 'tag:'+ tag_name)46 title = utils.parse_rst(title, 'tag', _('tag:') + tag_name) 47 47 if body: 48 body = utils.parse_rst(body, 'tag', 'tag:'+ tag_name)48 body = utils.parse_rst(body, 'tag', _('tag:') + tag_name) 49 49 for key in metadata: 50 metadata[key] = utils.parse_rst(metadata[key], 'tag', 'tag:'+ tag_name)50 metadata[key] = utils.parse_rst(metadata[key], 'tag', _('tag:') + tag_name) 51 51 if library in template.builtins: 52 52 tag_library = None … … 75 75 title, body, metadata = utils.parse_docstring(filter_func.__doc__) 76 76 if title: 77 title = utils.parse_rst(title, 'filter', 'filter:'+ filter_name)77 title = utils.parse_rst(title, 'filter', _('filter:') + filter_name) 78 78 if body: 79 body = utils.parse_rst(body, 'filter', 'filter:'+ filter_name)79 body = utils.parse_rst(body, 'filter', _('filter:') + filter_name) 80 80 for key in metadata: 81 metadata[key] = utils.parse_rst(metadata[key], 'filter', 'filter:'+ filter_name)81 metadata[key] = utils.parse_rst(metadata[key], 'filter', _('filter:') + filter_name) 82 82 if library in template.builtins: 83 83 tag_library = None … … 133 133 title, body, metadata = utils.parse_docstring(view_func.__doc__) 134 134 if title: 135 title = utils.parse_rst(title, 'view', 'view:'+ view)135 title = utils.parse_rst(title, 'view', _('view:') + view) 136 136 if body: 137 body = utils.parse_rst(body, 'view', 'view:'+ view)137 body = utils.parse_rst(body, 'view', _('view:') + view) 138 138 for key in metadata: 139 metadata[key] = utils.parse_rst(metadata[key], 'model', 'view:'+ view)139 metadata[key] = utils.parse_rst(metadata[key], 'model', _('view:') + view) 140 140 return render_to_response('admin_doc/view_detail.html', { 141 141 'name': view, … … 162 162 app_mod = models.get_app(app_label) 163 163 except ImproperlyConfigured: 164 raise Http404, "App %r not found"% app_label164 raise Http404, _("App %r not found") % app_label 165 165 model = None 166 166 for m in models.get_models(app_mod): … … 169 169 break 170 170 if model is None: 171 raise Http404, "Model %r not found in app %r"% (model_name, app_label)171 raise Http404, _("Model %r not found in app %r") % (model_name, app_label) 172 172 173 173 opts = model._meta … … 181 181 data_type = related_object_name = field.rel.to.__name__ 182 182 app_label = field.rel.to._meta.app_label 183 verbose = utils.parse_rst(( "the related `%s.%s` object" % (app_label, data_type)), 'model', 'model:'+ data_type)183 verbose = utils.parse_rst((_("the related `%s.%s` object") % (app_label, data_type)), 'model', _('model:') + data_type) 184 184 else: 185 185 data_type = get_readable_field_data_type(field) … … 203 203 verbose = func.__doc__ 204 204 if verbose: 205 verbose = utils.parse_rst(utils.trim_docstring(verbose), 'model', 'model:'+ opts.module_name)205 verbose = utils.parse_rst(utils.trim_docstring(verbose), 'model', _('model:') + opts.module_name) 206 206 fields.append({ 207 207 'name': func_name, … … 212 212 # Gather related objects 213 213 for rel in opts.get_all_related_objects(): 214 verbose = "related `%s.%s` objects"% (rel.opts.app_label, rel.opts.object_name)214 verbose = _("related `%s.%s` objects") % (rel.opts.app_label, rel.opts.object_name) 215 215 accessor = rel.get_accessor_name() 216 216 fields.append({ 217 217 'name' : "%s.all" % accessor, 218 218 'data_type' : 'List', 219 'verbose' : utils.parse_rst( "all " + verbose , 'model', 'model:'+ opts.module_name),219 'verbose' : utils.parse_rst(_("all %s") % verbose , 'model', _('model:') + opts.module_name), 220 220 }) 221 221 fields.append({ 222 222 'name' : "%s.count" % accessor, 223 223 'data_type' : 'Integer', 224 'verbose' : utils.parse_rst( "number of " + verbose , 'model', 'model:'+ opts.module_name),224 'verbose' : utils.parse_rst(_("number of %s") % verbose , 'model', _('model:') + opts.module_name), 225 225 }) 226 226 … … 337 337 views.extend(extract_views_from_urlpatterns(p.url_patterns, base + p.regex.pattern)) 338 338 else: 339 raise TypeError, "%s does not appear to be a urlpattern object"% p339 raise TypeError, _("%s does not appear to be a urlpattern object") % p 340 340 return views 341 341 django/branches/multiple-db-support/django/contrib/admin/views/main.py
r3427 r3581 264 264 return HttpResponseRedirect(post_url_continue % pk_value) 265 265 if request.POST.has_key("_popup"): 266 return HttpResponse('<script type="text/javascript">opener.dismissAddAnotherPopup(window, % s, "%s");</script>' % \266 return HttpResponse('<script type="text/javascript">opener.dismissAddAnotherPopup(window, %r, "%s");</script>' % \ 267 267 (pk_value, str(new_object).replace('"', '\\"'))) 268 268 elif request.POST.has_key("_addanother"): django/branches/multiple-db-support/django/contrib/flatpages/README.TXT
r1189 r3581 3 3 For full documentation, see either of these: 4 4 5 * The file d jango/docs/flatpages.txt in the Django distribution5 * The file docs/flatpages.txt in the Django distribution 6 6 * http://www.djangoproject.com/documentation/flatpages/ on the Web 7 7 django/branches/multiple-db-support/django/contrib/sessions/middleware.py
r3113 r3581 89 89 datetime.datetime.now() + datetime.timedelta(seconds=settings.SESSION_COOKIE_AGE)) 90 90 response.set_cookie(settings.SESSION_COOKIE_NAME, session_key, 91 max_age=max_age, expires=expires, domain=settings.SESSION_COOKIE_DOMAIN) 91 max_age=max_age, expires=expires, domain=settings.SESSION_COOKIE_DOMAIN, 92 secure=settings.SESSION_COOKIE_SECURE or None) 92 93 return response django/branches/multiple-db-support/django/core/management.py
r3523 r3581 111 111 112 112 # Get installed models, so we generate REFERENCES right 113 # We trim models from the current app so that the sqlreset command does 114 # not generate invalid SQL (leaving models out of known_models is 115 # harmless, so we can be conservative). 113 116 manager = model._default_manager 114 117 tables = manager.get_table_list() 115 installed_models = manager.get_installed_models(tables) 118 installed_models = [ model for model in 119 manager.get_installed_models(tables) 120 if model not in app_models ] 116 121 models_output = set(installed_models) 117 122 builder = creation.builder … … 137 142 not_installed_models = set(pending_references.keys()) 138 143 if not_installed_models: 139 final_output.append('-- The following references should be added but depend on non-existant tables:')144 alter_sql = [] 140 145 for model in not_installed_models: 141 final_output.extend(['-- ' + sql 142 for sql in pending_references.pop(model)]) 143 146 alter_sql.extend(['-- ' + sql 147 for sql in pending_references.pop(model)]) 148 if alter_sql: 149 final_output.append('-- The following references should be added ' 150 'but depend on non-existent tables:') 151 final_output.extend(alter_sql) 144 152 # convert BoundStatements into strings 145 153 final_output = map(str, final_output) … … 564 572 introspection_module = get_introspection_module() 565 573 566 def table2model(table_name): 567 object_name = table_name.title().replace('_', '') 568 return object_name.endswith('s') and object_name[:-1] or object_name 574 table2model = lambda table_name: table_name.title().replace('_', '') 569 575 570 576 cursor = connection.cursor() … … 595 601 extra_params = {} # Holds Field parameters such as 'db_column'. 596 602 603 if ' ' in att_name: 604 extra_params['db_column'] = att_name 605 att_name = att_name.replace(' ', '') 606 comment_notes.append('Field renamed to remove spaces.') 597 607 if keyword.iskeyword(att_name): 598 608 extra_params['db_column'] = att_name … … 1011 1021 1012 1022 def runfcgi(args): 1013 """Run this project as a FastCGI application. requires flup.""" 1023 "Runs this project as a FastCGI application. Requires flup." 1024 from django.conf import settings 1025 from django.utils import translation 1026 # Activate the current language, because it won't get activated later. 1027 try: 1028 translation.activate(settings.LANGUAGE_CODE) 1029 except AttributeError: 1030 pass 1014 1031 from django.core.servers.fastcgi import runfastcgi 1015 1032 runfastcgi(args) … … 1168 1185 print style.SQL_KEYWORD("COMMIT;") 1169 1186 1170 def execute_manager(settings_mod, argv=None): 1187 def setup_environ(settings_mod): 1188 """ 1189 Configure the runtime environment. This can also be used by external 1190 scripts wanting to set up a similar environment to manage.py. 1191 """ 1171 1192 # Add this project to sys.path so that it's importable in the conventional 1172 1193 # way. For example, if this file (manage.py) lives in a directory … … 1180 1201 # Set DJANGO_SETTINGS_MODULE appropriately. 1181 1202 os.environ['DJANGO_SETTINGS_MODULE'] = '%s.settings' % project_name 1182 1203 return project_directory 1204 1205 def execute_manager(settings_mod, argv=None): 1206 project_directory = setup_environ(settings_mod) 1183 1207 action_mapping = DEFAULT_ACTION_MAPPING.copy() 1184 1208 django/branches/multiple-db-support/django/core/servers/basehttp.py
r3427 r3581 548 548 env['PATH_INFO'] = urllib.unquote(path) 549 549 env['QUERY_STRING'] = query 550 551 host = self.address_string()552 if host != self.client_address[0]:553 env['REMOTE_HOST'] = host554 550 env['REMOTE_ADDR'] = self.client_address[0] 555 551 django/branches/multiple-db-support/django/core/urlresolvers.py
r3523 r3581 87 87 def __init__(self, regex, callback, default_args=None): 88 88 # regex is a string representing a regular expression. 89 # callback is something like 'foo.views.news.stories.story_detail', 90 # which represents the path to a module and a view function name. 89 # callback is either a string like 'foo.views.news.stories.story_detail' 90 # which represents the path to a module and a view function name, or a 91 # callable object (view). 91 92 self.regex = re.compile(regex) 92 self.callback = callback 93 if callable(callback): 94 self._callback = callback 95 else: 96 self._callback = None 97 self._callback_str = callback 93 98 self.default_args = default_args or {} 94 99 … … 107 112 kwargs.update(self.default_args) 108 113 109 try: # Lazily load self.func. 110 return self.func, args, kwargs 111 except AttributeError: 112 self.func = self.get_callback() 113 return self.func, args, kwargs 114 115 def get_callback(self): 116 mod_name, func_name = get_mod_func(self.callback) 117 try: 118 return getattr(__import__(mod_name, '', '', ['']), func_name) 114 return self.callback, args, kwargs 115 116 def _get_callback(self): 117 if self._callback is not None: 118 return self._callback 119 mod_name, func_name = get_mod_func(self._callback_str) 120 try: 121 self._callback = getattr(__import__(mod_name, '', '', ['']), func_name) 119 122 except ImportError, e: 120 123 raise ViewDoesNotExist, "Could not import %s. Error was: %s" % (mod_name, str(e)) 121 124 except AttributeError, e: 122 125 raise ViewDoesNotExist, "Tried %s in module %s. Error was: %s" % (func_name, mod_name, str(e)) 126 return self._callback 127 callback = property(_get_callback) 123 128 124 129 def reverse(self, viewname, *args, **kwargs): 125 if viewname != self.callback: 130 mod_name, func_name = get_mod_func(viewname) 131 try: 132 lookup_view = getattr(__import__(mod_name, '', '', ['']), func_name) 133 except (ImportError, AttributeError): 134 raise NoReverseMatch 135 if lookup_view != self.callback: 126 136 raise NoReverseMatch 127 137 return self.reverse_helper(*args, **kwargs) … … 186 196 return self._resolve_special('500') 187 197 188 def reverse(self, viewname, *args, **kwargs): 198 def reverse(self, lookup_view, *args, **kwargs): 199 if not callable(lookup_view): 200 mod_name, func_name = get_mod_func(lookup_view) 201 try: 202 lookup_view = getattr(__import__(mod_name, '', '', ['']), func_name) 203 except (ImportError, AttributeError): 204 raise NoReverseMatch 189 205 for pattern in self.urlconf_module.urlpatterns: 190 206 if isinstance(pattern, RegexURLResolver): 191 207 try: 192 return pattern.reverse_helper( viewname, *args, **kwargs)208 return pattern.reverse_helper(lookup_view, *args, **kwargs) 193 209 except NoReverseMatch: 194 210 continue 195 elif pattern.callback == viewname:211 elif pattern.callback == lookup_view: 196 212 try: 197 213 return pattern.reverse_helper(*args, **kwargs) … … 200 216 raise NoReverseMatch 201 217 202 def reverse_helper(self, viewname, *args, **kwargs):203 sub_match = self.reverse( viewname, *args, **kwargs)218 def reverse_helper(self, lookup_view, *args, **kwargs): 219 sub_match = self.reverse(lookup_view, *args, **kwargs) 204 220 result = reverse_helper(self.regex, *args, **kwargs) 205 221 return result + sub_match django/branches/multiple-db-support/django/db/backends/ansi/sql.py
r3523 r3581 140 140 # For MySQL, r_name must be unique in the first 64 141 141 # characters. So we are careful with character usage here. 142 r_name = '%s_refs_%s_%x' % ( r_col,col,142 r_name = '%s_refs_%s_%x' % (col, r_col, 143 143 abs(hash((r_table, table)))) 144 144 sql = style.SQL_KEYWORD('ALTER TABLE') + ' %s ADD CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s (%s);' % \ … … 263 263 style.SQL_KEYWORD( 264 264 backend.get_drop_foreignkey_sql()), 265 style.SQL_FIELD(qn("%s_referencing_%s_%s" % 266 (col, r_table, r_col)))), 265 style.SQL_FIELD(qn("%s_refs_%s_%x" % 266 (col, r_col, 267 abs(hash((table, r_table))))) 268 )), 267 269 db.connection)) 268 270 del references_to_delete[model] django/branches/multiple-db-support/django/db/backends/postgresql_psycopg2/base.py
r3261 r3581 11 11 from django.core.exceptions import ImproperlyConfigured 12 12 raise ImproperlyConfigured, "Error loading psycopg2 module: %s" % e 13 14 # Register Unicode conversions 15 import psycopg2.extensions 16 psycopg2.extensions.register_type(psycopg2.extensions.UNICODE) 13 17 14 18 DatabaseError = Database.DatabaseError django/branches/multiple-db-support/django/db/models/base.py
r3502 r3581 181 181 if cursor.fetchone(): 182 182 db_values = [f.get_db_prep_save(f.pre_save(self, False)) for f in non_pks] 183 cursor.execute("UPDATE %s SET %s WHERE %s=%%s" % \ 184 (qn(self._meta.db_table), 185 ','.join(['%s=%%s' % qn(f.column) for f in non_pks]), 186 qn(self._meta.pk.column)), 187 db_values + [pk_val]) 183 if db_values: 184 cursor.execute("UPDATE %s SET %s WHERE %s=%%s" % \ 185 (qn(self._meta.db_table), 186 ','.join(['%s=%%s' % qn(f.column) for f in non_pks]), 187 qn(self._meta.pk.column)), 188 db_values + [pk_val]) 188 189 else: 189 190 record_exists = False django/branches/multiple-db-support/django/db/models/fields/__init__.py
r3523 r3581 21 21 22 22 # prepares a value for use in a LIKE query 23 prep_for_like_query = lambda x: str(x).replace(" %", "\%").replace("_", "\_")23 prep_for_like_query = lambda x: str(x).replace("\\", "\\\\").replace("%", "\%").replace("_", "\_") 24 24 25 25 # returns the <ul> class for a given radio_admin value django/branches/multiple-db-support/django/db/models/__init__.py
r3502 r3581 26 26 bits = func(*args, **kwargs) 27 27 viewname = bits[0] 28 return reverse(bits[0], None, *bits[1: 2])28 return reverse(bits[0], None, *bits[1:3]) 29 29 return inner 30 30 … … 48 48 49 49 def __get_value__(self): 50 return datetime.datetime.now() + self.delta50 return (datetime.datetime.now() + self.delta).date() 51 51 52 52 def __getattr__(self, attr): django/branches/multiple-db-support/django/db/models/loading.py
r3502 r3581 36 36 return _app_list 37 37 38 def get_app(app_label, emptyOK =False):38 def get_app(app_label, emptyOK=False): 39 39 "Returns the module containing the models for the given app_label. If the app has no models in it and 'emptyOK' is True, returns None." 40 40 get_apps() # Run get_apps() to populate the _app_list cache. Slightly hackish. … … 84 84 return model_list 85 85 86 def get_model(app_label, model_name, seed_cache =True):86 def get_model(app_label, model_name, seed_cache=True): 87 87 """ 88 88 Returns the model matching the given app_label and case-insensitive django/branches/multiple-db-support/django/db/models/manipulators.py
r3427 r3581 139 139 140 140 if child_follow: 141 obj_list = expanded_data [related.var_name].items()141 obj_list = expanded_data.get(related.var_name, {}).items() 142 142 if not obj_list: 143 143 continue django/branches/multiple-db-support/django/http/__init__.py
r3427 r3581 39 39 def get_full_path(self): 40 40 return '' 41 41 42 42 def is_secure(self): 43 43 return os.environ.get("HTTPS") == "on" … … 204 204 self.cookies[key][var.replace('_', '-')] = val 205 205 206 def delete_cookie(self, key): 207 try: 208 self.cookies[key]['max_age'] = 0 209 except KeyError: 210 pass 206 def delete_cookie(self, key, path='/', domain=None): 207 self.cookies[key] = '' 208 if path is not None: 209 self.cookies[key]['path'] = path 210 if domain is not None: 211 self.cookies[key]['domain'] = path 212 self.cookies[key]['expires'] = 0 213 self.cookies[key]['max-age'] = 0 211 214 212 215 def _get_content(self): django/branches/multiple-db-support/django/template/defaultfilters.py
r3427 r3581 340 340 "Formats a time according to the given format" 341 341 from django.utils.dateformat import time_format 342 if not value:342 if value in (None, ''): 343 343 return '' 344 344 if arg is None: … … 438 438 the comma is used for the singular case. 439 439 """ 440 if not ',' in arg: 440 if not ',' in arg: 441 441 arg = ',' + arg 442 442 bits = arg.split(',') django/branches/multiple-db-support/django/template/loaders/filesystem.py
r2809 r3581 18 18 except IOError: 19 19 tried.append(filepath) 20 if t emplate_dirs:20 if tried: 21 21 error_msg = "Tried %s" % tried 22 22 else: django/branches/multiple-db-support/django/views/generic/create_update.py
r3427 r3581 7 7 from django.http import Http404, HttpResponse, HttpResponseRedirect 8 8 from django.core.exceptions import ObjectDoesNotExist, ImproperlyConfigured 9 from django.utils.translation import gettext 9 10 10 11 def create_object(request, model, template_name=None, … … 40 41 41 42 if request.user.is_authenticated(): 42 request.user.message_set.create(message= "The %s was created successfully." % model._meta.verbose_name)43 request.user.message_set.create(message=gettext("The %(verbose_name)s was created successfully.") % {"verbose_name": model._meta.verbose_name}) 43 44 44 45 # Redirect to the new object: first by trying post_save_redirect, … … 114 115 115 116 if request.user.is_authenticated(): 116 request.user.message_set.create(message= "The %s was updated successfully." % model._meta.verbose_name)117 request.user.message_set.create(message=gettext("The %(verbose_name)s was updated successfully.") % {"verbose_name": model._meta.verbose_name}) 117 118 118 119 # Do a post-after-redirect so that reload works, etc. … … 181 182 object.delete() 182 183 if request.user.is_authenticated(): 183 request.user.message_set.create(message= "The %s was deleted." % model._meta.verbose_name)184 request.user.message_set.create(message=gettext("The %(verbose_name)s was deleted.") % {"verbose_name": model._meta.verbose_name}) 184 185 return HttpResponseRedirect(post_delete_redirect) 185 186 else: django/branches/multiple-db-support/docs/db-api.txt
r3523 r3581 719 719 720 720 p = Person.objects.create(first_name="Bruce", last_name="Springsteen") 721 721 722 722 and:: 723 723 724 724 p = Person(first_name="Bruce", last_name="Springsteen") 725 725 p.save() 726 726 727 727 are equivalent. 728 728 … … 1472 1472 1473 1473 In order to prevent database inconsistency, this method only exists on 1474 ``ForeignKey``s where ``null=True``. If the related field can't be set to 1475 ``None`` (``NULL``), then an object can't be removed from a relation 1476 without being added to another. In the above example, removing ``e`` from 1477 ``b.entry_set()`` is equivalent to doing ``e.blog = None``, and because 1478 the ``blog`` ``ForeignKey`` doesn't have ``null=True``, this is invalid. 1474 ``ForeignKey`` objects where ``null=True``. If the related field can't be 1475 set to ``None`` (``NULL``), then an object can't be removed from a 1476 relation without being added to another. In the above example, removing 1477 ``e`` from ``b.entry_set()`` is equivalent to doing ``e.blog = None``, 1478 and because the ``blog`` ``ForeignKey`` doesn't have ``null=True``, this 1479 is invalid. 1479 1480 1480 1481 * ``clear()``: Removes all objects from the related object set. … … 1560 1561 1561 1562 Queries involving related objects follow the same rules as queries involving 1562 normal value fields. When specifying the the value for a query to match, you 1563 may use either an object instance itself, or the primary key value for the 1563 normal value fields. When specifying the the value for a query to match, you 1564 may use either an object instance itself, or the primary key value for the 1564 1565 object. 1565 1566 1566 1567 For example, if you have a Blog object ``b`` with ``id=5``, the following 1567 1568 three queries would be identical:: 1568 1569 1569 1570 Entry.objects.filter(blog=b) # Query using object instance 1570 1571 Entry.objects.filter(blog=b.id) # Query using id from instance django/branches/multiple-db-support/docs/generic_views.txt
r3502 r3581 128 128 129 129 urlpatterns = patterns('django.views.generic.simple', 130 ('^foo/(? p<id>\d+)/$', 'redirect_to', {'url': '/bar/%(id)s/'}),130 ('^foo/(?P<id>\d+)/$', 'redirect_to', {'url': '/bar/%(id)s/'}), 131 131 ) 132 132 django/branches/multiple-db-support/docs/model-api.txt
r3427 r3581 223 223 the absolute URL to your image in a template with ``{{ 224 224 object.get_mug_shot_url }}``. 225 226 For example, say your ``MEDIA_ROOT`` is set to ``'/home/media'``, and 227 ``upload_to`` is set to ``'photos/%Y/%m/%d'``. The ``'%Y/%m/%d'`` part of 228 ``upload_to`` is strftime formatting; ``'%Y'`` is the four-digit year, 229 ``'%m'`` is the two-digit month and ``'%d'`` is the two-digit day. If you 230 upload a file on Jan. 15, 2007, it will be saved in the directory 231 ``/home/media/photos/2007/01/15``. 225 232 226 233 .. _`strftime formatting`: http://docs.python.org/lib/module-time.html#l2h-1941 django/branches/multiple-db-support/docs/request_response.txt
r3427 r3581 150 150 151 151 Example: ``"/music/bands/the_beatles/?print=true"`` 152
