Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Used property decorators in django/forms.py

  • Loading branch information...
commit 58062a6302a2bf1013d100deb053ccae2298bb84 1 parent 1686e0d
Claude Paroz authored January 25, 2013

Showing 1 changed file with 16 additions and 16 deletions. Show diff stats Hide diff stats

  1. 32  django/forms/forms.py
32  django/forms/forms.py
@@ -111,12 +111,12 @@ def __getitem__(self, name):
111 111
             raise KeyError('Key %r not found in Form' % name)
112 112
         return BoundField(self, field, name)
113 113
 
114  
-    def _get_errors(self):
  114
+    @property
  115
+    def errors(self):
115 116
         "Returns an ErrorDict for the data provided for the form"
116 117
         if self._errors is None:
117 118
             self.full_clean()
118 119
         return self._errors
119  
-    errors = property(_get_errors)
120 120
 
121 121
     def is_valid(self):
122 122
         """
@@ -322,7 +322,8 @@ def has_changed(self):
322 322
         """
323 323
         return bool(self.changed_data)
324 324
 
325  
-    def _get_changed_data(self):
  325
+    @property
  326
+    def changed_data(self):
326 327
         if self._changed_data is None:
327 328
             self._changed_data = []
328 329
             # XXX: For now we're asking the individual widgets whether or not the
@@ -350,9 +351,9 @@ def _get_changed_data(self):
350 351
                 elif field._has_changed(initial_value, data_value):
351 352
                     self._changed_data.append(name)
352 353
         return self._changed_data
353  
-    changed_data = property(_get_changed_data)
354 354
 
355  
-    def _get_media(self):
  355
+    @property
  356
+    def media(self):
356 357
         """
357 358
         Provide a description of all media required to render the widgets on this form
358 359
         """
@@ -360,7 +361,6 @@ def _get_media(self):
360 361
         for field in self.fields.values():
361 362
             media = media + field.widget.media
362 363
         return media
363  
-    media = property(_get_media)
364 364
 
365 365
     def is_multipart(self):
366 366
         """
@@ -432,13 +432,13 @@ def __len__(self):
432 432
     def __getitem__(self, idx):
433 433
         return list(self.__iter__())[idx]
434 434
 
435  
-    def _errors(self):
  435
+    @property
  436
+    def errors(self):
436 437
         """
437 438
         Returns an ErrorList for this field. Returns an empty ErrorList
438 439
         if there are none.
439 440
         """
440 441
         return self.form.errors.get(self.name, self.form.error_class())
441  
-    errors = property(_errors)
442 442
 
443 443
     def as_widget(self, widget=None, attrs=None, only_initial=False):
444 444
         """
@@ -479,12 +479,12 @@ def as_hidden(self, attrs=None, **kwargs):
479 479
         """
480 480
         return self.as_widget(self.field.hidden_widget(), attrs, **kwargs)
481 481
 
482  
-    def _data(self):
  482
+    @property
  483
+    def data(self):
483 484
         """
484 485
         Returns the data for this BoundField, or None if it wasn't given.
485 486
         """
486 487
         return self.field.widget.value_from_datadict(self.form.data, self.form.files, self.html_name)
487  
-    data = property(_data)
488 488
 
489 489
     def value(self):
490 490
         """
@@ -532,12 +532,13 @@ def css_classes(self, extra_classes=None):
532 532
             extra_classes.add(self.form.required_css_class)
533 533
         return ' '.join(extra_classes)
534 534
 
535  
-    def _is_hidden(self):
  535
+    @property
  536
+    def is_hidden(self):
536 537
         "Returns True if this BoundField's widget is hidden."
537 538
         return self.field.widget.is_hidden
538  
-    is_hidden = property(_is_hidden)
539 539
 
540  
-    def _auto_id(self):
  540
+    @property
  541
+    def auto_id(self):
541 542
         """
542 543
         Calculates and returns the ID attribute for this BoundField, if the
543 544
         associated Form has specified auto_id. Returns an empty string otherwise.
@@ -548,9 +549,9 @@ def _auto_id(self):
548 549
         elif auto_id:
549 550
             return self.html_name
550 551
         return ''
551  
-    auto_id = property(_auto_id)
552 552
 
553  
-    def _id_for_label(self):
  553
+    @property
  554
+    def id_for_label(self):
554 555
         """
555 556
         Wrapper around the field widget's `id_for_label` method.
556 557
         Useful, for example, for focusing on this field regardless of whether
@@ -559,4 +560,3 @@ def _id_for_label(self):
559 560
         widget = self.field.widget
560 561
         id_ = widget.attrs.get('id') or self.auto_id
561 562
         return widget.id_for_label(id_)
562  
-    id_for_label = property(_id_for_label)

0 notes on commit 58062a6

Please sign in to comment.
Something went wrong with that request. Please try again.