appobject.py
changeset 2476 1294a6bdf3bf
parent 2144 51c84d585456
child 2613 5e19c2bb370e
equal deleted inserted replaced
2475:b6753521129d 2476:1294a6bdf3bf
    38     Classes are kept in the vregistry and instantiation is done at selection
    38     Classes are kept in the vregistry and instantiation is done at selection
    39     time.
    39     time.
    40 
    40 
    41     At registration time, the following attributes are set on the class:
    41     At registration time, the following attributes are set on the class:
    42     :vreg:
    42     :vreg:
    43       the application's registry
    43       the instance's registry
    44     :schema:
    44     :schema:
    45       the application's schema
    45       the instance's schema
    46     :config:
    46     :config:
    47       the application's configuration
    47       the instance's configuration
    48 
    48 
    49     At instantiation time, the following attributes are set on the instance:
    49     At instantiation time, the following attributes are set on the instance:
    50     :req:
    50     :req:
    51       current request
    51       current request
    52     :rset:
    52     :rset:
   274         output = UStringIO()
   274         output = UStringIO()
   275         template.expand(context, output)
   275         template.expand(context, output)
   276         return output.getvalue()
   276         return output.getvalue()
   277 
   277 
   278     def format_date(self, date, date_format=None, time=False):
   278     def format_date(self, date, date_format=None, time=False):
   279         """return a string for a date time according to application's
   279         """return a string for a date time according to instance's
   280         configuration
   280         configuration
   281         """
   281         """
   282         if date:
   282         if date:
   283             if date_format is None:
   283             if date_format is None:
   284                 if time:
   284                 if time:
   287                     date_format = self.req.property_value('ui.date-format')
   287                     date_format = self.req.property_value('ui.date-format')
   288             return ustrftime(date, date_format)
   288             return ustrftime(date, date_format)
   289         return u''
   289         return u''
   290 
   290 
   291     def format_time(self, time):
   291     def format_time(self, time):
   292         """return a string for a time according to application's
   292         """return a string for a time according to instance's
   293         configuration
   293         configuration
   294         """
   294         """
   295         if time:
   295         if time:
   296             return ustrftime(time, self.req.property_value('ui.time-format'))
   296             return ustrftime(time, self.req.property_value('ui.time-format'))
   297         return u''
   297         return u''
   298 
   298 
   299     def format_float(self, num):
   299     def format_float(self, num):
   300         """return a string for floating point number according to application's
   300         """return a string for floating point number according to instance's
   301         configuration
   301         configuration
   302         """
   302         """
   303         if num:
   303         if num:
   304             return self.req.property_value('ui.float-format') % num
   304             return self.req.property_value('ui.float-format') % num
   305         return u''
   305         return u''