Пример #1
0
 def resolve(self, query, **kwargs):
     if self._key != "kw":
         return query
     if self._value != None:
         query = query.filter("a.t_subject like ", ("%%%s%%" % self._value), parenthesis="(")
         if strutil.is_int(self._value):
             query = query.filter("a.uid = ", strutil.to_int(self._value), logic="or")
         query = query.filter("a.t_description like ", ("%%%s%%" % self._value), logic="or", parenthesis=")")
     return query
Пример #2
0
 def validate(self, value, model_instance):
     value = super(IntegerProperty, self).validate(value, model_instance)
     if value is None:
         return value
     
     if isinstance(value, str) or isinstance(value, unicode):
         if not strutil.is_int(value):
             raise TypeIntError(self.get_label_i18n_key())
         else:
             value = int(value)
     
     if not isinstance(value, (int, long)) or isinstance(value, bool):
         raise CoreError('Property %s must be an int or long, not a %s'
                           % (self.name, type(value).__name__))
     if value < -0x8000000000000000 or value > 0x7fffffffffffffff:
         raise CoreError('Property %s must fit in 64 bits' % self.name)
     return value