thirdparty/google_appengine/google/appengine/ext/db/__init__.py
changeset 297 35211afcd563
parent 149 f2e327a7c5de
child 686 df109be0567c
equal deleted inserted replaced
296:b02dd2a5f329 297:35211afcd563
  1936     Returns:
  1936     Returns:
  1937       'time' part of 'now' only.
  1937       'time' part of 'now' only.
  1938     """
  1938     """
  1939     return datetime.datetime.now().time()
  1939     return datetime.datetime.now().time()
  1940 
  1940 
       
  1941   def empty(self, value):
       
  1942     """Is time property empty.
       
  1943 
       
  1944     "0:0" (midnight) is not an empty value.
       
  1945 
       
  1946     Returns:
       
  1947       True if value is None, else False.
       
  1948     """
       
  1949     return value is None
       
  1950 
  1941   def get_value_for_datastore(self, model_instance):
  1951   def get_value_for_datastore(self, model_instance):
  1942     """Get value from property to send to datastore.
  1952     """Get value from property to send to datastore.
  1943 
  1953 
  1944     We retrieve a datetime.time from the model instance and return a
  1954     We retrieve a datetime.time from the model instance and return a
  1945     datetime.datetime instance with the date set to 1/1/1970.
  1955     datetime.datetime instance with the date set to 1/1/1970.
  2199       Copy of the default value.
  2209       Copy of the default value.
  2200     """
  2210     """
  2201     return list(super(ListProperty, self).default_value())
  2211     return list(super(ListProperty, self).default_value())
  2202 
  2212 
  2203 
  2213 
  2204 def StringListProperty(verbose_name=None, default=None, **kwds):
  2214 class StringListProperty(ListProperty):
  2205   """A shorthand for the most common type of ListProperty.
  2215   """A property that stores a list of strings.
  2206 
  2216 
  2207   Args:
  2217   A shorthand for the most common type of ListProperty.
  2208     verbose_name: Optional verbose name.
       
  2209     default: Optional default value; if omitted, an empty list is used.
       
  2210     **kwds: Optional additional keyword arguments, passed to ListProperty().
       
  2211 
       
  2212   Returns:
       
  2213     A ListProperty instance whose item type is basestring and whose other
       
  2214     arguments are whatever was passed here.
       
  2215   """
  2218   """
  2216   return ListProperty(basestring, verbose_name, default, **kwds)
  2219 
       
  2220   def __init__(self, verbose_name=None, default=None, **kwds):
       
  2221     """Construct StringListProperty.
       
  2222 
       
  2223     Args:
       
  2224       verbose_name: Optional verbose name.
       
  2225       default: Optional default value; if omitted, an empty list is used.
       
  2226       **kwds: Optional additional keyword arguments, passed to ListProperty().
       
  2227     """
       
  2228     super(StringListProperty, self).__init__(basestring,
       
  2229                                              verbose_name=verbose_name,
       
  2230                                              default=default,
       
  2231                                              **kwds)
  2217 
  2232 
  2218 
  2233 
  2219 class ReferenceProperty(Property):
  2234 class ReferenceProperty(Property):
  2220   """A property that represents a many-to-one reference to another model.
  2235   """A property that represents a many-to-one reference to another model.
  2221 
  2236