From bcc26d8eeae483814ad80c80a0336311b17de8bf Mon Sep 17 00:00:00 2001 From: Boulder Sprinters Date: Fri, 11 May 2007 16:03:48 +0000 Subject: [PATCH] boulder-oracle-sprint: Merged to [5193] git-svn-id: http://code.djangoproject.com/svn/django/branches/boulder-oracle-sprint@5194 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- .../conf/locale/zh_CN/LC_MESSAGES/django.mo | Bin 30798 -> 30798 bytes .../conf/locale/zh_CN/LC_MESSAGES/django.po | 2 +- .../conf/locale/zh_CN/LC_MESSAGES/djangojs.mo | Bin 1505 -> 1498 bytes .../conf/locale/zh_CN/LC_MESSAGES/djangojs.po | 2 +- django/contrib/webdesign/lorem_ipsum.py | 135 +++++++++--------- django/http/__init__.py | 4 + docs/install.txt | 16 +-- docs/templates_python.txt | 6 +- tests/regressiontests/httpwrappers/tests.py | 11 ++ 9 files changed, 97 insertions(+), 79 deletions(-) diff --git a/django/conf/locale/zh_CN/LC_MESSAGES/django.mo b/django/conf/locale/zh_CN/LC_MESSAGES/django.mo index 0d6bf90c0ee6f3de4ac035c8640733427dbc1031..3b0492065495b6dd3bc6d56035dca2d5a8f2b9ff 100644 GIT binary patch delta 17 ZcmX^2f$`i2#tjx_OuMFRwki{00sv6O2c`f3 delta 17 ZcmX^2f$`i2#tjx_OglO^Ta}400RT{S2bll> diff --git a/django/conf/locale/zh_CN/LC_MESSAGES/django.po b/django/conf/locale/zh_CN/LC_MESSAGES/django.po index 2552b677bd..1f30a08b15 100644 --- a/django/conf/locale/zh_CN/LC_MESSAGES/django.po +++ b/django/conf/locale/zh_CN/LC_MESSAGES/django.po @@ -1344,7 +1344,7 @@ msgstr "四月" #: utils/dates.py:19 msgid "may" -msgstr "三月" +msgstr "五月" #: utils/dates.py:19 msgid "jun" diff --git a/django/conf/locale/zh_CN/LC_MESSAGES/djangojs.mo b/django/conf/locale/zh_CN/LC_MESSAGES/djangojs.mo index ec7580a8629f346ef84074a06bd51e93dd549820..f0127a55a01a14f5434f1cf43a4f6736ce1e8413 100644 GIT binary patch delta 69 zcmaFJeT#d83L{@60|Uby76t}3AZ^AvS&LChRvO3*Vr5_u0MdCt+7(FG18I)pWxWCbkjD$_ delta 102 zcmcb`{g8Wu3S(#j0|Uby76t}3AZ^PEp c: - count = min(count - c, len(WORDS)) - word_list += random.sample(WORDS, count - c) - else: - word_list = word_list[:count] - return ' '.join(word_list) +""" +Utility functions for generating "lorem ipsum" Latin text. +""" + +import random + +COMMON_P = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.' +WORDS = ('exercitationem', 'perferendis', 'perspiciatis', 'laborum', 'eveniet', 'sunt', 'iure', 'nam', 'nobis', 'eum', 'cum', 'officiis', 'excepturi', 'odio', 'consectetur', 'quasi', 'aut', 'quisquam', 'vel', 'eligendi', 'itaque', 'non', 'odit', 'tempore', 'quaerat', 'dignissimos', 'facilis', 'neque', 'nihil', 'expedita', 'vitae', 'vero', 'ipsum', 'nisi', 'animi', 'cumque', 'pariatur', 'velit', 'modi', 'natus', 'iusto', 'eaque', 'sequi', 'illo', 'sed', 'ex', 'et', 'voluptatibus', 'tempora', 'veritatis', 'ratione', 'assumenda', 'incidunt', 'nostrum', 'placeat', 'aliquid', 'fuga', 'provident', 'praesentium', 'rem', 'necessitatibus', 'suscipit', 'adipisci', 'quidem', 'possimus', 'voluptas', 'debitis', 'sint', 'accusantium', 'unde', 'sapiente', 'voluptate', 'qui', 'aspernatur', 'laudantium', 'soluta', 'amet', 'quo', 'aliquam', 'saepe', 'culpa', 'libero', 'ipsa', 'dicta', 'reiciendis', 'nesciunt', 'doloribus', 'autem', 'impedit', 'minima', 'maiores', 'repudiandae', 'ipsam', 'obcaecati', 'ullam', 'enim', 'totam', 'delectus', 'ducimus', 'quis', 'voluptates', 'dolores', 'molestiae', 'harum', 'dolorem', 'quia', 'voluptatem', 'molestias', 'magni', 'distinctio', 'omnis', 'illum', 'dolorum', 'voluptatum', 'ea', 'quas', 'quam', 'corporis', 'quae', 'blanditiis', 'atque', 'deserunt', 'laboriosam', 'earum', 'consequuntur', 'hic', 'cupiditate', 'quibusdam', 'accusamus', 'ut', 'rerum', 'error', 'minus', 'eius', 'ab', 'ad', 'nemo', 'fugit', 'officia', 'at', 'in', 'id', 'quos', 'reprehenderit', 'numquam', 'iste', 'fugiat', 'sit', 'inventore', 'beatae', 'repellendus', 'magnam', 'recusandae', 'quod', 'explicabo', 'doloremque', 'aperiam', 'consequatur', 'asperiores', 'commodi', 'optio', 'dolor', 'labore', 'temporibus', 'repellat', 'veniam', 'architecto', 'est', 'esse', 'mollitia', 'nulla', 'a', 'similique', 'eos', 'alias', 'dolore', 'tenetur', 'deleniti', 'porro', 'facere', 'maxime', 'corrupti') +COMMON_WORDS = ('lorem', 'ipsum', 'dolor', 'sit', 'amet', 'consectetur', 'adipisicing', 'elit', 'sed', 'do', 'eiusmod', 'tempor', 'incididunt', 'ut', 'labore', 'et', 'dolore', 'magna', 'aliqua') + +def sentence(): + """ + Returns a randomly generated sentence of lorem ipsum text. + + The first word is capitalized, and the sentence ends in either a period or + question mark. Commas are added at random. + """ + # Determine the number of comma-separated sections and number of words in + # each section for this sentence. + sections = [' '.join(random.sample(WORDS, random.randint(3, 12))) for i in range(random.randint(1, 5))] + s = ', '.join(sections) + # Convert to sentence case and add end punctuation. + return '%s%s%s' % (s[0].upper(), s[1:], random.choice('?.')) + +def paragraph(): + """ + Returns a randomly generated paragraph of lorem ipsum text. + + The paragraph consists of between 1 and 4 sentences, inclusive. + """ + return ' '.join([sentence() for i in range(random.randint(1, 4))]) + +def paragraphs(count, common=True): + """ + Returns a list of paragraphs as returned by paragraph(). + + If `common` is True, then the first paragraph will be the standard + 'lorem ipsum' paragraph. Otherwise, the first paragraph will be random + Latin text. Either way, subsequent paragraphs will be random Latin text. + """ + paras = [] + for i in range(count): + if common and i == 0: + paras.append(COMMON_P) + else: + paras.append(paragraph()) + return paras + +def words(count, common=True): + """ + Returns a string of `count` lorem ipsum words separated by a single space. + + If `common` is True, then the first 19 words will be the standard + 'lorem ipsum' words. Otherwise, all words will be selected randomly. + """ + if common: + word_list = list(COMMON_WORDS) + else: + word_list = [] + c = len(word_list) + if count > c: + count -= c + while count > 0: + c = min(count, len(WORDS)) + count -= c + word_list += random.sample(WORDS, c) + else: + word_list = word_list[:count] + return ' '.join(word_list) diff --git a/django/http/__init__.py b/django/http/__init__.py index a0c51ff0da..74a4eff55c 100644 --- a/django/http/__init__.py +++ b/django/http/__init__.py @@ -91,6 +91,10 @@ class QueryDict(MultiValueDict): self._assert_mutable() MultiValueDict.__setitem__(self, key, value) + def __delitem__(self, key): + self._assert_mutable() + super(QueryDict, self).__delitem__(key) + def __copy__(self): result = self.__class__('', mutable=True) for key, value in dict.items(self): diff --git a/docs/install.txt b/docs/install.txt index defa3e38ad..c68179cba9 100644 --- a/docs/install.txt +++ b/docs/install.txt @@ -56,7 +56,7 @@ installed. either ``postgresql`` [for version 1] or ``postgresql_psycopg2`` [for version 2].) If you're on Windows, check out the unofficial `compiled Windows version`_. - + * If you're using MySQL, you'll need MySQLdb_, version 1.2.1p2 or higher. You will also want to read the database-specific notes for the `MySQL backend`_. @@ -78,16 +78,16 @@ installed. Remove any old versions of Django ================================= -If you are upgrading your installation of Django from a previous version, -you will need to uninstall the old Django version before installing the -new version. +If you are upgrading your installation of Django from a previous version, +you will need to uninstall the old Django version before installing the +new version. If you installed Django using ``setup.py install``, uninstalling -is as simple as deleting the ``django`` directory from your Python +is as simple as deleting the ``django`` directory from your Python ``site-packages``. -If you installed Django from a Python Egg, remove the Django ``.egg` file, -and remove the reference to the egg in the file named ``easy-install.pth``. +If you installed Django from a Python Egg, remove the Django ``.egg`` file, +and remove the reference to the egg in the file named ``easy-install.pth``. This file should also be located in your ``site-packages`` directory. .. admonition:: Where are my ``site-packages`` stored? @@ -95,7 +95,7 @@ This file should also be located in your ``site-packages`` directory. The location of the ``site-packages`` directory depends on the operating system, and the location in which Python was installed. However, the following locations are common: - + * If you're using Linux: ``/usr/lib/python2.X/site-packages`` * If you're using Windows: ``C:\Python2.X\lib\site-packages`` diff --git a/docs/templates_python.txt b/docs/templates_python.txt index 853707f58c..08a287f572 100644 --- a/docs/templates_python.txt +++ b/docs/templates_python.txt @@ -717,7 +717,7 @@ object:: # split_contents() knows not to split quoted strings. tag_name, format_string = token.split_contents() except ValueError: - raise template.TemplateSyntaxError, "%r tag requires a single argument" % token.contents[0] + raise template.TemplateSyntaxError, "%r tag requires a single argument" % token.contents.split()[0] if not (format_string[0] == format_string[-1] and format_string[0] in ('"', "'")): raise template.TemplateSyntaxError, "%r tag's argument should be in quotes" % tag_name return CurrentTimeNode(format_string[1:-1]) @@ -846,7 +846,7 @@ Now your tag should begin to look like this:: # split_contents() knows not to split quoted strings. tag_name, date_to_be_formatted, format_string = token.split_contents() except ValueError: - raise template.TemplateSyntaxError, "%r tag requires exactly two arguments" % token.contents[0] + raise template.TemplateSyntaxError, "%r tag requires exactly two arguments" % token.contents.split()[0] if not (format_string[0] == format_string[-1] and format_string[0] in ('"', "'")): raise template.TemplateSyntaxError, "%r tag's argument should be in quotes" % tag_name return FormatTimeNode(date_to_be_formatted, format_string[1:-1]) @@ -1080,7 +1080,7 @@ class, like so:: # Splitting by None == splitting by spaces. tag_name, arg = token.contents.split(None, 1) except ValueError: - raise template.TemplateSyntaxError, "%r tag requires arguments" % token.contents[0] + raise template.TemplateSyntaxError, "%r tag requires arguments" % token.contents.split()[0] m = re.search(r'(.*?) as (\w+)', arg) if not m: raise template.TemplateSyntaxError, "%r tag had invalid arguments" % tag_name diff --git a/tests/regressiontests/httpwrappers/tests.py b/tests/regressiontests/httpwrappers/tests.py index 29cb8385e0..c8016bc5bd 100644 --- a/tests/regressiontests/httpwrappers/tests.py +++ b/tests/regressiontests/httpwrappers/tests.py @@ -96,6 +96,12 @@ MultiValueDictKeyError: "Key 'foo' not found in " >>> q['name'] 'john' +>>> del q['name'] +>>> 'name' in q +False + +>>> q['name'] = 'john' + >>> q.get('foo', 'default') 'default' @@ -367,6 +373,11 @@ AttributeError: This QueryDict instance is immutable >>> q.urlencode() 'vote=yes&vote=no' +>>> del q['vote'] +Traceback (most recent call last): +... +AttributeError: This QueryDict instance is immutable + """ from django.http import QueryDict