Camelot에 대한 문서는 Elixir 모델을 사용한다고 말합니다. SQLAlchemy가 잠시 동안 declarative_base를 포함 시켰기 때문에 나는 다른 프로그램을 위해 Elixir 대신에 이것을 사용했다. 이제 SQLAlchemy/선언적 모델을 Camelot에서 직접 사용하고 싶습니다.파이썬 카멜롯이 엘릭서와 관련이 있습니까?
카멜롯은 말한다 유래에 post 있습니다 하지 비약에 연결하고 가능할 것이다 다른 모델을 사용하지만 어떻게 말을하지 않습니다.
카멜롯의 원래 model.py
에만이 내용이 있습니다
import camelot.types
from camelot.model import metadata, Entity, Field, ManyToOne, OneToMany, Unicode, Date, Integer, using_options
from camelot.view.elixir_admin import EntityAdmin
from camelot.view.forms import *
__metadata__ = metadata
내가 내 SQLAlchemy의 모델을 추가하고이에
model.py
을 변경 : 그것은 작동하지 않았다
import camelot.types
from camelot.model import metadata, Entity, Field, ManyToOne, OneToMany, Unicode, Date, using_options
from camelot.view.elixir_admin import EntityAdmin
from camelot.view.forms import *
from sqlalchemy import Column, Integer, String
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
__metadata__ = metadata
Base = declarative_base()
class Test(Base):
__tablename__ = "test"
id = Column(Integer, primary_key=True)
text = Column(String)
합니다. main.py
을 시작하면 사이드 바에 GUI와 Test
이 표시되지만 행이 표시되지 않습니다.
File "/usr/lib/python2.6/dist-packages/camelot/view/elixir_admin.py", line 52, in get_query
return self.entity.query
AttributeError: type object 'Test' has no attribute 'query'
이 라인 46-52의 elixir_admin.py
코드입니다 : 이것은 역 추적의 꼬리
@model_function
def get_query(self):
""":return: an sqlalchemy query for all the objects that should be
displayed in the table or the selection view. Overwrite this method to
change the default query, which selects all rows in the database.
"""
return self.entity.query
이 코드는 문제를 일으키는 경우는, 내가 어떻게를 변경하는 방법을 덮어 않는다 작동하게 기본 쿼리?
어떻게 Camelot에서 SQLAlchemy/선언적 모델을 사용할 수 있습니까?
문제를 만드는 코드를 알려주십시오. – Nilesh
코드가 위에 있습니다. 차이점을 볼 수 있도록 원래 'model.py' 코드를 추가했습니다. – boadescriptor
네,하지만 당신의 코드가'Test'의'query' 속성에 접근하려고하는 문장을 찾지 못했습니다. 추적을 게시하십시오. – Nilesh