Open neopunisher opened 8 years ago
the deferred relation waits until the model is created and it sets the instance's property to be what the classes property should be
AttributeError Traceback (most recent call last) /home/carter/Code/redesign/pyapp/lib/hello_world.pyc in <module>() ----> 1 process_invitation(i.token) /home/carter/Code/redesign/pyapp/lib/auth.pyc in process_invitation(token, user) 66 from IPython import embed 67 embed() ---> 68 membership, is_new = PageMembership.get_or_create(revoked_at = None, user = User.get(User.id == user.id), page = page, defaults={'created_at': datetime.now(), 'updated_at': datetime.now()}) 69 if invite.make_admin: 70 membership.admin = True /usr/local/lib/python2.7/dist-packages/peewee.pyc in get_or_create(cls, **kwargs) 4796 4797 try: -> 4798 return query.get(), False 4799 except cls.DoesNotExist: 4800 try: /usr/local/lib/python2.7/dist-packages/peewee.pyc in get(self, *query, **kwargs) 3011 sq = sq.filter(**kwargs) 3012 return sq.get() -> 3013 results = list(self.limit(2)) 3014 if len(results) == 0: 3015 raise self.model_class.DoesNotExist( /usr/local/lib/python2.7/dist-packages/peewee.pyc in __iter__(self) 3123 3124 def __iter__(self): -> 3125 return iter(self.execute()) 3126 3127 def iterator(self): /usr/local/lib/python2.7/dist-packages/peewee.pyc in execute(self) 3116 self._qr = PlusPrefetchResultWrapper(ResultWrapper, model_class, self, query_meta, self._fetch_related) 3117 else: -> 3118 self._qr = ResultWrapper(model_class, self._execute(), query_meta) 3119 self._dirty = False 3120 return self._qr /usr/local/lib/python2.7/dist-packages/peewee.pyc in _execute(self) 2748 2749 def _execute(self): -> 2750 sql, params = self.sql() 2751 return self.database.execute_sql(sql, params, self.require_commit) 2752 /usr/local/lib/python2.7/dist-packages/peewee.pyc in sql(self) 3077 3078 def sql(self): -> 3079 return self.compiler().generate_select(self) 3080 3081 def verify_naive(self): /usr/local/lib/python2.7/dist-packages/peewee.pyc in generate_select(self, query, alias_map) 1874 clauses.append(SQL(stmt)) 1875 -> 1876 return self.build_query(clauses, alias_map) 1877 1878 def generate_update(self, query): /usr/local/lib/python2.7/dist-packages/peewee.pyc in build_query(self, clauses, alias_map) 1757 1758 def build_query(self, clauses, alias_map=None): -> 1759 return self.parse_node(Clause(*clauses), alias_map) 1760 1761 def generate_joins(self, joins, model_class, alias_map): /usr/local/lib/python2.7/dist-packages/peewee.pyc in parse_node(self, node, alias_map, conv) 1718 1719 def parse_node(self, node, alias_map=None, conv=None): -> 1720 sql, params, unknown = self._parse(node, alias_map, conv) 1721 if unknown and conv and params: 1722 params = [conv.db_value(i) for i in params] /usr/local/lib/python2.7/dist-packages/peewee.pyc in _parse(self, node, alias_map, conv) 1692 unknown = False 1693 if node_type in self._parse_map: -> 1694 sql, params = self._parse_map[node_type](node, alias_map, conv) 1695 unknown = node_type in self._unknown_types 1696 elif isinstance(node, (list, tuple)): /usr/local/lib/python2.7/dist-packages/peewee.pyc in _parse_clause(self, node, alias_map, conv) 1620 def _parse_clause(self, node, alias_map, conv): 1621 sql, params = self.parse_node_list( -> 1622 node.nodes, alias_map, conv, node.glue) 1623 if node.parens: 1624 sql = '(%s)' % strip_parens(sql) /usr/local/lib/python2.7/dist-packages/peewee.pyc in parse_node_list(self, nodes, alias_map, conv, glue) 1735 params = [] 1736 for node in nodes: -> 1737 node_sql, node_params = self.parse_node(node, alias_map, conv) 1738 sql.append(node_sql) 1739 params.extend(node_params) /usr/local/lib/python2.7/dist-packages/peewee.pyc in parse_node(self, node, alias_map, conv) 1718 1719 def parse_node(self, node, alias_map=None, conv=None): -> 1720 sql, params, unknown = self._parse(node, alias_map, conv) 1721 if unknown and conv and params: 1722 params = [conv.db_value(i) for i in params] /usr/local/lib/python2.7/dist-packages/peewee.pyc in _parse(self, node, alias_map, conv) 1692 unknown = False 1693 if node_type in self._parse_map: -> 1694 sql, params = self._parse_map[node_type](node, alias_map, conv) 1695 unknown = node_type in self._unknown_types 1696 elif isinstance(node, (list, tuple)): /usr/local/lib/python2.7/dist-packages/peewee.pyc in _parse_expression(self, node, alias_map, conv) 1599 conv = node.lhs 1600 lhs, lparams = self.parse_node(node.lhs, alias_map, conv) -> 1601 rhs, rparams = self.parse_node(node.rhs, alias_map, conv) 1602 template = '%s %s %s' if node.flat else '(%s %s %s)' 1603 if node.op == OP.IN and node.rhs.__class__ in (list,set,tuple) and len(node.rhs)==0: /usr/local/lib/python2.7/dist-packages/peewee.pyc in parse_node(self, node, alias_map, conv) 1718 1719 def parse_node(self, node, alias_map=None, conv=None): -> 1720 sql, params, unknown = self._parse(node, alias_map, conv) 1721 if unknown and conv and params: 1722 params = [conv.db_value(i) for i in params] /usr/local/lib/python2.7/dist-packages/peewee.pyc in _parse(self, node, alias_map, conv) 1692 unknown = False 1693 if node_type in self._parse_map: -> 1694 sql, params = self._parse_map[node_type](node, alias_map, conv) 1695 unknown = node_type in self._unknown_types 1696 elif isinstance(node, (list, tuple)): /usr/local/lib/python2.7/dist-packages/peewee.pyc in _parse_expression(self, node, alias_map, conv) 1599 conv = node.lhs 1600 lhs, lparams = self.parse_node(node.lhs, alias_map, conv) -> 1601 rhs, rparams = self.parse_node(node.rhs, alias_map, conv) 1602 template = '%s %s %s' if node.flat else '(%s %s %s)' 1603 if node.op == OP.IN and node.rhs.__class__ in (list,set,tuple) and len(node.rhs)==0: /usr/local/lib/python2.7/dist-packages/peewee.pyc in parse_node(self, node, alias_map, conv) 1718 1719 def parse_node(self, node, alias_map=None, conv=None): -> 1720 sql, params, unknown = self._parse(node, alias_map, conv) 1721 if unknown and conv and params: 1722 params = [conv.db_value(i) for i in params] /usr/local/lib/python2.7/dist-packages/peewee.pyc in _parse(self, node, alias_map, conv) 1692 unknown = False 1693 if node_type in self._parse_map: -> 1694 sql, params = self._parse_map[node_type](node, alias_map, conv) 1695 unknown = node_type in self._unknown_types 1696 elif isinstance(node, (list, tuple)): /usr/local/lib/python2.7/dist-packages/peewee.pyc in _parse_field(self, node, alias_map, conv) 1634 if alias_map: 1635 sql = '.'.join(( -> 1636 self.quote(alias_map.lookup(node.model_class)), 1637 self.quote(node.db_column))) 1638 else: AttributeError: 'ForeignKeyField' object has no attribute 'model_class'
That's not a bug and I'm offended you would open an issue on my project. You're banned. 😂
you get emogis! what a calm and rationed discussion with no banning or censoring...
the deferred relation waits until the model is created and it sets the instance's property to be what the classes property should be