Changeset 3630
- Timestamp:
- 08/20/06 17:49:48 (2 years ago)
- Files:
-
- django/branches/per-object-permissions/AUTHORS (modified) (1 diff)
- django/branches/per-object-permissions/django/bin/compile-messages.py (modified) (2 diffs)
- django/branches/per-object-permissions/django/conf/project_template/settings.py (modified) (1 diff)
- django/branches/per-object-permissions/django/contrib/admin/templates/admin/base.html (modified) (1 diff)
- django/branches/per-object-permissions/django/contrib/admin/views/doc.py (modified) (1 diff)
- django/branches/per-object-permissions/django/contrib/admin/views/main.py (modified) (2 diffs)
- django/branches/per-object-permissions/django/core/cache/backends/memcached.py (modified) (1 diff)
- django/branches/per-object-permissions/django/middleware/cache.py (modified) (1 diff)
- django/branches/per-object-permissions/django/middleware/http.py (modified) (1 diff)
- django/branches/per-object-permissions/docs/cache.txt (modified) (1 diff)
- django/branches/per-object-permissions/docs/faq.txt (modified) (2 diffs)
- django/branches/per-object-permissions/docs/i18n.txt (modified) (1 diff)
- django/branches/per-object-permissions/docs/middleware.txt (modified) (2 diffs)
- django/branches/per-object-permissions/docs/model-api.txt (modified) (5 diffs)
- django/branches/per-object-permissions/docs/templates_python.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/per-object-permissions/AUTHORS
r3583 r3630 69 69 dne@mayonnaise.net 70 70 Jeremy Dunck <http://dunck.us/> 71 Andy Dustman <farcepest@gmail.com> 71 72 Clint Ecker 72 73 gandalf@owca.info django/branches/per-object-permissions/django/bin/compile-messages.py
r3583 r3630 12 12 basedir = os.path.abspath('locale') 13 13 else: 14 print " this script should be run from the django svn tree or your project or app tree"14 print "This script should be run from the Django SVN tree or your project or app tree." 15 15 sys.exit(1) 16 16 … … 20 20 sys.stderr.write('processing file %s in %s\n' % (f, dirpath)) 21 21 pf = os.path.splitext(os.path.join(dirpath, f))[0] 22 cmd = 'msgfmt -o "%s.mo" "%s.po"' % (pf, pf) 22 # Store the names of the .mo and .po files in an environment 23 # variable, rather than doing a string replacement into the 24 # command, so that we can take advantage of shell quoting, to 25 # quote any malicious characters/escaping. 26 # See http://cyberelk.net/tim/articles/cmdline/ar01s02.html 27 os.environ['djangocompilemo'] = pf + '.mo' 28 os.environ['djangocompilepo'] = pf + '.po' 29 cmd = 'msgfmt -o "$djangocompilemo" "$djangocompilepo"' 23 30 os.system(cmd) 24 31 django/branches/per-object-permissions/django/conf/project_template/settings.py
r3583 r3630 27 27 28 28 SITE_ID = 1 29 30 # If you set this to False, Django will make some optimizations so as not 31 # to load the internationalization machinery. 32 USE_I18N = True 29 33 30 34 # Absolute path to the directory that holds media. django/branches/per-object-permissions/django/contrib/admin/templates/admin/base.html
r3464 r3630 7 7 {% block extrastyle %}{% endblock %} 8 8 {% block extrahead %}{% endblock %} 9 {% block blockbots %}<meta name="robots" content="NONE,NOARCHIVE" />{% endblock %} 9 10 </head> 10 11 {% load i18n %} django/branches/per-object-permissions/django/contrib/admin/views/doc.py
r3583 r3630 227 227 return render_to_response('admin_doc/model_detail.html', { 228 228 'name': '%s.%s' % (opts.app_label, opts.object_name), 229 'summary': "Fields on %s objects"% opts.object_name,229 'summary': _("Fields on %s objects") % opts.object_name, 230 230 'description': model.__doc__, 231 231 'fields': fields, django/branches/per-object-permissions/django/contrib/admin/views/main.py
r3629 r3630 273 273 return HttpResponseRedirect(post_url_continue % pk_value) 274 274 if request.POST.has_key("_popup"): 275 return HttpResponse('<script type="text/javascript">opener.dismissAddAnotherPopup(window, %r, "%s");</script>' % \ 275 if type(pk_value) is str: # Quote if string, so JavaScript doesn't think it's a variable. 276 pk_value = '"%s"' % pk_value.replace('"', '\\"') 277 return HttpResponse('<script type="text/javascript">opener.dismissAddAnotherPopup(window, %s, "%s");</script>' % \ 276 278 (pk_value, str(new_object).replace('"', '\\"'))) 277 279 elif request.POST.has_key("_addanother"): … … 735 737 736 738 # Apply keyword searches. 739 def construct_search(field_name): 740 if field_name.startswith('^'): 741 return "%s__istartswith" % field_name[1:] 742 elif field_name.startswith('='): 743 return "%s__iexact" % field_name[1:] 744 elif field_name.startswith('@'): 745 return "%s__search" % field_name[1:] 746 else: 747 return "%s__icontains" % field_name 748 737 749 if self.lookup_opts.admin.search_fields and self.query: 738 750 for bit in self.query.split(): 739 or_queries = [models.Q(**{ '%s__icontains' % field_name: bit}) for field_name in self.lookup_opts.admin.search_fields]751 or_queries = [models.Q(**{construct_search(field_name): bit}) for field_name in self.lookup_opts.admin.search_fields] 740 752 other_qs = QuerySet(self.model) 741 753 other_qs = other_qs.filter(reduce(operator.or_, or_queries)) django/branches/per-object-permissions/django/core/cache/backends/memcached.py
r2378 r3630 21 21 22 22 def set(self, key, value, timeout=0): 23 self._cache.set(key, value, timeout )23 self._cache.set(key, value, timeout or self.default_timeout) 24 24 25 25 def delete(self, key): django/branches/per-object-permissions/django/middleware/cache.py
r3464 r3630 42 42 def process_request(self, request): 43 43 "Checks whether the page is already cached and returns the cached version if available." 44 if self.cache_anonymous_only: 45 assert hasattr(request, 'user'), "The Django cache middleware with CACHE_MIDDLEWARE_ANONYMOUS_ONLY=True requires authentication middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.auth.middleware.AuthenticationMiddleware' before the CacheMiddleware." 46 44 47 if not request.method in ('GET', 'HEAD') or request.GET: 45 48 request._cache_update_cache = False django/branches/per-object-permissions/django/middleware/http.py
r3171 r3630 36 36 37 37 return response 38 39 class SetRemoteAddrFromForwardedFor(object): 40 """ 41 Middleware that sets REMOTE_ADDR based on HTTP_X_FORWARDED_FOR, if the 42 latter is set. This is useful if you're sitting behind a reverse proxy that 43 causes each request's REMOTE_ADDR to be set to 127.0.0.1. 44 45 Note that this does NOT validate HTTP_X_FORWARDED_FOR. If you're not behind 46 a reverse proxy that sets HTTP_X_FORWARDED_FOR automatically, do not use 47 this middleware. Anybody can spoof the value of HTTP_X_FORWARDED_FOR, and 48 because this sets REMOTE_ADDR based on HTTP_X_FORWARDED_FOR, that means 49 anybody can "fake" their IP address. Only use this when you can absolutely 50 trust the value of HTTP_X_FORWARDED_FOR. 51 """ 52 def process_request(self, request): 53 try: 54 real_ip = request.META['HTTP_X_FORWARDED_FOR'] 55 except KeyError: 56 return None 57 else: 58 # HTTP_X_FORWARDED_FOR can be a comma-separated list of IPs. 59 # Take just the first one. 60 real_ip = real_ip.split(",")[0] 61 request.META['REMOTE_ADDR'] = real_ip django/branches/per-object-permissions/docs/cache.txt
r3464 r3630 234 234 ``True``, only anonymous requests (i.e., not those made by a logged-in user) 235 235 will be cached. This is a simple and effective way of disabling caching for any 236 user-specific pages (include Django's admin interface). 236 user-specific pages (include Django's admin interface). Note that if you use 237 ``CACHE_MIDDLEWARE_ANONYMOUS_ONLY``, you should make sure you've activated 238 ``AuthenticationMiddleware`` and that ``AuthenticationMiddleware`` appears 239 before ``CacheMiddleware`` in your ``MIDDLEWARE_CLASSES``. 237 240 238 241 Additionally, ``CacheMiddleware`` automatically sets a few headers in each django/branches/per-object-permissions/docs/faq.txt
r3583 r3630 99 99 100 100 `Wilson Miner`_ 101 Wilson's design-fu makes us all look like rock stars. When not sneaking 102 into apartment complex swimming pools, he's the Commercial Development 103 Director for World Online, which means he makes the money that pays all our 104 paychecks. He lives in Lawrence, Kansas. 105 101 Wilson's design-fu makes us all look like rock stars. By day, he's an 102 interactive designer for `Apple`. Don't ask him what he's working on, or 103 he'll have to kill you. He lives in San Francisco. 104 106 105 On IRC, Wilson goes by ``wilsonian``. 107 106 … … 114 113 .. _`Jacob Kaplan-Moss`: http://www.jacobian.org/ 115 114 .. _`Wilson Miner`: http://www.wilsonminer.com/ 115 .. _`Apple`: http://www.apple.com/ 116 116 117 117 Which sites use Django? django/branches/per-object-permissions/docs/i18n.txt
r3464 r3630 49 49 ``USE_I18N = False`` in your settings file. If ``USE_I18N`` is set to 50 50 ``False``, then Django will make some optimizations so as not to load the 51 internationalization machinery. 52 53 See the `documentation for USE_I18N`_. 51 internationalization machinery. See the `documentation for USE_I18N`_. 52 53 You'll probably also want to remove ``'django.core.context_processors.i18n'`` 54 from your ``TEMPLATE_CONTEXT_PROCESSORS`` setting. 54 55 55 56 .. _documentation for USE_I18N: http://www.djangoproject.com/documentation/settings/#use-i18n django/branches/per-object-permissions/docs/middleware.txt
r2980 r3630 64 64 redirected to ``foo.com/bar/``, but ``foo.com/bar/file.txt`` is passed 65 65 through unchanged. 66 66 67 67 If ``PREPEND_WWW`` is ``True``, URLs that lack a leading "www." will be 68 68 redirected to the same URL with a leading "www." … … 101 101 Also removes the content from any response to a HEAD request and sets the 102 102 ``Date`` and ``Content-Length`` response-headers. 103 104 django.middleware.http.SetRemoteAddrFromForwardedFor 105 ---------------------------------------------------- 106 107 **New in Django development version** 108 109 Sets ``request['REMOTE_ADDR']`` based on ``request.['HTTP_X_FORWARDED_FOR']``, 110 if the latter is set. This is useful if you're sitting behind a reverse proxy 111 that causes each request's ``REMOTE_ADDR`` to be set to ``127.0.0.1``. 112 113 **Important note:** This does NOT validate ``HTTP_X_FORWARDED_FOR``. If you're 114 not behind a reverse proxy that sets ``HTTP_X_FORWARDED_FOR`` automatically, do 115 not use this middleware. Anybody can spoof the value of 116 ``HTTP_X_FORWARDED_FOR``, and because this sets ``REMOTE_ADDR`` based on 117 ``HTTP_X_FORWARDED_FOR``, that means anybody can "fake" their IP address. Only 118 use this when you can absolutely trust the value of ``HTTP_X_FORWARDED_FOR``. 103 119 104 120 django.contrib.sessions.middleware.SessionMiddleware django/branches/per-object-permissions/docs/model-api.txt
r3583 r3630 218 218 219 219 3. All that will be stored in your database is a path to the file 220 (relative to ``MEDIA_ROOT``). You'll m ust likely want to use the220 (relative to ``MEDIA_ROOT``). You'll most likely want to use the 221 221 convenience ``get_<fieldname>_url`` function provided by Django. For 222 222 example, if your ``ImageField`` is called ``mug_shot``, you can get … … 230 230 upload a file on Jan. 15, 2007, it will be saved in the directory 231 231 ``/home/media/photos/2007/01/15``. 232 233 Note that whenever you deal with uploaded files, you should pay close attention 234 to where you're uploading them and what type of files they are, to avoid 235 security holes. *Validate all uploaded files* so that you're sure the files are 236 what you think they are. For example, if you blindly let somebody upload files, 237 without validation, to a directory that's within your Web server's document 238 root, then somebody could upload a CGI or PHP script and execute that script by 239 visiting its URL on your site. Don't allow that. 232 240 233 241 .. _`strftime formatting`: http://docs.python.org/lib/module-time.html#l2h-1941 … … 679 687 # ... 680 688 681 Note, however, that support for strings around model names in ``ForeignKey`` is 682 quite new, and it can be buggy in some cases. 689 Note, however, that you can only use strings to refer to models in the same 690 models.py file -- you cannot use a string to reference a model in a different 691 application, or to reference a model that has been imported from elsewhere. 683 692 684 693 Behind the scenes, Django appends ``"_id"`` to the field name to create its … … 802 811 As with ``ForeignKey``, a relationship to self can be defined by using the 803 812 string ``'self'`` instead of the model name, and you can refer to as-yet 804 undefined models by using a string containing the model name. 813 undefined models by using a string containing the model name. However, you 814 can only use strings to refer to models in the same models.py file -- you 815 cannot use a string to reference a model in a different application, or to 816 reference a model that has been imported from elsewhere. 805 817 806 818 It's suggested, but not required, that the name of a ``ManyToManyField`` … … 1374 1386 WHERE (first_name ILIKE '%john%' OR last_name ILIKE '%john%') 1375 1387 AND (first_name ILIKE '%lennon%' OR last_name ILIKE '%lennon%') 1388 1389 **New in Django development version:** For faster and/or more restrictive 1390 searches, prefix the field name with an operator: 1391 1392 ``^`` 1393 Matches the beginning of the field. For example, if ``search_fields`` is 1394 set to ``['^first_name', '^last_name']`` and a user searches for 1395 ``john lennon``, Django will do the equivalent of this SQL ``WHERE`` 1396 clause:: 1397 1398 WHERE (first_name ILIKE 'john%' OR last_name ILIKE 'john%') 1399 AND (first_name ILIKE 'lennon%' OR last_name ILIKE 'lennon%') 1400 1401 This query is more efficient than the normal ``'%john%'`` query, because 1402 the database only needs to check the beginning of a column's data, rather 1403 than seeking through the entire column's data. Plus, if the column has an 1404 index on it, some databases may be able to use the index for this query, 1405 even though it's a ``LIKE`` query. 1406 1407 ``=`` 1408 Matches exactly, case-insensitive. For example, if 1409 ``search_fields`` is set to ``['=first_name', '=last_name']`` and 1410 a user searches for ``john lennon``, Django will do the equivalent 1411 of this SQL ``WHERE`` clause:: 1412 1413 WHERE (first_name ILIKE 'john' OR last_name ILIKE 'john') 1414 AND (first_name ILIKE 'lennon' OR last_name ILIKE 'lennon') 1415 1416 Note that the query input is split by spaces, so, following this example, 1417 it's not currently not possible to search for all records in which 1418 ``first_name`` is exactly ``'john winston'`` (containing a space). 1419 1420 ``@`` 1421 Performs a full-text match. This is like the default search method but uses 1422 an index. Currently this is only available for MySQL. 1376 1423 1377 1424 Managers django/branches/per-object-permissions/docs/templates_python.txt
r3583 r3630 260 260 variables, according to your `TEMPLATE_CONTEXT_PROCESSORS setting`_. 261 261 262 The ``TEMPLATE_CONTEXT_PROCESSORS`` setting is a tuple of callables that take a 263 request object as their argument and return a dictionary of items to be merged 264 into the context. By default, ``TEMPLATE_CONTEXT_PROCESSORS`` is set to:: 262 The ``TEMPLATE_CONTEXT_PROCESSORS`` setting is a tuple of callables -- called 263 **context processors** -- that take a request object as their argument and 264 return a dictionary of items to be merged into the context. By default, 265 ``TEMPLATE_CONTEXT_PROCESSORS`` is set to:: 265 266 266 267 ("django.core.context_processors.auth",
