def where(cls, **kwargs): email = kwargs.get('email') login = kwargs.get('login') if email and login: raise ValueError( 'Queries are supported on at most ONE of email and login' ) # This is a workaround for # https://github.com/zooniverse/Panoptes/issues/2733 kwargs['page_size'] = BATCH_SIZE if email: if not isiterable(email): email = [email] for batch in split(email, BATCH_SIZE): kwargs['email'] = ",".join(batch) for user in super(User, cls).where(**kwargs): yield user elif login: if not isiterable(login): login = [login] for batch in split(login, BATCH_SIZE): kwargs['login'] = "******".join(batch) for user in super(User, cls).where(**kwargs): yield user else: for user in super(User, cls).where(**kwargs): yield user
def where(cls, **kwargs): email = kwargs.get('email') login = kwargs.get('login') if email and login: raise ValueError( 'Queries are supported on at most ONE of email and login') # This is a workaround for # https://github.com/zooniverse/Panoptes/issues/2733 kwargs['page_size'] = BATCH_SIZE if email: if not isiterable(email): email = [email] for batch in split(email, BATCH_SIZE): kwargs['email'] = ",".join(batch) for user in super(User, cls).where(**kwargs): yield user elif login: if not isiterable(login): login = [login] for batch in split(login, BATCH_SIZE): kwargs['login'] = "******".join(batch) for user in super(User, cls).where(**kwargs): yield user else: for user in super(User, cls).where(**kwargs): yield user
def _savable_dict(self, edit_attributes): out = [] for key, value in self.parent.raw['links'].items(): if not key in edit_attributes: continue if isiterable(value): out.append((key, [getattr(o, 'id', o) for o in value])) else: if value: out.append((key, value)) return dict(out)