preferences.py
changeset 131 67f5d2fdca1d
parent 130 4212fd69d671
equal deleted inserted replaced
130:4212fd69d671 131:67f5d2fdca1d
   281                             assert False, "Not implemented yet..."
   281                             assert False, "Not implemented yet..."
   282 
   282 
   283                         else :
   283                         else :
   284                             # set
   284                             # set
   285                             cookies[key] = value
   285                             cookies[key] = value
       
   286                             cookies[key]["path"] = config.PREF_COOKIE_PATH
       
   287                             cookies[key]["expires"] = config.PREF_COOKIE_EXPIRE_SECONDS
   286 
   288 
   287                     # add headers
   289                     # add headers
   288                     for morsel in cookies.itervalues() :
   290                     for morsel in cookies.itervalues() :
   289                         response.add_header('Set-cookie', morsel.OutputString())
   291                         response.add_header('Set-cookie', morsel.OutputString())
   290 
   292 
   367         else :
   369         else :
   368             return pytz.timezone(name)
   370             return pytz.timezone(name)
   369 
   371 
   370     def is_default (self, tz) :
   372     def is_default (self, tz) :
   371         """
   373         """
   372             True if it's a FixedOffsetTimezone or PREF_TIMEZONE_DEFAULT
   374             True if it's a FixedOffsetTimezone or PREF_TIMEZONE_FALLBACK
   373         """
   375         """
   374 
   376 
   375         return (isinstance(tz, utils.FixedOffsetTimezone) or tz == config.PREF_TIMEZONE_DEFAULT)
   377         return (isinstance(tz, utils.FixedOffsetTimezone) or tz == config.PREF_TIMEZONE_FALLBACK)
   376 
   378 
   377     def build (self, tz) :
   379     def build (self, tz) :
   378         """
   380         """
   379             FixedOffsetTimezone -> None
   381             FixedOffsetTimezone -> None
   380             pytz.timezone -> tz_name
   382             pytz.timezone -> tz_name
   391     def process (self, prefs, tz) :
   393     def process (self, prefs, tz) :
   392         """
   394         """
   393             If this timezone is given, simply build that. Otherwise, try and use TimezoneOffset, and if that fails,
   395             If this timezone is given, simply build that. Otherwise, try and use TimezoneOffset, and if that fails,
   394             just return the default.
   396             just return the default.
   395 
   397 
   396             None -> FixedOffsetTimezone/PREF_TIMEZONE_DEFAULT
   398             None -> FixedOffsetTimezone/PREF_TIMEZONE_FALLBACK
   397             pytz.timezone -> pytz.timezone
   399             pytz.timezone -> pytz.timezone
   398         """
   400         """
   399         
   401         
   400         # specific timezone set?
   402         # specific timezone set?
   401         if tz != self.default :
   403         if tz != self.default :
   405         elif prefs[timezone_offset] is not None :
   407         elif prefs[timezone_offset] is not None :
   406             return utils.FixedOffsetTimezone(prefs[timezone_offset])
   408             return utils.FixedOffsetTimezone(prefs[timezone_offset])
   407         
   409         
   408         # default
   410         # default
   409         else :
   411         else :
   410             return config.PREF_TIMEZONE_DEFAULT
   412             return config.PREF_TIMEZONE_FALLBACK
   411 
   413 
   412 class ImageFont (Preference) :
   414 class ImageFont (Preference) :
   413     """
   415     """
   414         Font for ImageFormatter
   416         Font for ImageFormatter
   415     """
   417     """