urltree.py
changeset 79 747554808944
parent 62 4c96d431336f
child 80 94c493b7c046
equal deleted inserted replaced
78:a46d2fc07951 79:747554808944
   146 class StaticLabel (Label) :
   146 class StaticLabel (Label) :
   147     """
   147     """
   148         A simple literal Label, used for fixed terms in the URL
   148         A simple literal Label, used for fixed terms in the URL
   149     """
   149     """
   150 
   150 
   151     EXPR = re.compile(r'^(?P<name>[a-zA-Z_.-]+)$')
   151     EXPR = re.compile(r'^(?P<name>[a-zA-Z0-9_.-]+)$')
   152 
   152 
   153     def __init__ (self, name) :
   153     def __init__ (self, name) :
   154         """
   154         """
   155             The given name is the literal name of this label
   155             The given name is the literal name of this label
   156         """
   156         """
   212         """
   212         """
   213             Return either the assigned value from values, our default value, or raise an error
   213             Return either the assigned value from values, our default value, or raise an error
   214         """
   214         """
   215         
   215         
   216         # just proxy to build_default
   216         # just proxy to build_default
   217         return build_default[1]
   217         return self.build_default(values)[1]
   218 
   218 
   219     def build_default (self, values) :
   219     def build_default (self, values) :
   220         """
   220         """
   221             Check if we have a value in values, and return based on that
   221             Check if we have a value in values, and return based on that
   222 
       
   223             XXX: copy-paste from build()
       
   224         """
   222         """
   225  
   223  
   226         # state
   224         # state
   227         is_default = False
   225         is_default = False
   228         
   226         
   290             return LabelValue(self, value, False)
   288             return LabelValue(self, value, False)
   291 
   289 
   292     def __str__ (self) :
   290     def __str__ (self) :
   293         return '{%s%s%s}' % (
   291         return '{%s%s%s}' % (
   294             self.key, 
   292             self.key, 
   295             (':%s' % (self.type_name, ) if self.type_name else ''),
   293             (':%s' % (self.type_name, ) if self.type_name is not None else ''),
   296             '=%s' % (self.default, ) if self.default else '',
   294             '=%s' % (self.default, ) if self.default is not None else '',
   297         )
   295         )
   298 
   296 
   299 class URLType (object) :
   297 class URLType (object) :
   300     """
   298     """
   301         Handles the type-ness of values in the URL
   299         Handles the type-ness of values in the URL