Changeset 817
- Timestamp:
- 10/09/05 09:40:10 (3 years ago)
- Files:
-
- django/branches/new-admin/django/core/template.py (modified) (2 diffs)
- django/branches/new-admin/django/views/admin/main.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/new-admin/django/core/template.py
r802 r817 114 114 "Compilation stage" 115 115 self.nodelist = compile_string(template_string, filename) 116 from pprint import pprint, pformat 117 print "------------------------" 118 print filename 119 pprint(self.nodelist) 120 print "------------------------" 121 116 122 117 def __iter__(self): 123 118 for node in self.nodelist: … … 194 189 ) 195 190 191 def find_linebreaks(template_string): 192 for match in newline_re.finditer(template_string): 193 yield match.start() 196 194 197 195 def tokenize(template_string, filename): 198 196 "Return a list of tokens from a given template_string" 199 # remove all empty strings, because the regex has a tendency to add them 200 linebreaks = [match.start() for match in newline_re.finditer(template_string)] 201 lastline = len(linebreaks) 197 202 198 token_tups = [] 203 199 upto = 0 204 200 line = 1 201 #TODO:Py2.4 generator expression 202 linebreaks = find_linebreaks(template_string) 203 next_linebreak = linebreaks.next() 204 try: 205 for match in tag_re.finditer(template_string): 206 start, end = match.span() 207 if start > upto: 208 token_tups.append( (template_string[upto:start], line) ) 209 upto = start 210 211 while next_linebreak <= upto: 212 next_linebreak = linebreaks.next() 213 line += 1 214 215 token_tups.append( (template_string[start:end], line) ) 216 upto = end 205 217 206 207 for match in tag_re.finditer(template_string): 208 start, end = match.span() 209 if start > upto: 210 token_tups.append( (template_string[upto:start], line) ) 211 upto = start 212 while linebreaks and line != lastline and linebreaks[line] <= upto: 218 while next_linebreak <= upto: 219 next_linebreak = linebreaks.next() 213 220 line += 1 214 215 token_tups.append( (template_string[start:end], line) ) 216 upto = end 217 218 while linebreaks and line != lastline and linebreaks[line] <= upto: 219 line += 1 221 except StopIteration: 222 pass 220 223 221 224 last_bit = template_string[upto:] 222 225 if len(last_bit): 223 token_tups.append( (last_bit, line) ) 224 225 226 token_tups.append( (last_bit, line) ) 227 226 228 return [ create_token(tok, (filename, line)) for tok, line in token_tups] 227 229 django/branches/new-admin/django/views/admin/main.py
r802 r817 553 553 self.needs_add_label = field.rel and isinstance(field.rel, meta.ManyToOne) or isinstance(field.rel, meta.ManyToMany) and field.rel.to.admin 554 554 self.not_in_table = isinstance(self.field, meta.AutoField) 555 self.first = True555 self.first = False 556 556 557 557 classes = []
