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


Python Portal.user_item方法代码示例

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


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

示例1: copy_user_with_groups_and_items

# 需要导入模块: from portalpy import Portal [as 别名]
# 或者: from portalpy.Portal import user_item [as 别名]
def copy_user_with_groups_and_items():
    source = Portal('http://portaldev.arcgis.com', 'wmathot', 'wmathot')
    target = Portal('http://portaldev.esri.com', 'admin', 'esri.agp')
    source_owner = source.logged_in_user()['username']
    target_owner = target.logged_in_user()['username']

    # Copy the groups
    groups = source.groups(q='owner:' + source_owner)
    copied_groups = copy_groups(groups, source, target)
    print 'Copied ' + str(len(copied_groups)) + ' groups'

    # Copy the items
    copied_items = copy_user_contents(source, source_owner, target, target_owner)
    print 'Copied ' + str(len(copied_items)) + ' items'

    # Share the items in the target portal
    for item_id in copied_items.keys():
        sharing = source.user_item(item_id)[1]
        if sharing['access'] != 'private':
            target_item_id = copied_items[item_id]
            target_group_ids = [copied_groups[id] for id in sharing['groups']\
                                if id in copied_groups]
            target.share_items(target_owner, [target_item_id], target_group_ids,\
                               sharing['access'] == 'org',\
                               sharing['access'] == 'public')
开发者ID:VandanaR,项目名称:PortalPy-AddIn,代码行数:27,代码来源:recipes.py

示例2: copy_group_with_shared_content

# 需要导入模块: from portalpy import Portal [as 别名]
# 或者: from portalpy.Portal import user_item [as 别名]
def copy_group_with_shared_content():
    source = Portal('http://www.arcgis.com')
    target = Portal('http://wittm.esri.com', 'admin', 'esri.agp')
    target_owner = target.logged_in_user()['username']
    group_id = '2394b887a80347fb8544610cfa30489c'

    # Copy the groups
    groups = source.groups(q='id:' + group_id)
    copied_groups = copy_groups(groups, source, target)
    print 'Copied ' + str(len(copied_groups)) + ' groups'

    # Copy the items
    items = source.search(q='group:' + group_id)
    copied_items = copy_items(items, source, target, target_owner,
                              'Copied Items (' + group_id + ')')
    print 'Copied ' + str(len(copied_items)) + ' items'

    # Share the items in the target portal
    for item_id in copied_items.keys():
        sharing = source.user_item(item_id)[1]

        # If we have access to the full sharing properties of the source
        # item, then copy all of them, otherwise just share with the group
        if sharing and sharing['access'] != 'private':
            target_item_id = copied_items[item_id]
            target_group_ids = [copied_groups[id] for id in sharing['groups'] \
                                if id in copied_groups]
            share_org = (sharing['access'] == 'org')
            share_public = (sharing['access'] == 'public')
            if not target.is_multitenant():
                share_public = (share_public or share_org)
            target.share_items(target_owner, [target_item_id],
                               target_group_ids, \
                               share_org or share_public, \
                               share_public)
        else:
            target_item_id = copied_items[item_id]
            target_group_id = copied_groups[group_id]
            target.share_items(target_owner, [target_item_id], \
                               [target_group_id])
开发者ID:VandanaR,项目名称:PortalPy-AddIn,代码行数:42,代码来源:recipes.py

示例3: copy_users

# 需要导入模块: from portalpy import Portal [as 别名]
# 或者: from portalpy.Portal import user_item [as 别名]
def copy_users():
    source = Portal('http://portaldev.arcgis.com', 'admin', 'esri.agp')
    target = Portal('http://wittm.esri.com', 'wmathot', 'wmathot')
    owners = ['admin', 'wmathot']
    target_owner = target.logged_in_user()['username']
    for owner in owners:
        groups = source.groups(q='owner:' + owner)
        copied_groups = copy_groups(groups, source, target, target_owner)
        copied_items = copy_user_contents(source, owner, target, target_owner)
        for item_id in copied_items.keys():
            sharing = source.user_item(item_id)[1]
            if sharing['access'] != 'private':
                target_item_id = copied_items[item_id]
                target_group_ids = [copied_groups[id] for id in sharing['groups']\
                                    if id in copied_groups]
                share_org = (sharing['access'] == 'org')
                share_public = (sharing['access'] == 'public')
                if not target.is_multitenant():
                    share_public = (share_public or share_org)
                target.share_items(target_owner, [target_item_id],
                                   target_group_ids,\
                                   share_org or share_public,\
                                   share_public)
开发者ID:VandanaR,项目名称:PortalPy-AddIn,代码行数:25,代码来源:recipes.py


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