magic-removal: Merged to [1971]

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@1972 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2006-01-15 05:55:48 +00:00
parent 2cfb709ac2
commit 974316939a
5 changed files with 13 additions and 9 deletions

View File

@ -34,6 +34,7 @@ answer newbie questions, and generally made Django that much better:
akaihola akaihola
Andreas Andreas
David Ascher <http://ascher.ca/> David Ascher <http://ascher.ca/>
Arthur <avandorp@gmail.com>
James Bennett James Bennett
Paul Bissex <http://e-scribe.com/> Paul Bissex <http://e-scribe.com/>
Simon Blanchard Simon Blanchard

View File

@ -58,10 +58,11 @@ def _get_contenttype_insert(opts):
def _is_valid_dir_name(s): def _is_valid_dir_name(s):
return bool(re.search(r'^\w+$', s)) return bool(re.search(r'^\w+$', s))
# If the foreign key points to an AutoField, the foreign key should be an # If the foreign key points to an AutoField, a PositiveIntegerField or a
# IntegerField, not an AutoField. Otherwise, the foreign key should be the same # PositiveSmallIntegerField, the foreign key should be an IntegerField, not the
# type of field as the field to which it points. # referred field type. Otherwise, the foreign key should be the same type of
get_rel_data_type = lambda f: (f.get_internal_type() == 'AutoField') and 'IntegerField' or f.get_internal_type() # field as the field to which it points.
get_rel_data_type = lambda f: (f.get_internal_type() in ('AutoField', 'PositiveIntegerField', 'PositiveSmallIntegerField')) and 'IntegerField' or f.get_internal_type()
def get_sql_create(app): def get_sql_create(app):
"Returns a list of the CREATE TABLE SQL statements for the given app." "Returns a list of the CREATE TABLE SQL statements for the given app."

View File

@ -52,6 +52,7 @@ def typecast_timestamp(s): # does NOT store time zone information
# "2005-07-29 15:48:00.590358-05" # "2005-07-29 15:48:00.590358-05"
# "2005-07-29 09:56:00-05" # "2005-07-29 09:56:00-05"
if not s: return None if not s: return None
if not ' ' in s: return typecast_date(s)
d, t = s.split() d, t = s.split()
# Extract timezone information, if it exists. Currently we just throw # Extract timezone information, if it exists. Currently we just throw
# it away, but in the future we may make use of it. # it away, but in the future we may make use of it.

View File

@ -38,8 +38,8 @@ def strip_tags(value):
return re.sub(r'<[^>]*?>', '', value) return re.sub(r'<[^>]*?>', '', value)
def strip_spaces_between_tags(value): def strip_spaces_between_tags(value):
"Returns the given HTML with spaces between tags stripped" "Returns the given HTML with spaces between tags normalized to a single space"
return re.sub(r'>\s+<', '><', value) return re.sub(r'>\s+<', '> <', value)
def strip_entities(value): def strip_entities(value):
"Returns the given HTML with all entities (&something;) stripped" "Returns the given HTML with all entities (&something;) stripped"

View File

@ -668,7 +668,8 @@ spaceless
**New in Django development version.** **New in Django development version.**
Strips whitespace between HTML tags. This includes tab characters and newlines. Normalizes whitespace between HTML tags to a single space. This includes tab
characters and newlines.
Example usage:: Example usage::
@ -680,9 +681,9 @@ Example usage::
This example would return this HTML:: This example would return this HTML::
<p><a href="foo/">Foo</a></p> <p> <a href="foo/">Foo</a> </p>
Only space between *tags* is stripped -- not space between tags and text. In Only space between *tags* is normalized -- not space between tags and text. In
this example, the space around ``Hello`` won't be stripped:: this example, the space around ``Hello`` won't be stripped::
{% spaceless %} {% spaceless %}