Commits

Anonymous committed bfdde2d

0.12.3dev: Fixed two misuses of `property()`, and cleaned up all other instances.

Closes #10078.

  • Participants
  • Parent commits 270a193
  • Branches 0.12-stable

Comments (0)

Files changed (6)

             DatabaseManager(self).shutdown()
         return True
 
-    def _get_href(self):
+    @property
+    def href(self):
+        """The application root path"""
         if not self._href:
             self._href = Href(urlsplit(self.abs_href.base)[2])
         return self._href
-    href = property(_get_href, 'The application root path')
 
-    def _get_abs_href(self):
+    @property
+    def abs_href(self):
+        """The application URL"""
         if not self._abs_href:
             if not self.base_url:
                 self.log.warn('base_url option not set in configuration, '
             else:
                 self._abs_href = Href(self.base_url)
         return self._abs_href
-    abs_href = property(_get_abs_href, 'The application URL')
 
 
 class EnvironmentSetup(Component):

File trac/ticket/model.py

     def _get_db(self, db):
         return db or self.env.get_read_db()
 
-    exists = property(fget=lambda self: self.id is not None)
+    exists = property(lambda self: self.id is not None)
 
     def _init_defaults(self, db=None):
         for field in self.fields:
             self.value = self._old_value = None
             self.name = self._old_name = None
 
-    exists = property(fget=lambda self: self._old_value is not None)
+    exists = property(lambda self: self._old_value is not None)
 
     def delete(self, db=None):
         """Delete the enum value.
             self.owner = None
             self.description = None
 
-    exists = property(fget=lambda self: self._old_name is not None)
+    exists = property(lambda self: self._old_name is not None)
 
     def delete(self, db=None):
         """Delete the component.
             self.description = ''
             self._to_old()
 
-    def _get_resource(self):
+    @property
+    def resource(self):
         return Resource('milestone', self.name) ### .version !!!
-    resource = property(_get_resource)
 
     def _fetch(self, name, db=None):
         if not db:
                                    name=name), _('Invalid milestone name'))
         self._from_database(row)
 
-    exists = property(fget=lambda self: self._old['name'] is not None)
-    is_completed = property(fget=lambda self: self.completed is not None)
-    is_late = property(fget=lambda self: self.due and
-                                         self.due < datetime.now(utc))
+    exists = property(lambda self: self._old['name'] is not None)
+    is_completed = property(lambda self: self.completed is not None)
+    is_late = property(lambda self: self.due and
+                                    self.due < datetime.now(utc))
 
     def _from_database(self, row):
         name, due, completed, description = row
             self.time = None
             self.description = None
 
-    exists = property(fget=lambda self: self._old_name is not None)
+    exists = property(lambda self: self._old_name is not None)
 
     def delete(self, db=None):
         """Delete the version.

File trac/ticket/web_ui.py

             return getattr(TicketSystem(self.env), name)
         raise AttributeError("TicketModule has no attribute '%s'" % name)
 
-    def _must_preserve_newlines(self):
+    @property
+    def must_preserve_newlines(self):
         preserve_newlines = self.preserve_newlines
         if preserve_newlines == 'default':
             preserve_newlines = self.env.get_version(initial=True) >= 21 # 0.11
         return as_bool(preserve_newlines)
-    must_preserve_newlines = property(_must_preserve_newlines)
 
     # IContentConverter methods
 

File trac/util/presentation.py

     def __setitem__(self, idx, value):
         self.items[idx] = value
 
+    @property
     def has_more_pages(self):
         return self.num_pages > 1
-    has_more_pages = property(has_more_pages)
 
+    @property
     def has_next_page(self):
         return self.page + 1 < self.num_pages
-    has_next_page = property(has_next_page)
 
+    @property
     def has_previous_page(self):
         return self.page > 0
-    has_previous_page = property(has_previous_page)
    
     def get_shown_pages(self, page_index_count = 11):
         if self.has_more_pages == False:

File trac/wiki/model.py

             self.time = None
             self.readonly = 0
             
-    exists = property(fget=lambda self: self.version > 0)
+    exists = property(lambda self: self.version > 0)
 
     def delete(self, version=None, db=None):
         assert self.exists, 'Cannot delete non-existent page'

File trac/wiki/parser.py

         self._helper_patterns = None
         self._external_handlers = None
 
-    def _get_rules(self):
+    @property
+    def rules(self):
         self._prepare_rules()
         return self._compiled_rules
-    rules = property(_get_rules)
 
-    def _get_helper_patterns(self):
+    @property
+    def helper_patterns(self):
         self._prepare_rules()
         return self._helper_patterns
-    helper_patterns = property(_get_helper_patterns)
 
-    def _get_external_handlers(self):
+    @property
+    def external_handlers(self):
         self._prepare_rules()
         return self._external_handlers
-    external_handlers = property(_get_external_handlers)
 
     def _prepare_rules(self):
         from trac.wiki.api import WikiSystem
             self._helper_patterns = helpers
             self._compiled_rules = rules
 
-    def _get_link_resolvers(self):
+    @property
+    def link_resolvers(self):
         if not self._link_resolvers:
             from trac.wiki.api import WikiSystem
             resolvers = {}
                     resolvers[namespace] = handler
             self._link_resolvers = resolvers
         return self._link_resolvers
-    link_resolvers = property(_get_link_resolvers)
 
     def parse(self, wikitext):
         """Parse `wikitext` and produce a WikiDOM tree."""