def give(self, amount, taker, **kwargs): amount = int(amount) if not amount: raise Move.Zero("Can't give 0") elif amount < 0: raise Move.Negative("Can't give negative") with NestingTransaction(): if refs.equals(taker, self.obj): raise Move.Self("Can't give to self") have = self.have if have < amount: raise Move.NeedMore("{} is not enough to give {}".format(have, amount)) return self.create(taker=taker, amount=amount, **kwargs)
def feeds_user(self, user): print 'feeds user %s == %s -> %s' % (self, user, refs.equals(self.user, user)) return refs.equals(self.user, user)