Changeset 4855
- Timestamp:
- 03/29/07 17:13:04 (2 years ago)
- Files:
-
- django/branches/boulder-oracle-sprint/django/contrib/flatpages/models.py (modified) (1 diff)
- django/branches/boulder-oracle-sprint/django/template/defaulttags.py (modified) (2 diffs)
- django/branches/boulder-oracle-sprint/django/test/simple.py (modified) (1 diff)
- django/branches/boulder-oracle-sprint/docs/templates.txt (modified) (1 diff)
- django/branches/boulder-oracle-sprint/docs/testing.txt (modified) (2 diffs)
- django/branches/boulder-oracle-sprint/docs/tutorial01.txt (modified) (5 diffs)
- django/branches/boulder-oracle-sprint/tests/regressiontests/templates/tests.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/boulder-oracle-sprint/django/contrib/flatpages/models.py
r4279 r4855 5 5 6 6 class FlatPage(models.Model): 7 url = models.CharField(_('URL'), maxlength=100, validator_list=[validators.isAlphaNumericURL], 7 url = models.CharField(_('URL'), maxlength=100, validator_list=[validators.isAlphaNumericURL], db_index=True, 8 8 help_text=_("Example: '/about/contact/'. Make sure to have leading and trailing slashes.")) 9 9 title = models.CharField(_('title'), maxlength=200) django/branches/boulder-oracle-sprint/django/template/defaulttags.py
r4842 r4855 281 281 return '' 282 282 283 class LoremNode(Node): 284 def __init__(self, count, method, common): 285 self.count, self.method, self.common = count, method, common 286 287 def render(self, context): 288 from django.utils.lorem_ipsum import words, paragraphs 289 try: 290 count = int(self.count.resolve(context)) 291 except (ValueError, TypeError): 292 count = 1 293 if self.method == 'w': 294 return words(count, common=self.common) 295 else: 296 paras = paragraphs(count, common=self.common) 297 if self.method == 'p': 298 paras = ['<p>%s</p>' % p for p in paras] 299 return '\n\n'.join(paras) 300 283 301 class NowNode(Node): 284 302 def __init__(self, format_string): … … 770 788 771 789 #@register.tag 790 def lorem(parser, token): 791 """ 792 Creates random latin text useful for providing test data in templates. 793 794 Usage format:: 795 796 {% lorem [count] [method] [random] %} 797 798 ``count`` is a number (or variable) containing the number of paragraphs or 799 words to generate (default is 1). 800 801 ``method`` is either ``w`` for words, ``p`` for HTML paragraphs, ``b`` for 802 plain-text paragraph blocks (default is ``b``). 803 804 ``random`` is the word ``random``, which if given, does not use the common 805 paragraph (starting "Lorem ipsum dolor sit amet, consectetuer..."). 806 807 Examples: 808 * ``{% lorem %}`` will output the common "lorem ipsum" paragraph 809 * ``{% lorem 3 p %}`` will output the common "lorem ipsum" paragraph 810 and two random paragraphs each wrapped in HTML ``<p>`` tags 811 * ``{% lorem 2 w random %}`` will output two random latin words 812 """ 813 bits = list(token.split_contents()) 814 tagname = bits[0] 815 # Random bit 816 common = bits[-1] != 'random' 817 if not common: 818 bits.pop() 819 # Method bit 820 if bits[-1] in ('w', 'p', 'b'): 821 method = bits.pop() 822 else: 823 method = 'b' 824 # Count bit 825 if len(bits) > 1: 826 count = bits.pop() 827 else: 828 count = '1' 829 count = parser.compile_filter(count) 830 if len(bits) != 1: 831 raise TemplateSyntaxError, "Incorrect format for %r tag" % tagname 832 return LoremNode(count, method, common) 833 lorem = register.tag(lorem) 834 835 #@register.tag 772 836 def now(parser, token): 773 837 """ django/branches/boulder-oracle-sprint/django/test/simple.py
r4695 r4855 85 85 teardown_test_environment() 86 86 87 return len(result.failures) 87 return len(result.failures) + len(result.errors) 88 88 django/branches/boulder-oracle-sprint/docs/templates.txt
r4842 r4855 625 625 626 626 See `Custom tag and filter libraries`_ for more information. 627 628 lorem 629 ~~~~~ 630 631 Display random latin text useful for providing sample data in templates. 632 633 Usage format: ``{% lorem [count] [method] [random] %}`` 634 635 =========== ============================================================= 636 Argument Description 637 =========== ============================================================= 638 ``count`` A number (or variable) containing the number of paragraphs or 639 words to generate (default is 1). 640 ``method`` Either ``w`` for words, ``p`` for HTML paragraphs or ``b`` 641 for plain-text paragraph blocks (default is ``b``). 642 ``random`` The word ``random``, which if given, does not use the common 643 paragraph ("Lorem ipsum dolor sit amet...") when generating 644 text. 645 646 Examples: 647 648 * ``{% lorem %}`` will output the common "lorem ipsum" paragraph. 649 * ``{% lorem 3 p %}`` will output the common "lorem ipsum" paragraph 650 and two random paragraphs each wrapped in HTML ``<p>`` tags. 651 * ``{% lorem 2 w random %}`` will output two random latin words. 627 652 628 653 now django/branches/boulder-oracle-sprint/docs/testing.txt
r4842 r4855 277 277 full list of HTTP status codes. 278 278 279 ``content`` The body of the response. Th eis the final page279 ``content`` The body of the response. This is the final page 280 280 content as rendered by the view, or any error message 281 281 (such as the URL for a 302 redirect). … … 469 469 FAILED (failures=1) 470 470 471 The return code for the script will indicate the number of tests that failed. 471 The return code for the script is the total number of failed and erroneous 472 tests. If all the tests pass, the return code is 0. 472 473 473 474 Regardless of whether the tests pass or fail, the test database is destroyed when django/branches/boulder-oracle-sprint/docs/tutorial01.txt
r4695 r4855 134 134 database's connection parameters: 135 135 136 * ``DATABASE_ENGINE`` -- Either 'postgresql ', 'mysql' or 'sqlite3'.137 More coming soon.136 * ``DATABASE_ENGINE`` -- Either 'postgresql_psycopg2', 'mysql' or 'sqlite3'. 137 Other backends are `also available`_. 138 138 * ``DATABASE_NAME`` -- The name of your database, or the full (absolute) 139 139 path to the database file if you're using SQLite. … … 144 144 (not used for SQLite). 145 145 146 .. _also available: ../settings/ 147 146 148 .. admonition:: Note 147 149 … … 320 322 python manage.py sql polls 321 323 322 You should see the following (the CREATE TABLE SQL statements for the polls app):: 324 You should see something similar to the following (the CREATE TABLE SQL statements 325 for the polls app):: 323 326 324 327 BEGIN; … … 338 341 Note the following: 339 342 343 * The exact output will vary depending on the database you are using. 344 340 345 * Table names are automatically generated by combining the name of the app 341 346 (``polls``) and the lowercase name of the model -- ``poll`` and … … 366 371 construction of your models. 367 372 368 * ``python manage.py sqlinitialdata polls`` -- Outputs any initial data 369 required for Django's admin framework and your models. 373 * ``python manage.py sqlcustom polls`` -- Outputs any custom SQL statements 374 (such as table modifications or constraints) that are defined for the 375 application. 370 376 371 377 * ``python manage.py sqlclear polls`` -- Outputs the necessary ``DROP django/branches/boulder-oracle-sprint/tests/regressiontests/templates/tests.py
r4841 r4855 655 655 'with02': ('{{ key }}{% with dict.key as key %}{{ key }}-{{ dict.key }}-{{ key }}{% endwith %}{{ key }}', {'dict': {'key':50}}, ('50-50-50', 'INVALID50-50-50INVALID')), 656 656 657 ### LOREM TAG ###################################################### 658 'lorem01': ('{% lorem %}', {}, '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.'), 659 'lorem02': ('{% lorem p %}', {}, '<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.</p>'), 660 'lorem03': ('{% lorem 6 w %}', {}, 'lorem ipsum dolor sit amet consectetur'), 661 657 662 ### NOW TAG ######################################################## 658 663 # Simple case
