def get_prep_lookup(self, lookup_type, value):
        "Perform preliminary non-db specific lookup checks and conversions"
        if hasattr(value, 'prepare'):
            return value.prepare()
        if hasattr(value, '_prepare'):
            return value._prepare()

        if lookup_type in (
                'regex', 'iregex', 'month', 'day', 'week_day', 'search',
                'contains', 'icontains', 'iexact', 'startswith', 'istartswith',
                'endswith', 'iendswith', 'isnull'
            ):
            return value
        elif lookup_type in ('exact', 'gt', 'gte', 'lt', 'lte'):
            return self.get_prep_value(value)
        elif lookup_type in ('range', 'in'):
            return [self.get_prep_value(v) for v in value]
        elif lookup_type == 'year':
            try:
                return int(value)
            except __HOLE__:
                raise ValueError("The __year lookup type requires an integer argument")

        raise TypeError("Field has invalid lookup: %s" % lookup_type)
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-1.2/django/db/models/fields/__init__.py/Field.get_prep_lookup