当前位置: 首页>>代码示例>>Python>>正文


Python User.get方法代码示例

本文整理汇总了Python中user.models.User.get方法的典型用法代码示例。如果您正苦于以下问题:Python User.get方法的具体用法?Python User.get怎么用?Python User.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在user.models.User的用法示例。


在下文中一共展示了User.get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: api_removePeering

# 需要导入模块: from user.models import User [as 别名]
# 或者: from user.models.User import get [as 别名]
def api_removePeering(user_id, message):
    user = User.get(user_id)
    if user:
        user.info['message'] = message
        user.update_peering(False)
        trigger_event('peering.remove', user.json())
        return True
    return False
开发者ID:h4ck3rm1k3,项目名称:openmedialibrary,代码行数:10,代码来源:nodeapi.py

示例2: api_pushChanges

# 需要导入模块: from user.models import User [as 别名]
# 或者: from user.models.User import get [as 别名]
def api_pushChanges(user_id, changes):
    logger.debug('pushChanges no longer used, ignored')
    return True
    user = User.get(user_id)
    if not Changelog.apply_changes(user, changes):
        logger.debug('FAILED TO APPLY CHANGE')
        state.nodes.queue(user_id, 'pullChanges')
        return False
    return True
开发者ID:h4ck3rm1k3,项目名称:openmedialibrary,代码行数:11,代码来源:nodeapi.py

示例3: api_rejectPeering

# 需要导入模块: from user.models import User [as 别名]
# 或者: from user.models.User import get [as 别名]
def api_rejectPeering(user_id, message):
    user = User.get(user_id)
    if user:
        if not user.info:
            user.info = {}
        user.info['message'] = message
        user.update_peering(False)
        trigger_event('peering.reject', user.json())
        return True
    return False
开发者ID:h4ck3rm1k3,项目名称:openmedialibrary,代码行数:12,代码来源:nodeapi.py

示例4: api_acceptPeering

# 需要导入模块: from user.models import User [as 别名]
# 或者: from user.models.User import get [as 别名]
def api_acceptPeering(user_id, username, message):
    user = User.get(user_id)
    logger.debug('incoming acceptPeering event: pending: %s', user.pending)
    if user and user.pending == 'sent':
        if not user.info:
            user.info = {}
        user.info['username'] = username
        user.info['message'] = message
        user.update_name()
        user.update_peering(True, username)
        state.nodes.queue('add', user.id)
        trigger_event('peering.accept', user.json())
        return True
    elif user and user.peered:
        return True
    return False
开发者ID:h4ck3rm1k3,项目名称:openmedialibrary,代码行数:18,代码来源:nodeapi.py

示例5: upgrade_db

# 需要导入模块: from user.models import User [as 别名]
# 或者: from user.models.User import get [as 别名]
def upgrade_db(old, new=None):
    if new:
        if old <= '20140525-92-eac91e7' and new > '20140525-92-eac91e7':
            with db.session():
                import user.models
                for u in user.models.User.query:
                    u.update_name()
                    u.save()
                import item.models
                for f in item.models.File.query:
                    changed = False
                    for key in ('mediastate', 'coverRatio', 'previewRatio'):
                        if key in f.info:
                            del f.info[key]
                            changed = True
                    if changed:
                        f.save()
        if old <= '20140526-118-d451eb3' and new > '20140526-118-d451eb3':
            with db.session():
                import item.models
                item.models.Find.query.filter_by(key='list').delete()

    if old <= '20140527-120-3cb9819':
        run_sql('CREATE INDEX ix_find_findvalue ON find (findvalue)')

    if old <= '20150307-272-557f4d3':
        run_sql('''CREATE TABLE scrape (
    item_id VARCHAR(32) NOT NULL, 
    added DATETIME, 
    PRIMARY KEY (item_id), 
    FOREIGN KEY(item_id) REFERENCES item (id)
)''')
        run_sql('CREATE INDEX idx_scrape_added ON scrape (added)')
    if old <= '20151118-346-7e86e68':
        old_key = os.path.join(settings.config_path, 'node.ssl.key')
        if os.path.exists(old_key):
            os.unlink(old_key)
        statements = [
            "UPDATE user SET id = '{nid}' WHERE id = '{oid}'",
            "UPDATE list SET user_id = '{nid}' WHERE user_id = '{oid}'",
            "UPDATE useritem SET user_id = '{nid}' WHERE user_id = '{oid}'",
            "UPDATE changelog SET user_id = '{nid}' WHERE user_id = '{oid}'",
        ]
        for sql in statements:
            run_sql(sql.format(oid=settings.OLD_USER_ID, nid=settings.USER_ID))
    if old <= '20151201-384-03c2439':
        with db.session():
            import item.models
            for i in item.models.Item.query:
                for f in i.files.all():
                    f.move()
    if old <= '20160103-423-05ca6c9':
        with db.session():
            import item.models
            for i in item.models.Item.query:
                if 'id' in i.meta:
                    del i.meta['id']
                    i.save()
            for m in item.models.Metadata.query:
                if 'id' in m.data:
                    del m.data['id']
                    m.save()
    if old <= '20160106-495-d1b9e96':
        run_sql('CREATE INDEX ix_useritem_user ON useritem ("user_id")')
    if old <= '20160106-497-c86ba8a':
        with db.session() as session:
            u = User.get(settings.USER_ID)
            l = u.library
            for i in u.items.all():
                if not i in l.items:
                    l.items.append(i)
            session.add(l)
            u.clear_list_cache()
            for u in User.query.filter_by(peered=True):
                l = u.library
                for i in u.items.all():
                    if not i in l.items:
                        l.items.append(i)
                session.add(l)
                u.clear_list_cache()
                l.items_count()
            session.commit()
    if old <= '20160107-508-a0c1970':
        with db.session() as session:
            for l in List.query.filter_by(name=' [2]'):
                if not len(l.items):
                    l.remove()
    if old <= '20160107-509-e0857fc':
        with db.session() as session:
            sql = "SELECT COUNT(*) AS c,list_id,item_id FROM listitem GROUP BY list_id, item_id HAVING c>1"
            doubles = [r for r in session.execute(sql)]
            for r in doubles:
                params = {'list_id': r[1], 'item_id': r[2]}
                sql = "DELETE FROM listitem WHERE list_id = :list_id AND item_id = :item_id"
                session.execute(sql, params)
                sql = "INSERT INTO listitem (list_id, item_id) VALUES (:list_id, :item_id)"
                session.execute(sql, params)
            session.commit()
            sql = 'CREATE UNIQUE INDEX IF NOT EXISTS listitem_index on listitem(list_id,item_id)'
            session.execute(sql)
#.........这里部分代码省略.........
开发者ID:h4ck3rm1k3,项目名称:openmedialibrary,代码行数:103,代码来源:setup.py


注:本文中的user.models.User.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。