def _by_name_cache(cls, name): q = cls._query(lower(cls.c.name) == name.lower(), cls.c._spam == (True, False), limit = 1) l = list(q) if l: return l[0]._id
def _by_name_cache(cls, name): q = cls._query(lower(cls.c.name) == name.lower(), cls.c._spam == (True, False), limit=1) l = list(q) if l: return l[0]._id
def _fetch(lnames): q = cls._query(lower(cls.c.name) == lnames, cls.c._spam == (True, False), limit=len(lnames), data=True) try: srs = list(q) except UnicodeEncodeError: print "Error looking up SRs %r" % (lnames,) raise return dict((sr.name.lower(), sr._id) for sr in srs)
def _by_codename(cls, codename): q = cls._query(lower(Award.c.codename) == codename.lower()) q._limit = 1 award = list(q) if award: return cls._byID(award[0]._id, True) else: raise NotFound, 'Award %s' % codename
def _by_codename(cls, codename): q = cls._query(lower(Ad.c.codename) == codename.lower()) q._limit = 1 ad = list(q) if ad: return cls._byID(ad[0]._id, True) else: raise NotFound, "Ad %s" % codename
def _by_name_cache(cls, name): q = cls._query(lower(cls.c.name) == name.lower(), cls.c._spam == (True, False), limit=1) try: l = list(q) except UnicodeEncodeError: print "Error looking up SR %r" % name raise if l: return l[0]._id
def _by_email_cache(cls, email, allow_deleted = False): deleted = (True, False) if allow_deleted else False q = cls._query(lower(Account.c.email) == email, Account.c._spam == (True, False), Account.c._deleted == deleted) q._limit = 1 l = list(q) if l: return l[0]._id
def _by_name_cache(cls, name, allow_deleted = False): deleted = (True, False) if allow_deleted else False q = cls._query(lower(Account.c.name) == name, Account.c._spam == (True, False), Account.c._deleted == deleted) q._limit = 1 l = list(q) if l: return l[0]._id
def _by_name_cache(cls, name, allow_deleted=False): #relower name here, just in case deleted = (True, False) if allow_deleted else False q = cls._query( lower(Account.c.name) == name.lower(), Account.c._spam == (True, False), Account.c._deleted == deleted) q._limit = 1 l = list(q) if l: return l[0]._id
def _by_name_cache(cls, name): q = cls._query(lower(cls.c.name) == name.lower(), cls.c._spam == (True, False), limit = 1) try: l = list(q) except UnicodeEncodeError: print "Error looking up SR %r" % name raise if l: return l[0]._id
def _by_name_cache(cls, name, allow_deleted=False): # relower name here, just in case deleted = (True, False) if allow_deleted else False q = cls._query( lower(cls.c.name) == name.lower(), cls.c._spam == (True, False), cls.c._deleted == deleted, data=True ) q._limit = 1 l = list(q) if l: return l[0]._id
def _fetch(lnames): q = cls._query(lower(cls.c.name) == lnames, cls.c._spam == (True, False), limit=len(lnames), data=True) try: srs = list(q) except UnicodeEncodeError: print "Error looking up SRs %r" % (lnames, ) raise return dict((sr.name.lower(), sr._id) for sr in srs)
def _by_name_multiple(cls, name): q = cls._query(lower(Account.c.name) == name.lower(), Account.c._spam == (True, False), Account.c._deleted == (True, False)) return list(q)
def _by_name_multiple(cls, name): q = cls._query( lower(Account.c.name) == name.lower(), Account.c._spam == (True, False), Account.c._deleted == (True, False)) return list(q)
def _by_url_cache(cls, url, sr): q = cls._query(base_url(lower(cls.c.url)) == utils.base_url(url.lower())) if sr: q._filter(cls.c.sr_id == sr._id) q = list(q) return [l._id for l in q]