本文整理汇总了Python中sqlalchemy.ext.orderinglist.ordering_list函数的典型用法代码示例。如果您正苦于以下问题:Python ordering_list函数的具体用法?Python ordering_list怎么用?Python ordering_list使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ordering_list函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_funky_ordering
def test_funky_ordering(self):
class Pos(object):
def __init__(self):
self.position = None
step_factory = ordering_list(
"position", ordering_func=step_numbering(2)
)
stepped = step_factory()
stepped.append(Pos())
stepped.append(Pos())
stepped.append(Pos())
stepped.append(Pos())
for li, pos in (0, 0), (1, 2), (2, 4), (3, 6):
self.assert_(stepped[li].position == pos)
fib_factory = ordering_list(
"position", ordering_func=fibonacci_numbering("position")
)
fibbed = fib_factory()
fibbed.append(Pos())
fibbed.append(Pos())
fibbed.append(Pos())
fibbed.append(Pos())
fibbed.append(Pos())
for li, pos in (0, 1), (1, 2), (2, 3), (3, 5), (4, 8):
self.assert_(fibbed[li].position == pos)
fibbed.insert(2, Pos())
fibbed.insert(4, Pos())
fibbed.insert(6, Pos())
for li, pos in (
(0, 1),
(1, 2),
(2, 3),
(3, 5),
(4, 8),
(5, 13),
(6, 21),
(7, 34),
):
self.assert_(fibbed[li].position == pos)
alpha_factory = ordering_list("position", ordering_func=alpha_ordering)
alpha = alpha_factory()
alpha.append(Pos())
alpha.append(Pos())
alpha.append(Pos())
alpha.insert(1, Pos())
for li, pos in (0, "A"), (1, "B"), (2, "C"), (3, "D"):
self.assert_(alpha[li].position == pos)
开发者ID:BY-jk,项目名称:sqlalchemy,代码行数:58,代码来源:test_orderinglist.py
示例2: Doc
def Doc(models):
if models.lang == 'ru':
id = Column(Integer, primary_key=True)
else:
id = Column(Integer, ForeignKey(models.DocRu.id),
primary_key=True, autoincrement=False)
date = Column(DateTime, nullable=False, default=datetime.now, index=True)
title = Column(Html(String(1000)), nullable=False, default='')
summary = Column(Html(Text), nullable=False, default='')
body = deferred(Column(ExpandableHtml(MediumText), nullable=False,
default=ExpandableMarkup('')))
_photos, photos_edit, photos = editable_ordered_relation(
models.Doc_Photo, 'photo', use_property=False)
_photo_sets, photo_sets_edit, photo_sets = editable_ordered_relation(
models.Doc_PhotoSet, 'photo_set', use_property=False)
link_blocks_edit = relationship(
models.DocLinkBlock,
order_by=[models.DocLinkBlock.order_position],
collection_class=ordering_list('order_position'),
cascade='all, delete-orphan')
# do not display blocks without links
link_blocks = FilteredProperty('link_blocks_edit', has_links=True)
sections = relationship(
models.Section,
secondary=models.Doc_Section.__table__)
__mapper_args__ = {'order_by': desc(date)}
def __unicode__(self):
if self.id is None:
return u'Новый материал'
return u'Материал: {}'.format(self.title)
@cached_property
def index_photo(self):
if self.photos:
return self.photos[0]
elif self.photo_sets:
return self.photo_sets[0].index_photo
else:
return None
@cached_property
def all_photos(self):
photos = sum([x.photos for x in self.photo_sets], []) + self.photos
return list(collections.OrderedDict.fromkeys(photos))
@cached_property
def links_count(self):
return sum([len(x.links) for x in self.link_blocks])
@cached_property
def date_formatted(self):
return format_datetime(self.date, locale=self.models.lang)
开发者ID:SmartTeleMax,项目名称:iktomi-cms-demo,代码行数:60,代码来源:docs.py
示例3: test_replace
def test_replace(self):
self._setup(ordering_list("position"))
s1 = Slide("Slide #1")
s1.bullets = [Bullet("1"), Bullet("2"), Bullet("3")]
self.assert_(len(s1.bullets) == 3)
self.assert_(s1.bullets[2].position == 2)
session = create_session()
session.add(s1)
session.flush()
new_bullet = Bullet("new 2")
self.assert_(new_bullet.position is None)
# mark existing bullet as db-deleted before replacement.
# session.delete(s1.bullets[1])
s1.bullets[1] = new_bullet
self.assert_(new_bullet.position == 1)
self.assert_(len(s1.bullets) == 3)
id_ = s1.id
session.flush()
session.expunge_all()
srt = session.query(Slide).get(id_)
self.assert_(srt.bullets)
self.assert_(len(srt.bullets) == 3)
self.assert_(srt.bullets[1].text == "new 2")
self.assert_(srt.bullets[2].text == "3")
开发者ID:BY-jk,项目名称:sqlalchemy,代码行数:35,代码来源:test_orderinglist.py
示例4: test_append_no_reorder
def test_append_no_reorder(self):
self._setup(
ordering_list("position", count_from=1, reorder_on_append=False)
)
s1 = Slide("Slide #1")
self.assert_(not s1.bullets)
self.assert_(len(s1.bullets) == 0)
s1.bullets.append(Bullet("s1/b1"))
self.assert_(s1.bullets)
self.assert_(len(s1.bullets) == 1)
self.assert_(s1.bullets[0].position == 1)
s1.bullets.append(Bullet("s1/b2"))
self.assert_(len(s1.bullets) == 2)
self.assert_(s1.bullets[0].position == 1)
self.assert_(s1.bullets[1].position == 2)
bul = Bullet("s1/b100")
bul.position = 100
s1.bullets.append(bul)
self.assert_(s1.bullets[0].position == 1)
self.assert_(s1.bullets[1].position == 2)
self.assert_(s1.bullets[2].position == 100)
s1.bullets.append(Bullet("s1/b4"))
self.assert_(s1.bullets[0].position == 1)
self.assert_(s1.bullets[1].position == 2)
self.assert_(s1.bullets[2].position == 100)
self.assert_(s1.bullets[3].position == 4)
s1.bullets._reorder()
self.assert_(s1.bullets[0].position == 1)
self.assert_(s1.bullets[1].position == 2)
self.assert_(s1.bullets[2].position == 3)
self.assert_(s1.bullets[3].position == 4)
session = create_session()
session.add(s1)
session.flush()
id_ = s1.id
session.expunge_all()
del s1
srt = session.query(Slide).get(id_)
self.assert_(srt.bullets)
self.assert_(len(srt.bullets) == 4)
titles = ["s1/b1", "s1/b2", "s1/b100", "s1/b4"]
found = [b.text for b in srt.bullets]
self.assert_(titles == found)
开发者ID:BY-jk,项目名称:sqlalchemy,代码行数:59,代码来源:test_orderinglist.py
示例5: test_replace_two
def test_replace_two(self):
"""test #3191"""
self._setup(ordering_list("position", reorder_on_append=True))
s1 = Slide("Slide #1")
b1, b2, b3, b4 = Bullet("1"), Bullet("2"), Bullet("3"), Bullet("4")
s1.bullets = [b1, b2, b3]
eq_([b.position for b in s1.bullets], [0, 1, 2])
s1.bullets = [b4, b2, b1]
eq_([b.position for b in s1.bullets], [0, 1, 2])
开发者ID:BY-jk,项目名称:sqlalchemy,代码行数:14,代码来源:test_orderinglist.py
示例6: get_dict
def get_dict(self, models, factory=None):
remote_cls_name = self.get_remote_cls_name(factory)
remote_cls = getattr(models, remote_cls_name)
kwargs = {}
if self.ordered:
kwargs['collection_class'] = ordering_list('order')
kwargs['order_by'] = [remote_cls.order]
if self.cascade:
kwargs['cascade'] = self.cascade
if self.remote_foreign_key:
kwargs['foreign_keys'] = self.get_foreign_keys(models, factory)
field = relation(remote_cls, **kwargs)
return {
self.name: field,
}
开发者ID:SlivTime,项目名称:cms34,代码行数:15,代码来源:fields.py
示例7: test_slice
def test_slice(self):
self._setup(ordering_list("position"))
b = [
Bullet("1"),
Bullet("2"),
Bullet("3"),
Bullet("4"),
Bullet("5"),
Bullet("6"),
]
s1 = Slide("Slide #1")
# 1, 2, 3
s1.bullets[0:3] = b[0:3]
for i in 0, 1, 2:
self.assert_(s1.bullets[i].position == i)
self.assert_(s1.bullets[i] == b[i])
# 1, 4, 5, 6, 3
s1.bullets[1:2] = b[3:6]
for li, bi in (0, 0), (1, 3), (2, 4), (3, 5), (4, 2):
self.assert_(s1.bullets[li].position == li)
self.assert_(s1.bullets[li] == b[bi])
# 1, 6, 3
del s1.bullets[1:3]
for li, bi in (0, 0), (1, 5), (2, 2):
self.assert_(s1.bullets[li].position == li)
self.assert_(s1.bullets[li] == b[bi])
session = create_session()
session.add(s1)
session.flush()
id_ = s1.id
session.expunge_all()
del s1
srt = session.query(Slide).get(id_)
self.assert_(srt.bullets)
self.assert_(len(srt.bullets) == 3)
texts = ["1", "6", "3"]
for i, text in enumerate(texts):
self.assert_(srt.bullets[i].position == i)
self.assert_(srt.bullets[i].text == text)
开发者ID:BY-jk,项目名称:sqlalchemy,代码行数:48,代码来源:test_orderinglist.py
示例8: test_insert
def test_insert(self):
self._setup(ordering_list('position'))
s1 = Slide('Slide #1')
s1.bullets.append(Bullet('1'))
s1.bullets.append(Bullet('2'))
s1.bullets.append(Bullet('3'))
s1.bullets.append(Bullet('4'))
self.assert_(s1.bullets[0].position == 0)
self.assert_(s1.bullets[1].position == 1)
self.assert_(s1.bullets[2].position == 2)
self.assert_(s1.bullets[3].position == 3)
s1.bullets.insert(2, Bullet('insert_at_2'))
self.assert_(s1.bullets[0].position == 0)
self.assert_(s1.bullets[1].position == 1)
self.assert_(s1.bullets[2].position == 2)
self.assert_(s1.bullets[3].position == 3)
self.assert_(s1.bullets[4].position == 4)
self.assert_(s1.bullets[1].text == '2')
self.assert_(s1.bullets[2].text == 'insert_at_2')
self.assert_(s1.bullets[3].text == '3')
s1.bullets.insert(999, Bullet('999'))
self.assert_(len(s1.bullets) == 6)
self.assert_(s1.bullets[5].position == 5)
session = create_session()
session.add(s1)
session.flush()
id = s1.id
session.expunge_all()
del s1
srt = session.query(Slide).get(id)
self.assert_(srt.bullets)
self.assert_(len(srt.bullets) == 6)
texts = ['1','2','insert_at_2','3','4','999']
found = [b.text for b in srt.bullets]
self.assert_(texts == found)
开发者ID:Attsun1031,项目名称:sqlalchemy,代码行数:47,代码来源:test_orderinglist.py
示例9: test_insert
def test_insert(self):
self._setup(ordering_list("position"))
s1 = Slide("Slide #1")
s1.bullets.append(Bullet("1"))
s1.bullets.append(Bullet("2"))
s1.bullets.append(Bullet("3"))
s1.bullets.append(Bullet("4"))
self.assert_(s1.bullets[0].position == 0)
self.assert_(s1.bullets[1].position == 1)
self.assert_(s1.bullets[2].position == 2)
self.assert_(s1.bullets[3].position == 3)
s1.bullets.insert(2, Bullet("insert_at_2"))
self.assert_(s1.bullets[0].position == 0)
self.assert_(s1.bullets[1].position == 1)
self.assert_(s1.bullets[2].position == 2)
self.assert_(s1.bullets[3].position == 3)
self.assert_(s1.bullets[4].position == 4)
self.assert_(s1.bullets[1].text == "2")
self.assert_(s1.bullets[2].text == "insert_at_2")
self.assert_(s1.bullets[3].text == "3")
s1.bullets.insert(999, Bullet("999"))
self.assert_(len(s1.bullets) == 6)
self.assert_(s1.bullets[5].position == 5)
session = create_session()
session.add(s1)
session.flush()
id_ = s1.id
session.expunge_all()
del s1
srt = session.query(Slide).get(id_)
self.assert_(srt.bullets)
self.assert_(len(srt.bullets) == 6)
texts = ["1", "2", "insert_at_2", "3", "4", "999"]
found = [b.text for b in srt.bullets]
self.assert_(texts == found)
开发者ID:BY-jk,项目名称:sqlalchemy,代码行数:47,代码来源:test_orderinglist.py
示例10: create_collection_class
def create_collection_class(owner, member, column, *,
sorted=True, duplicates=True):
"""
Creates a class for holding the values of a collection in given *owner*
class.
The given *owner* class will be updated to have a new *member* with given
name, which is a list containing elements as described by *column*:
>>> create_collection_class(Group, 'permissions',
... Column(PermissionEnum.db_type(), nullable=False)
Group objects will now have a member called 'permissions', which contain a
sorted list of PermissionEnum values.
See :func:`.create_relationship_class` for the description of the keyword
arguments.
"""
name = owner.__name__ + tbl2cls(member)
if sorted:
bref = backref(member + '_wrapper', order_by='%s.index' % name,
collection_class=ordering_list('index'))
else:
bref = backref(member + '_wrapper')
members = {
'__score_db__': {
'inheritance': None
},
'owner_id': Column(IdType, ForeignKey('%s.id' % owner.__tablename__),
nullable=False),
'owner': relationship(owner, backref=bref),
'value': column,
}
if sorted:
members['index'] = Column(Integer, nullable=False)
if not duplicates:
members['__table_args__'] = (
UniqueConstraint(members['owner_id'], column),
)
cls = type(name, (owner.__score_db__['base'],), members)
proxy = association_proxy(member + '_wrapper', 'value',
creator=lambda v: cls(value=v))
setattr(owner, member, proxy)
return cls
开发者ID:tronstoner,项目名称:py.db,代码行数:44,代码来源:helpers.py
示例11: test_slice
def test_slice(self):
self._setup(ordering_list('position'))
b = [ Bullet('1'), Bullet('2'), Bullet('3'),
Bullet('4'), Bullet('5'), Bullet('6') ]
s1 = Slide('Slide #1')
# 1, 2, 3
s1.bullets[0:3] = b[0:3]
for i in 0, 1, 2:
self.assert_(s1.bullets[i].position == i)
self.assert_(s1.bullets[i] == b[i])
# 1, 4, 5, 6, 3
s1.bullets[1:2] = b[3:6]
for li, bi in (0,0), (1,3), (2,4), (3,5), (4,2):
self.assert_(s1.bullets[li].position == li)
self.assert_(s1.bullets[li] == b[bi])
# 1, 6, 3
del s1.bullets[1:3]
for li, bi in (0,0), (1,5), (2,2):
self.assert_(s1.bullets[li].position == li)
self.assert_(s1.bullets[li] == b[bi])
session = create_session()
session.add(s1)
session.flush()
id = s1.id
session.expunge_all()
del s1
srt = session.query(Slide).get(id)
self.assert_(srt.bullets)
self.assert_(len(srt.bullets) == 3)
texts = ['1', '6', '3']
for i, text in enumerate(texts):
self.assert_(srt.bullets[i].position == i)
self.assert_(srt.bullets[i].text == text)
开发者ID:Attsun1031,项目名称:sqlalchemy,代码行数:42,代码来源:test_orderinglist.py
示例12: test_replace_two
def test_replace_two(self):
"""test #3191"""
self._setup(ordering_list('position', reorder_on_append=True))
s1 = Slide('Slide #1')
b1, b2, b3, b4 = Bullet('1'), Bullet('2'), Bullet('3'), Bullet('4')
s1.bullets = [b1, b2, b3]
eq_(
[b.position for b in s1.bullets],
[0, 1, 2]
)
s1.bullets = [b4, b2, b1]
eq_(
[b.position for b in s1.bullets],
[0, 1, 2]
)
开发者ID:Attsun1031,项目名称:sqlalchemy,代码行数:20,代码来源:test_orderinglist.py
示例13: DocLinkBlock
def DocLinkBlock(models):
id = Column(Integer, primary_key=True)
title = Column(String(250), nullable=False, default='')
doc_id = Column(Integer, ForeignKey(models.Doc.id, ondelete='CASCADE'),
nullable=False)
doc = relationship(models.Doc)
links_edit = relationship(models.DocLink,
collection_class=ordering_list('order_position'),
order_by=[models.DocLink.order_position],
cascade='all, delete-orphan')
# do not display links which can not be transformed to urls,
# for example links to unpublished documents
links = FilteredProperty('links_edit', has_url=True)
order_position = Column(Integer, nullable=False, default=0)
@property
def has_links(self):
return bool(self.links)
def __unicode__(self):
return u"Блок ссылок: {}".format(self.title)
开发者ID:SmartTeleMax,项目名称:iktomi-cms-demo,代码行数:22,代码来源:docs.py
示例14: InitMapper
def InitMapper( cls, metadata, Board ):
cls.__table__ = Table( cls.__tablename__, metadata,
Column('id', Integer, index = True, primary_key = True ),
Column('board_id', ForeignKey( Board.id ), index = True, nullable = False ),
Column('slot', Integer, index = True, nullable = False ),
Column('subject', String(255), nullable = False ),
Column('body', Text, nullable = False ),
Column('turn', Integer, nullable = False ),
Column('mtime', DateTime, nullable = False,
onupdate = func.current_timestamp(), default = func.current_timestamp()))
cols = cls.__table__.c
Index('ix_%s_id_board' % cls.__tablename__, cols.id, cols.board_id)
mapper( cls, cls.__table__, properties = {
'board': relation( Board,
uselist = False,
backref = backref( 'messages',
collection_class = ordering_list('slot', count_from = 1),
order_by = [ cols.slot ] ))
})
开发者ID:cahirwpz,项目名称:tpserver-py,代码行数:22,代码来源:Message.py
示例15: InitMapper
def InitMapper( cls, metadata, OrderType, Object, Player ):
cls.__table__ = Table( cls.__tablename__, metadata,
Column('id', Integer, index = True, primary_key = True),
Column('slot', Integer, nullable = False),
Column('type_id', ForeignKey( OrderType.id ), nullable = False),
Column('object_id', ForeignKey( Object.id ), nullable = True),
Column('owner_id', ForeignKey( Player.id ), index = True, nullable = True),
Column('eta', Integer, nullable = False, default = 0),
Column('mtime', DateTime, nullable = False,
onupdate = func.current_timestamp(), default = func.current_timestamp()))
cols = cls.__table__.c
mapper( cls, cls.__table__, polymorphic_on = cols.type_id, properties = {
'type': relation( OrderType,
uselist = False ),
'object': relation( Object,
uselist = False,
backref = backref( 'orders',
collection_class = ordering_list('slot', count_from = 1),
order_by = [ cols.slot ] )),
'owner': relation( Player,
uselist = False )
})
开发者ID:cahirwpz,项目名称:tpserver-py,代码行数:24,代码来源:Order.py
示例16: Column
primary_key=True)
position = Column(Integer, nullable=False)
creation_date = deferred(Column(DateTime, default=datetime.now,
nullable=False))
comments = deferred(Column(String(255), nullable=True))
service_instance = relation(ServiceInstance)
system = relation(System, uselist=False, backref='sislist')
def __str__(self):
return str(self.system.fqdn)
def __repr__(self):
return self.__class__.__name__ + " " + str(self.system.fqdn)
service_instance_server = ServiceInstanceServer.__table__
service_instance_server.primary_key.name='service_instance_server_pk'
table = service_instance_server
#TODO: would we like this mapped in service_instance.py instead?
ServiceInstance.servers = relation(ServiceInstanceServer,
collection_class=ordering_list('position'),
order_by=[ServiceInstanceServer.__table__.c.position])
开发者ID:jrha,项目名称:aquilon,代码行数:27,代码来源:service_instance_server.py
示例17:
return cls.extra_columns
## Mappers
meta.mapper(
Resource,
resource_table,
properties={
"resource_group": orm.relation(
ResourceGroup,
# all resources including deleted
# formally package_resources_all
backref=orm.backref(
"resources_all",
collection_class=ordering_list("position"),
cascade="all, delete",
order_by=resource_table.c.position,
),
)
},
order_by=[resource_table.c.resource_group_id],
extension=[vdm.sqlalchemy.Revisioner(resource_revision_table), extension.PluginMapperExtension()],
)
meta.mapper(
ResourceGroup,
resource_group_table,
properties={
"package": orm.relation(
开发者ID:netconstructor,项目名称:ckan,代码行数:31,代码来源:resource.py
示例18: test_append_reorder
def test_append_reorder(self):
self._setup(ordering_list('position', count_from=1,
reorder_on_append=True))
s1 = Slide('Slide #1')
self.assert_(not s1.bullets)
self.assert_(len(s1.bullets) == 0)
s1.bullets.append(Bullet('s1/b1'))
self.assert_(s1.bullets)
self.assert_(len(s1.bullets) == 1)
self.assert_(s1.bullets[0].position == 1)
s1.bullets.append(Bullet('s1/b2'))
self.assert_(len(s1.bullets) == 2)
self.assert_(s1.bullets[0].position == 1)
self.assert_(s1.bullets[1].position == 2)
bul = Bullet('s1/b100')
bul.position = 100
s1.bullets.append(bul)
self.assert_(s1.bullets[0].position == 1)
self.assert_(s1.bullets[1].position == 2)
self.assert_(s1.bullets[2].position == 3)
s1.bullets.append(Bullet('s1/b4'))
self.assert_(s1.bullets[0].position == 1)
self.assert_(s1.bullets[1].position == 2)
self.assert_(s1.bullets[2].position == 3)
self.assert_(s1.bullets[3].position == 4)
s1.bullets._reorder()
self.assert_(s1.bullets[0].position == 1)
self.assert_(s1.bullets[1].position == 2)
self.assert_(s1.bullets[2].position == 3)
self.assert_(s1.bullets[3].position == 4)
s1.bullets._raw_append(Bullet('raw'))
self.assert_(s1.bullets[4].position is None)
s1.bullets._reorder()
self.assert_(s1.bullets[4].position == 5)
session = create_session()
session.add(s1)
session.flush()
id = s1.id
session.expunge_all()
del s1
srt = session.query(Slide).get(id)
self.assert_(srt.bullets)
self.assert_(len(srt.bullets) == 5)
titles = ['s1/b1','s1/b2','s1/b100','s1/b4', 'raw']
found = [b.text for b in srt.bullets]
eq_(titles, found)
srt.bullets._raw_append(Bullet('raw2'))
srt.bullets[-1].position = 6
session.flush()
session.expunge_all()
srt = session.query(Slide).get(id)
titles = ['s1/b1','s1/b2','s1/b100','s1/b4', 'raw', 'raw2']
found = [b.text for b in srt.bullets]
eq_(titles, found)
开发者ID:Attsun1031,项目名称:sqlalchemy,代码行数:72,代码来源:test_orderinglist.py
示例19: association_proxy
primaryjoin=ArtworkArtifact.artifact_id == Artifact.id,
backref='artwork_artifacts')
ArtworkArtifact.artwork = association_proxy('artwork_version', 'artwork')
ArtworkAuthor.author = relationship(User,
primaryjoin=ArtworkAuthor.author_id == User.id,
backref='artwork_authors')
ArtworkAuthor.description = relationship(Post,
primaryjoin=ArtworkAuthor.description_id == Post.id)
ArtworkAuthor.artwork = relationship(Artwork,
primaryjoin=ArtworkAuthor.artwork_id == Artwork.id,
backref=backref(
'artwork_authors',
cascade="all, delete-orphan",
order_by=ArtworkAuthor.order,
collection_class=ordering_list('order', reorder_on_append=True)))
Post.poster = relationship(User,
primaryjoin=Post.poster_id == User.id)
Post.active_text = relationship(PostText,
primaryjoin=Post.active_text_id == PostText.id)
PostText.post = relationship(Post,
primaryjoin=PostText.post_id == Post.id,
backref=backref(
"texts",
order_by=PostText.posted_at))
PostText.poster = relationship(User,
primaryjoin=PostText.poster_id == User.id)
ArtworkComment.artwork = relationship(Artwork,
开发者ID:encukou,项目名称:fanart,代码行数:31,代码来源:tables.py
示例20: object_session
"Add a field model."
self.fieldModels.append(field)
s = object_session(self)
if s:
s.flush()
def addCardModel(self, card):
"Add a card model."
self.cardModels.append(card)
s = object_session(self)
if s:
s.flush()
mapper(Model, modelsTable, properties={
'fieldModels': relation(FieldModel, backref='model',
collection_class=ordering_list('ordinal'),
order_by=[fieldModelsTable.c.ordinal],
cascade="all, delete-orphan"),
'cardModels': relation(CardModel, backref='model',
collection_class=ordering_list('ordinal'),
order_by=[cardModelsTable.c.ordinal],
cascade="all, delete-orphan"),
})
# Model deletions
##########################################################################
modelsDeletedTable = Table(
'modelsDeleted', metadata,
Column('modelId', Integer, ForeignKey("models.id"),
nullable=False),
开发者ID:sanna,项目名称:libanki,代码行数:31,代码来源:models.py
注:本文中的sqlalchemy.ext.orderinglist.ordering_list函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论