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


Python Tag.timestamp方法代码示例

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


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

示例1: run

# 需要导入模块: from tags.models import Tag [as 别名]
# 或者: from tags.models.Tag import timestamp [as 别名]
def run():
    libraries = connections["old"].cursor()
    cursor = connections["old"].cursor()

    # Delete existing courses
    print "Removing existing libraries..."
    Library.objects.all().delete()

    print "Creating libraries..."

    cached_users = dict([(profile.principal_id, profile.user) for profile in Profile.objects.select_related().all()])
    cached_users["zope.manager"] = admin

    class_id = 101

    cursor.execute("SELECT object_id, id FROM _intids WHERE class_id = %s", [class_id])
    intids = dict(cursor.fetchall())

    tags_dict = {}
    cursor.execute("SELECT * FROM _tags")
    for item, principal, name, timestamp in cursor.fetchall():
        if item not in tags_dict:
            tags_dict[item] = []
        if principal in cached_users:
            tags_dict[item].append((name, cached_users[principal], timestamp))

    rating_dict = {}
    cursor.execute("SELECT * FROM _overall_rating WHERE id = 'overall_rating'")
    for item, id, principal, value, timestamp in cursor.fetchall():
        if item not in rating_dict:
            rating_dict[item] = []
        if principal in cached_users:
            rating_dict[item].append((int(value), cached_users[principal], timestamp))

    reviews_dict = {}
    cursor.execute("SELECT * FROM _reviews")
    for item, principal, text, timestamp in cursor.fetchall():
        if item not in reviews_dict:
            reviews_dict[item] = []
        if principal in cached_users:
            reviews_dict[item].append((text, cached_users[principal], timestamp))

    saved_items_dict = {}
    cursor.execute("SELECT * FROM _bookmarks")
    for item, principal, timestamp in cursor.fetchall():
        if item not in saved_items_dict:
            saved_items_dict[item] = []
        if principal in cached_users:
            saved_items_dict[item].append((cached_users[principal], timestamp))

    creators = {}
    cursor.execute("SELECT * FROM _ownership WHERE class_id = %s", [class_id])
    for object_id, class_id, principal_id in cursor.fetchall():
        if principal_id in cached_users:
            creators[object_id] = cached_users[principal_id]
        else:
            creators[object_id] = admin

    created_dict = {}
    cursor.execute("SELECT * FROM _dublincore WHERE class_id = %s AND property = %s AND qualified = %s",
                   [class_id, "Date", "Created"])
    for id, object_id, class_id, property, qualified, value in cursor.fetchall():
        created_dict[object_id] = parse(value)

    modified_dict = {}
    cursor.execute("SELECT * FROM _dublincore WHERE class_id = %s AND property = %s AND qualified = %s",
                   [class_id, "Date", "Modified"])
    for id, object_id, class_id, property, qualified, value in cursor.fetchall():
        modified_dict[object_id] = parse(value)

    workflow_state_dict = {}
    cursor.execute("SELECT object_id, state FROM _workflowstates WHERE class_id = %s",
                   [class_id, ])
    for object_id, state in cursor.fetchall():
        workflow_state_dict[object_id] = state

    libraries.execute("SELECT * FROM libraries")

    total_items = libraries.rowcount

    cnt = 0


    for id, name, title, description, content_creation_date, authors, \
        author_emails, author_countries, remote_url, keywords, \
        tech_requirements, general_subjects, grade_levels, languages, \
        geographic_relevance, institution, collection, material_types, \
        media_formats, curriculum_standards, is_homepage, iskme_id, cksum, native_id, \
        license_url, license_name, license_image, license_description, \
        copyright_holder, in_rss, rss_description, rss_datetime, is_featured, \
        publication_time, _searchindex, cou_bucket, tags in libraries.fetchall():

        if "audio-lectures" in material_types:
            continue

        cnt += 1

        creator = creators[id]

        try:
#.........这里部分代码省略.........
开发者ID:colinbdclark,项目名称:OER-Commons,代码行数:103,代码来源:migrate_libraries.py


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