亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? byroot_tree.py

?? SQLAlchemy. 經典的Python ORM框架。學習必看。
?? PY
字號:
"""A more advanced example of basic_tree.py.Treenodes can now reference their "root" node, and introduces a newselection method which selects an entire tree of nodes at once, takingadvantage of a custom MapperExtension to assemble incoming nodes into theircorrect structure."""from sqlalchemy import MetaData, Table, Column, Sequence, ForeignKeyfrom sqlalchemy import Integer, Stringfrom sqlalchemy.orm import create_session, mapper, relation, backreffrom sqlalchemy.orm import MapperExtensionfrom sqlalchemy.orm.collections import attribute_mapped_collectionmetadata = MetaData('sqlite:///')metadata.bind.echo = True# Create the `treenodes` table, a basic adjacency list model table.# One additional column, "root_id", references a "root node" row and is used# in the 'byroot_tree' example.trees = Table('treenodes', metadata,    Column('id', Integer, Sequence('treenode_id_seq', optional=True),           primary_key=True),    Column('parent_id', Integer, ForeignKey('treenodes.id'), nullable=True),    Column('root_id', Integer, ForeignKey('treenodes.id'), nullable=True),    Column('name', String(50), nullable=False),    Column('data_id', Integer, ForeignKey('treedata.data_id')))treedata = Table(    "treedata", metadata,    Column('data_id', Integer, primary_key=True),    Column('value', String(100), nullable=False))class TreeNode(object):    """A hierarchical Tree class,    Adds the concept of a "root node".  The root is the topmost node in a    tree, or in other words a node whose parent ID is NULL.  All child nodes    that are decendents of a particular root, as well as a root node itself,    reference this root node.    """    def __init__(self, name):        self.name = name        self.root = self    def _set_root(self, root):        self.root = root        for c in self.children.values():            c._set_root(root)    def append(self, node):        if isinstance(node, basestring):            node = TreeNode(node)        node._set_root(self.root)        self.children.set(node)    def __repr__(self):        return self._getstring(0, False)    def __str__(self):        return self._getstring(0, False)    def _getstring(self, level, expand = False):        s = "%s%s (%s,%s,%s, %d): %s\n" % (            ('  ' * level), self.name, self.id,self.parent_id,            self.root_id, id(self), repr(self.data))        if expand:            s += ''.join([n._getstring(level+1, True)                          for n in self.children.values()])        return s    def print_nodes(self):        return self._getstring(0, True)class TreeLoader(MapperExtension):    def after_insert(self, mapper, connection, instance):        """        Runs after the insert of a new TreeNode row.  The primary key of the        row is not determined until the insert is complete, since most DB's        use autoincrementing columns.  If this node is the root node, we        will take the new primary key and update it as the value of the        node's "root ID" as well, since its root node is itself.        """        if instance.root is instance:            connection.execute(mapper.mapped_table.update(                TreeNode.c.id==instance.id, values=dict(root_id=instance.id)))            instance.root_id = instance.id    def append_result(self, mapper, selectcontext, row, instance, result, **flags):        """        Runs as results from a SELECT statement are processed, and newly        created or already-existing instances that correspond to each row        are appended to result lists.  This method will only append root        nodes to the result list, and will attach child nodes to their        appropriate parent node as they arrive from the select results.        This allows a SELECT statement which returns both root and child        nodes in one query to return a list of "roots".        """        isnew = flags.get('isnew', False)        if instance.parent_id is None:            result.append(instance)        else:            if isnew or selectcontext.populate_existing:                key = mapper.identity_key_from_primary_key(instance.parent_id)                parentnode = selectcontext.session.identity_map[key]                parentnode.children.set(instance)        return Falseclass TreeData(object):    def __init__(self, value=None):        self.id = None        self.value = value    def __repr__(self):        return "TreeData(%s, %s)" % (repr(self.id), repr(self.value))print "\n\n\n----------------------------"print "Creating Tree Table:"print "----------------------------"metadata.create_all()mapper(TreeNode, trees, properties=dict(    # 'root' attribute.  has a load-only backref '_descendants' that loads    # all nodes with the same root ID eagerly, which are intercepted by the    # TreeLoader extension and populated into the "children" collection.    root=relation(TreeNode, primaryjoin=trees.c.root_id==trees.c.id,                  remote_side=trees.c.id, lazy=None,                  backref=backref('_descendants', lazy=False, join_depth=1,                                  primaryjoin=trees.c.root_id==trees.c.id,viewonly=True)),    # 'children' attribute.  collection of immediate child nodes.  this is a    # non-loading relation which is populated by the TreeLoader extension.    children=relation(TreeNode, primaryjoin=trees.c.parent_id==trees.c.id,        lazy=None, cascade="all",        collection_class=attribute_mapped_collection('name'),        backref=backref('parent',                        primaryjoin=trees.c.parent_id==trees.c.id,                        remote_side=trees.c.id)        ),    # 'data' attribute.  A collection of secondary objects which also loads    # eagerly.    data=relation(TreeData, cascade="all, delete-orphan", lazy=False)), extension=TreeLoader())mapper(TreeData, treedata, properties={'id':treedata.c.data_id})session = create_session()node2 = TreeNode('node2')node2.append('subnode1')node = TreeNode('rootnode')node.append('node1')node.append(node2)node.append('node3')node.children['node3'].data = TreeData('node 3s data')node.children['node2'].append('subnode2')node.children['node1'].data = TreeData('node 1s data')print "\n\n\n----------------------------"print "Created new tree structure:"print "----------------------------"print node.print_nodes()print "\n\n\n----------------------------"print "flushing:"print "----------------------------"session.save(node)session.flush()print "\n\n\n----------------------------"print "Tree After Save:"print "----------------------------"print node.print_nodes()node.append('node4')node.children['node4'].append('subnode3')node.children['node4'].append('subnode4')node.children['node4'].children['subnode3'].append('subsubnode1')del node.children['node1']print "\n\n\n----------------------------"print "Modified the tree"print "(added node4, node4/subnode3, node4/subnode4,"print "node4/subnode3/subsubnode1, deleted node1):"print "----------------------------"print node.print_nodes()print "\n\n\n----------------------------"print "Committing:"print "----------------------------"session.flush()print "\n\n\n----------------------------"print "Tree After Save:"print "----------------------------"print node.print_nodes()nodeid = node.idprint "\n\n\n----------------------------"print "Clearing objectstore, selecting "print "tree new where root_id=%d:" % nodeidprint "----------------------------"session.clear()# load some nodes.  we do this based on "root id" which will load an entire# sub-tree in one pass.  the MapperExtension will assemble the incoming# nodes into a tree structure.t = (session.query(TreeNode).       filter(TreeNode.c.root_id==nodeid).       order_by([TreeNode.c.id]))[0]print "\n\n\n----------------------------"print "Full Tree:"print "----------------------------"print t.print_nodes()print "\n\n\n----------------------------"print "Marking root node as deleted"print "and committing:"print "----------------------------"session.delete(t)session.flush()

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一道本成人在线| 97久久精品人人做人人爽| 亚洲国产精品传媒在线观看| 欧美日韩精品一区二区三区蜜桃| 韩国视频一区二区| 国产福利一区二区| 欧美群妇大交群的观看方式| 亚洲国产美国国产综合一区二区| 99国产欧美另类久久久精品 | 欧美美女黄视频| 国产精品色噜噜| 成人免费av资源| 国产欧美日韩视频在线观看| av电影一区二区| 欧美一区二区三区四区在线观看| 成人性色生活片免费看爆迷你毛片| 日本aⅴ亚洲精品中文乱码| 一区二区在线看| 中文字幕一区二| 亚洲精品高清在线观看| 欧美在线观看一区二区| 亚洲成人你懂的| 精品免费国产二区三区| 欧美日韩另类一区| 国精产品一区一区三区mba桃花| 国产欧美一区二区在线观看| 91免费在线播放| 看国产成人h片视频| 国产精品水嫩水嫩| 日韩欧美国产综合一区| 成人91在线观看| 日韩av在线发布| 中文字幕亚洲电影| 欧美一级二级在线观看| 在线视频欧美精品| 免费人成黄页网站在线一区二区| 精品女同一区二区| 国产精品 日产精品 欧美精品| 精品黑人一区二区三区久久| 日韩不卡一区二区三区 | 久久成人免费网| 久久天天做天天爱综合色| 精品电影一区二区| 99久久99久久综合| 青青草国产成人av片免费| 国产视频一区在线播放| 3d动漫精品啪啪| 亚洲一区二区三区视频在线| 日韩精品一区二区三区蜜臀 | 欧美日韩一区二区三区四区| 91在线精品秘密一区二区| www.欧美亚洲| 一本久久a久久免费精品不卡| 日本精品一区二区三区高清| 欧美性色黄大片手机版| 欧美一区二区三区公司| 国产一区二区在线观看视频| 亚洲一区二区三区三| 亚洲va国产va欧美va观看| 日韩国产一二三区| 精品一区二区三区影院在线午夜| 国内精品嫩模私拍在线| 不卡一卡二卡三乱码免费网站| 成人一区二区三区在线观看| 在线视频一区二区三| 日韩一区二区电影在线| 亚洲国产精品国自产拍av| 亚洲在线观看免费视频| 日韩av在线免费观看不卡| 国产精品99久久久久久有的能看| 91免费国产在线观看| 欧美日韩国产色站一区二区三区| 精品国产亚洲在线| 中文字幕在线不卡| 日日骚欧美日韩| 国产宾馆实践打屁股91| 欧美日韩中字一区| 久久久91精品国产一区二区三区| 自拍偷拍欧美精品| 九色综合狠狠综合久久| 91麻豆国产在线观看| 精品国精品自拍自在线| 一区二区三区在线观看动漫| 国内精品国产三级国产a久久| 色999日韩国产欧美一区二区| 日韩欧美一区在线| 国产精品自产自拍| 欧美亚洲一区二区在线观看| 精品av久久707| 美国毛片一区二区| 在线亚洲人成电影网站色www| 日韩欧美中文一区| 亚洲精品高清视频在线观看| 国产麻豆精品95视频| www久久久久| 97精品久久久久中文字幕| 国产suv一区二区三区88区| 色播五月激情综合网| 久久久九九九九| 亚洲国产你懂的| 91丨porny丨首页| 久久免费国产精品| 日本欧美加勒比视频| 色香蕉久久蜜桃| 国产日韩v精品一区二区| 日本欧美大码aⅴ在线播放| 色婷婷国产精品综合在线观看| 国产夜色精品一区二区av| 粉嫩av亚洲一区二区图片| 欧美一区二区三区四区视频| 一区二区三区日韩精品视频| av电影在线观看完整版一区二区| 精品福利视频一区二区三区| 三级一区在线视频先锋| 不卡av免费在线观看| 久久先锋资源网| 久久精品国产一区二区| 欧美精品18+| 天天影视网天天综合色在线播放| 色婷婷一区二区三区四区| 中文字幕在线观看不卡视频| 国产sm精品调教视频网站| 久久久久久久性| 国模冰冰炮一区二区| 2020国产精品| 经典三级在线一区| 精品国产乱码久久久久久浪潮| 天天操天天色综合| 7777精品伊人久久久大香线蕉最新版| 一区二区三区**美女毛片| 在线看国产一区| 伊人色综合久久天天人手人婷| 色嗨嗨av一区二区三区| 夜夜揉揉日日人人青青一国产精品| 99视频在线观看一区三区| 亚洲四区在线观看| 99riav久久精品riav| 国产精品素人视频| av欧美精品.com| 日韩美女啊v在线免费观看| 高清日韩电视剧大全免费| 久久99久久精品| 亚洲成av人片在线| 午夜伦理一区二区| 国产精品久久久久久久久免费樱桃 | 国产一区二区三区国产| 亚洲丝袜自拍清纯另类| 精品日韩一区二区三区| 一本久道中文字幕精品亚洲嫩| 国产自产2019最新不卡| 中文字幕中文字幕一区| 成人av在线播放网站| 亚洲人成伊人成综合网小说| 91豆麻精品91久久久久久| 日韩精品视频网| 久久亚洲精品国产精品紫薇| 成人网男人的天堂| 亚洲精品老司机| 欧美日韩高清在线播放| 免费人成精品欧美精品 | 欧美日韩国产成人在线免费| 欧美bbbbb| 欧美激情一区二区三区蜜桃视频| 91啪在线观看| 免费久久精品视频| 国产精品色眯眯| 欧美日韩国产三级| 国产制服丝袜一区| 亚洲精品高清在线观看| 精品美女一区二区三区| 91网站黄www| 亚洲欧美日韩国产一区二区三区| 欧美日韩久久久一区| 国产精品亚洲а∨天堂免在线| 尤物在线观看一区| 精品国精品自拍自在线| 色狠狠一区二区三区香蕉| 玖玖九九国产精品| 亚洲激情图片一区| 久久久精品中文字幕麻豆发布| 色视频一区二区| 国内精品伊人久久久久av影院 | 色综合久久久久综合体| 免费高清视频精品| 亚洲女与黑人做爰| 精品国精品自拍自在线| 欧美色欧美亚洲另类二区| 国产精品一区二区不卡| 午夜精品视频一区| 国产精品久久久久aaaa| 日韩欧美中文字幕制服| 欧美亚洲日本国产| 国模一区二区三区白浆| 91精品欧美福利在线观看| 久久色在线视频| 欧美日韩一本到| 亚洲视频小说图片| 看片网站欧美日韩| 欧美日韩一区二区欧美激情| 久久综合色播五月|