mirror of
				https://github.com/django/django.git
				synced 2025-11-03 21:25:09 +00:00 
			
		
		
		
	Changed 'raise' statements to new style syntax in documentation. Thanks DaNmarner. Refs #15635.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15874 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
		
							parent
							
								
									c70bdad8b4
								
							
						
					
					
						commit
						413ceb57b2
					
				
					 3 changed files with 9 additions and 9 deletions
				
			
		| 
						 | 
					@ -351,9 +351,9 @@ object::
 | 
				
			||||||
            # split_contents() knows not to split quoted strings.
 | 
					            # split_contents() knows not to split quoted strings.
 | 
				
			||||||
            tag_name, format_string = token.split_contents()
 | 
					            tag_name, format_string = token.split_contents()
 | 
				
			||||||
        except ValueError:
 | 
					        except ValueError:
 | 
				
			||||||
            raise template.TemplateSyntaxError, "%r tag requires a single argument" % token.contents.split()[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 ('"', "'")):
 | 
					        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
 | 
					            raise template.TemplateSyntaxError("%r tag's argument should be in quotes" % tag_name)
 | 
				
			||||||
        return CurrentTimeNode(format_string[1:-1])
 | 
					        return CurrentTimeNode(format_string[1:-1])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Notes:
 | 
					Notes:
 | 
				
			||||||
| 
						 | 
					@ -596,9 +596,9 @@ Now your tag should begin to look like this::
 | 
				
			||||||
            # split_contents() knows not to split quoted strings.
 | 
					            # split_contents() knows not to split quoted strings.
 | 
				
			||||||
            tag_name, date_to_be_formatted, format_string = token.split_contents()
 | 
					            tag_name, date_to_be_formatted, format_string = token.split_contents()
 | 
				
			||||||
        except ValueError:
 | 
					        except ValueError:
 | 
				
			||||||
            raise template.TemplateSyntaxError, "%r tag requires exactly two arguments" % token.contents.split()[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 ('"', "'")):
 | 
					        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
 | 
					            raise template.TemplateSyntaxError("%r tag's argument should be in quotes" % tag_name)
 | 
				
			||||||
        return FormatTimeNode(date_to_be_formatted, format_string[1:-1])
 | 
					        return FormatTimeNode(date_to_be_formatted, format_string[1:-1])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
You also have to change the renderer to retrieve the actual contents of the
 | 
					You also have to change the renderer to retrieve the actual contents of the
 | 
				
			||||||
| 
						 | 
					@ -863,13 +863,13 @@ class, like so::
 | 
				
			||||||
            # Splitting by None == splitting by spaces.
 | 
					            # Splitting by None == splitting by spaces.
 | 
				
			||||||
            tag_name, arg = token.contents.split(None, 1)
 | 
					            tag_name, arg = token.contents.split(None, 1)
 | 
				
			||||||
        except ValueError:
 | 
					        except ValueError:
 | 
				
			||||||
            raise template.TemplateSyntaxError, "%r tag requires arguments" % token.contents.split()[0]
 | 
					            raise template.TemplateSyntaxError("%r tag requires arguments" % token.contents.split()[0])
 | 
				
			||||||
        m = re.search(r'(.*?) as (\w+)', arg)
 | 
					        m = re.search(r'(.*?) as (\w+)', arg)
 | 
				
			||||||
        if not m:
 | 
					        if not m:
 | 
				
			||||||
            raise template.TemplateSyntaxError, "%r tag had invalid arguments" % tag_name
 | 
					            raise template.TemplateSyntaxError("%r tag had invalid arguments" % tag_name)
 | 
				
			||||||
        format_string, var_name = m.groups()
 | 
					        format_string, var_name = m.groups()
 | 
				
			||||||
        if not (format_string[0] == format_string[-1] and format_string[0] in ('"', "'")):
 | 
					        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
 | 
					            raise template.TemplateSyntaxError("%r tag's argument should be in quotes" % tag_name)
 | 
				
			||||||
        return CurrentTimeNode3(format_string[1:-1], var_name)
 | 
					        return CurrentTimeNode3(format_string[1:-1], var_name)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
The difference here is that ``do_current_time()`` grabs the format string and
 | 
					The difference here is that ``do_current_time()`` grabs the format string and
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -170,7 +170,7 @@ straight lookups. Here are some things to keep in mind:
 | 
				
			||||||
        >>> t = Template("My name is {{ person.first_name }}.")
 | 
					        >>> t = Template("My name is {{ person.first_name }}.")
 | 
				
			||||||
        >>> class PersonClass3:
 | 
					        >>> class PersonClass3:
 | 
				
			||||||
        ...     def first_name(self):
 | 
					        ...     def first_name(self):
 | 
				
			||||||
        ...         raise AssertionError, "foo"
 | 
					        ...         raise AssertionError("foo")
 | 
				
			||||||
        >>> p = PersonClass3()
 | 
					        >>> p = PersonClass3()
 | 
				
			||||||
        >>> t.render(Context({"person": p}))
 | 
					        >>> t.render(Context({"person": p}))
 | 
				
			||||||
        Traceback (most recent call last):
 | 
					        Traceback (most recent call last):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -216,7 +216,7 @@ is where you define your own validation that works at the formset level::
 | 
				
			||||||
    ...             form = self.forms[i]
 | 
					    ...             form = self.forms[i]
 | 
				
			||||||
    ...             title = form.cleaned_data['title']
 | 
					    ...             title = form.cleaned_data['title']
 | 
				
			||||||
    ...             if title in titles:
 | 
					    ...             if title in titles:
 | 
				
			||||||
    ...                 raise forms.ValidationError, "Articles in a set must have distinct titles."
 | 
					    ...                 raise forms.ValidationError("Articles in a set must have distinct titles.")
 | 
				
			||||||
    ...             titles.append(title)
 | 
					    ...             titles.append(title)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    >>> ArticleFormSet = formset_factory(ArticleForm, formset=BaseArticleFormSet)
 | 
					    >>> ArticleFormSet = formset_factory(ArticleForm, formset=BaseArticleFormSet)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue