Django

Code

Changeset 4855

Show
Ignore:
Timestamp:
03/29/07 17:13:04 (2 years ago)
Author:
bouldersprinters
Message:

boulder-oracle-sprint: Merged to [4853].

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/boulder-oracle-sprint/django/contrib/flatpages/models.py

    r4279 r4855  
    55 
    66class 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, 
    88        help_text=_("Example: '/about/contact/'. Make sure to have leading and trailing slashes.")) 
    99    title = models.CharField(_('title'), maxlength=200) 
  • django/branches/boulder-oracle-sprint/django/template/defaulttags.py

    r4842 r4855  
    281281        return '' 
    282282 
     283class 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 
    283301class NowNode(Node): 
    284302    def __init__(self, format_string): 
     
    770788 
    771789#@register.tag 
     790def 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) 
     833lorem = register.tag(lorem)     
     834 
     835#@register.tag 
    772836def now(parser, token): 
    773837    """ 
  • django/branches/boulder-oracle-sprint/django/test/simple.py

    r4695 r4855  
    8585    teardown_test_environment() 
    8686     
    87     return len(result.failures) 
     87    return len(result.failures) + len(result.errors) 
    8888     
  • django/branches/boulder-oracle-sprint/docs/templates.txt

    r4842 r4855  
    625625 
    626626See `Custom tag and filter libraries`_ for more information. 
     627 
     628lorem 
     629~~~~~ 
     630 
     631Display random latin text useful for providing sample data in templates. 
     632 
     633Usage 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 
     646Examples: 
     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. 
    627652 
    628653now 
  • django/branches/boulder-oracle-sprint/docs/testing.txt

    r4842 r4855  
    277277                     full list of HTTP status codes. 
    278278 
    279     ``content``      The body of the response. The is the final page 
     279    ``content``      The body of the response. This is the final page 
    280280                     content as rendered by the view, or any error message 
    281281                     (such as the URL for a 302 redirect). 
     
    469469    FAILED (failures=1) 
    470470 
    471 The return code for the script will indicate the number of tests that failed. 
     471The return code for the script is the total number of failed and erroneous  
     472tests. If all the tests pass, the return code is 0. 
    472473 
    473474Regardless of whether the tests pass or fail, the test database is destroyed when 
  • django/branches/boulder-oracle-sprint/docs/tutorial01.txt

    r4695 r4855  
    134134database's connection parameters: 
    135135 
    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`_
    138138    * ``DATABASE_NAME`` -- The name of your database, or the full (absolute) 
    139139      path to the database file if you're using SQLite. 
     
    144144      (not used for SQLite). 
    145145 
     146.. _also available: ../settings/ 
     147 
    146148.. admonition:: Note 
    147149 
     
    320322    python manage.py sql polls 
    321323 
    322 You should see the following (the CREATE TABLE SQL statements for the polls app):: 
     324You should see something similar to the following (the CREATE TABLE SQL statements  
     325for the polls app):: 
    323326 
    324327    BEGIN; 
     
    338341Note the following: 
    339342 
     343    * The exact output will vary depending on the database you are using. 
     344     
    340345    * Table names are automatically generated by combining the name of the app 
    341346      (``polls``) and the lowercase name of the model -- ``poll`` and 
     
    366371      construction of your models. 
    367372 
    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.  
    370376 
    371377    * ``python manage.py sqlclear polls`` -- Outputs the necessary ``DROP 
  • django/branches/boulder-oracle-sprint/tests/regressiontests/templates/tests.py

    r4841 r4855  
    655655            'with02': ('{{ key }}{% with dict.key as key %}{{ key }}-{{ dict.key }}-{{ key }}{% endwith %}{{ key }}', {'dict': {'key':50}}, ('50-50-50', 'INVALID50-50-50INVALID')), 
    656656 
     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 
    657662            ### NOW TAG ######################################################## 
    658663            # Simple case