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


Python FriendHelper.from_data_store方法代码示例

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


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

示例1: get

# 需要导入模块: from rogerthat.bizz.friend_helper import FriendHelper [as 别名]
# 或者: from rogerthat.bizz.friend_helper.FriendHelper import from_data_store [as 别名]
def get():
    from rogerthat.dal.friend import get_friends_map
    user = users.get_current_user()
    friendMap = get_friends_map(user)
    return [FriendTO.fromDBFriendDetail(FriendHelper.from_data_store(users.User(f.email), f.type), f)
            for f in friendMap.friendDetails
            if f.type == FriendDetail.TYPE_SERVICE and f.existence == FriendDetail.FRIEND_EXISTENCE_ACTIVE]
开发者ID:rogerthat-platform,项目名称:rogerthat-backend,代码行数:9,代码来源:services.py

示例2: get

# 需要导入模块: from rogerthat.bizz.friend_helper import FriendHelper [as 别名]
# 或者: from rogerthat.bizz.friend_helper.FriendHelper import from_data_store [as 别名]
def get():
    from rogerthat.dal.friend import get_friends_map
    from rogerthat.models.properties.friend import FriendDetail
    user = users.get_current_user()
    friendMap = get_friends_map(user)
    return [FriendTO.fromDBFriendDetail(FriendHelper.from_data_store(users.User(f.email), f.type), f)
            for f in friendMap.friendDetails if f.type == FriendDetail.TYPE_USER]
开发者ID:our-city-app,项目名称:mobicage-backend,代码行数:9,代码来源:friends.py

示例3: test_invite_response_with_user_data

# 需要导入模块: from rogerthat.bizz.friend_helper import FriendHelper [as 别名]
# 或者: from rogerthat.bizz.friend_helper.FriendHelper import from_data_store [as 别名]
    def test_invite_response_with_user_data(self):
        user_data = {'test1': 'bla1', 'test2': 'bla2'}

        # friend invites svc_identity_user
        invitor = users.get_current_user()

        svc_user = users.User(u's%[email protected]' % time.time())
        si = create_service_profile(svc_user, u"Default name")[1]

        self.assertIsNone(db.get(UserData.createKey(invitor, si.user)))

        invite(invitor, remove_slash_default(si.user).email(), None, None, None,
               None, origin=ORIGIN_USER_INVITE, app_id=App.APP_ID_ROGERTHAT)
        invited_response_receiver(UNIT_TEST_REFS["invited"], json.dumps(user_data))
        myFriendMap = get_friends_map(invitor)
        assert remove_slash_default(si.user) in myFriendMap.friends
        assert myFriendMap.generation > 0
        assert get_friend_serviceidentity_connection(invitor, si.user)

        ud = db.get(UserData.createKey(invitor, si.user))
        self.assertIsNotNone(ud)
        helper = FriendHelper.from_data_store(si.user, FRIEND_TYPE_SERVICE)
        user_data_string = FriendTO.fromDBFriendMap(helper, myFriendMap, si.user, True, True, invitor).userData
        self.assertIsNone(user_data_string)
        ud_dict = ud.userData.to_json_dict()
        ud_dict['__rt__disabledBroadcastTypes'] = ud_dict.get('__rt__disabledBroadcastTypes', [])
        user_data['__rt__disabledBroadcastTypes'] = list()
        self.assertDictEqual(user_data, ud_dict)

        # test cleanup of UserData
        breakFriendShip(invitor, si.user)
        self.assertIsNone(db.get(UserData.createKey(invitor, si.user)))
开发者ID:our-city-app,项目名称:mobicage-backend,代码行数:34,代码来源:test_friends.py

示例4: getStaticFlow

# 需要导入模块: from rogerthat.bizz.friend_helper import FriendHelper [as 别名]
# 或者: from rogerthat.bizz.friend_helper.FriendHelper import from_data_store [as 别名]
def getStaticFlow(request):
    from rogerthat.dal.service import get_service_menu_item_by_coordinates
    from rogerthat.rpc import users
    service_identity_user = add_slash_default(users.User(request.service))
    get_service_identity(service_identity_user)  # azzerts

    smd = get_service_menu_item_by_coordinates(service_identity_user, request.coords)
    if not smd:
        logging.info("No menu item found with coords %s" % request.coords)
        return None

    if smd.isBroadcastSettings:
        response = GetStaticFlowResponseTO()
        helper = FriendHelper.from_data_store(service_identity_user, FRIEND_TYPE_SERVICE)
        response.staticFlow = generate_broadcast_settings_static_flow(helper, users.get_current_user())
        return response

    if not smd.staticFlowKey:
        logging.info("Menu item %s doesn't reference a static flow" % request.coords)
        return None

    mfd = MessageFlowDesign.get(smd.staticFlowKey)
    static_flow = mfd.js_flow_definitions.get_by_hash(request.staticFlowHash)
    if not static_flow:
        logging.info("No static flow found on MFD '%s' with hash %s" % (mfd.name, request.staticFlowHash))
        return None

    response = GetStaticFlowResponseTO()
    response.staticFlow = static_flow.definition
    return response
开发者ID:our-city-app,项目名称:mobicage-backend,代码行数:32,代码来源:services.py

示例5: test_ds_helper_for_user

# 需要导入模块: from rogerthat.bizz.friend_helper import FriendHelper [as 别名]
# 或者: from rogerthat.bizz.friend_helper.FriendHelper import from_data_store [as 别名]
 def test_ds_helper_for_user(self):
     helper = FriendHelper.from_data_store(self.john, FriendTO.TYPE_USER)
     self.assertIsInstance(helper.get_profile_info(), UserProfile)
     self.assertIsNone(helper.get_service_profile())
     self.assertIsNone(helper.get_share_sid())
     self.assertIsNone(helper.get_translator())
     self.assertIsNone(helper.get_service_data())
     self.assertListEqual(helper.list_service_menu_items(), [])
开发者ID:our-city-app,项目名称:mobicage-backend,代码行数:10,代码来源:test_update_friends.py

示例6: get_full_services_list

# 需要导入模块: from rogerthat.bizz.friend_helper import FriendHelper [as 别名]
# 或者: from rogerthat.bizz.friend_helper.FriendHelper import from_data_store [as 别名]
def get_full_services_list():
    from rogerthat.dal.friend import get_friends_map_cached
    app_user = users.get_current_user()
    friendMap = get_friends_map_cached(app_user)
    return [FriendTO.fromDBFriendDetail(FriendHelper.from_data_store(users.User(fd.email), fd.type),
                                        fd, True, True, tagetUser=app_user)
            for fd in (friendMap.friendDetails[friend.email()] for friend in friendMap.friends)
            if fd.isService and fd.existence == fd.FRIEND_EXISTENCE_ACTIVE]
开发者ID:our-city-app,项目名称:mobicage-backend,代码行数:10,代码来源:friends.py

示例7: get_full_service

# 需要导入模块: from rogerthat.bizz.friend_helper import FriendHelper [as 别名]
# 或者: from rogerthat.bizz.friend_helper.FriendHelper import from_data_store [as 别名]
def get_full_service(service):
    from rogerthat.dal.friend import get_friends_map
    user = users.get_current_user()
    service_identity_user = add_slash_default(users.User(service))
    azzert(get_friend_serviceidentity_connection(user, service_identity_user),
           "%s tried to get full service %s, but is not connected to this service identity"
           % (user.email(), service_identity_user.email()))
    helper = FriendHelper.from_data_store(service_identity_user, FRIEND_TYPE_SERVICE)
    return FriendTO.fromDBFriendMap(helper, get_friends_map(user), service_identity_user, includeServiceDetails=True,
                                    targetUser=user)
开发者ID:rogerthat-platform,项目名称:rogerthat-backend,代码行数:12,代码来源:services.py

示例8: test_generated_broadcast_settings_flow

# 需要导入模块: from rogerthat.bizz.friend_helper import FriendHelper [as 别名]
# 或者: from rogerthat.bizz.friend_helper.FriendHelper import from_data_store [as 别名]
    def test_generated_broadcast_settings_flow(self):
        user_profile, service_profile = self._prepare_users()
        friend_user = user_profile.user
        service_identity_user = add_slash_default(service_profile.user)
        helper = FriendHelper.from_data_store(service_identity_user, FRIEND_TYPE_SERVICE)
        helper.get_service_profile()
        helper._service_profile = service_profile  # because we modify the service_profile which is cached by the helper

        makeFriends(friend_user, service_identity_user, service_identity_user, None, origin=ORIGIN_USER_INVITE)

        # No broadcast types ==> no flow
        self.assertFalse(generate_broadcast_settings_static_flow(helper, user_profile.user))

        service_profile.broadcastTypes = ['Apes', 'Birds', 'Cats', 'Dogs']
        service_profile.put()

        friend_service_identity_connection = get_friend_serviceidentity_connection(friend_user, service_identity_user)
        friend_service_identity_connection.enabled_broadcast_types = service_profile.broadcastTypes
        friend_service_identity_connection.put()

        self.assertTrue(generate_broadcast_settings_static_flow(helper, user_profile.user))

        mfds = generate_broadcast_settings_flow_def(helper, user_profile)
        self.assertEqual(1, len(mfds.definition))
        mf_def = mfds.definition[0]
        self.assertEqual(1, len(mf_def.formMessage))
        fm = mf_def.formMessage[0]
        self.assertEqual(len(service_profile.broadcastTypes), len(fm.form.widget.choice))
        self.assertEqual(0, len(service_profile.broadcastTypes) - len(fm.form.widget.value))  # 0 disabled values

        friend_service_identity_connection1 = get_friend_serviceidentity_connection(friend_user, service_identity_user)
        friend_service_identity_connection1.enabled_broadcast_types = ['Birds', 'Cats', 'Dogs']
        friend_service_identity_connection1.disabled_broadcast_types = ['Apes']
        friend_service_identity_connection1.put()

        mfds = generate_broadcast_settings_flow_def(helper, user_profile)
        self.assertEqual(1, len(mfds.definition))
        mf_def = mfds.definition[0]
        self.assertEqual(1, len(mf_def.formMessage))
        fm = mf_def.formMessage[0]
        self.assertEqual(len(service_profile.broadcastTypes), len(fm.form.widget.choice))
        self.assertEqual(1, len(service_profile.broadcastTypes) - len(fm.form.widget.value))  # 1 disabled values

        friend_service_identity_connection2 = get_friend_serviceidentity_connection(friend_user, service_identity_user)
        friend_service_identity_connection2.enabled_broadcast_types = ['Cats', 'Dogs']
        friend_service_identity_connection2.disabled_broadcast_types = ['Apes', 'Birds']
        friend_service_identity_connection2.put()

        mfds = generate_broadcast_settings_flow_def(helper, user_profile)
        self.assertEqual(1, len(mfds.definition))
        mf_def = mfds.definition[0]
        self.assertEqual(1, len(mf_def.formMessage))
        fm = mf_def.formMessage[0]
        self.assertEqual(len(service_profile.broadcastTypes), len(fm.form.widget.choice))
        self.assertEqual(2, len(service_profile.broadcastTypes) - len(fm.form.widget.value))  # 2 disabled values
开发者ID:rogerthat-platform,项目名称:rogerthat-backend,代码行数:57,代码来源:test_broadcast.py

示例9: test_user_data

# 需要导入模块: from rogerthat.bizz.friend_helper import FriendHelper [as 别名]
# 或者: from rogerthat.bizz.friend_helper.FriendHelper import from_data_store [as 别名]
    def test_user_data(self):
        service_user = self._prepare_svc()

        friend_email = u"a%[email protected]" % time.time()

        data = json.dumps(dict(test="hihihi")).decode('utf8')

        self.assertRaises(FriendNotFoundException, put_user_data, friend_email, data)  # non-existing user

        human_user = users.User(friend_email)
        create_user_profile(human_user, friend_email, language=u'nl')
        self.assertRaises(FriendNotFoundException, put_user_data, friend_email, data)  # user is no friend

        makeFriends(human_user, service_user, None, None, None)

        data = json.dumps(dict(test="ikkel", moe="hahaha")).decode('utf8')
        put_user_data(friend_email, data)

        data = json.dumps(dict(test="tikkel", john="doe")).decode('utf8')
        put_user_data(friend_email, data)

        get_helper = lambda: FriendHelper.from_data_store(service_user, FRIEND_TYPE_SERVICE)
        get_friendto = lambda: run_in_xg_transaction(lambda: FriendTO.fromDBFriendMap(get_helper(),
                                                                                      get_friends_map(human_user),
                                                                                      service_user,
                                                                                      True,
                                                                                      True,
                                                                                      human_user))

        ud = db.get(UserData.createKey(human_user, create_service_identity_user(service_user)))
        ud_dict = ud.userData.to_json_dict()
        ud_dict['__rt__disabledBroadcastTypes'] = ud_dict.get('__rt__disabledBroadcastTypes', [])
        self.assertDictEqual(dict(test="tikkel", moe="hahaha", john="doe", __rt__disabledBroadcastTypes=[]),
                             ud_dict)
        self.assertTrue(get_friendto().hasUserData)

        self.assertRaises(InvalidJsonStringException, put_user_data, friend_email, "invalid user data")
        self.assertRaises(InvalidJsonStringException, put_user_data, friend_email, "")

        del_user_data(friend_email, ["test"])
        self.assertTrue(get_friendto().hasUserData)

        del_user_data(friend_email, ["moe", "john"])
        self.assertFalse(get_friendto().hasUserData)

        japanese = u"スキーに行くのが好きです。"
        data_dict = dict(test="ikkel", moe="hahaha", japanese=japanese)
        data = json.dumps(data_dict).decode('utf8')
        put_user_data(friend_email, data)
        data = json.loads(get_user_data(friend_email, ["japanese"]))
        self.assertEqual(japanese, data["japanese"])

        data = json.loads(get_user_data(friend_email, ["japanese", "test", "moe"]))
        self.assertDictEqual(data, data_dict)
开发者ID:rogerthat-platform,项目名称:rogerthat-backend,代码行数:56,代码来源:test_system_api.py

示例10: getFriendsList

# 需要导入模块: from rogerthat.bizz.friend_helper import FriendHelper [as 别名]
# 或者: from rogerthat.bizz.friend_helper.FriendHelper import from_data_store [as 别名]
def getFriendsList(request):
    from rogerthat.rpc import users
    from rogerthat.dal.friend import get_friends_map
    user = users.get_current_user()
    friendMap = get_friends_map(user)
    response = GetFriendsListResponseTO()
    get_helper = lambda f: FriendHelper.from_data_store(users.User(f.email), f.type)
    response.friends = [FriendTO.fromDBFriendDetail(get_helper(f), f, True, True, targetUser=user)
                        for f in friendMap.friendDetails]
    response.generation = friendMap.generation
    return response
开发者ID:our-city-app,项目名称:mobicage-backend,代码行数:13,代码来源:friends.py

示例11: test_menu_items

# 需要导入模块: from rogerthat.bizz.friend_helper import FriendHelper [as 别名]
# 或者: from rogerthat.bizz.friend_helper.FriendHelper import from_data_store [as 别名]
    def test_menu_items(self):
        user_profile, service_profile = self._prepare_users()

        friend_user = user_profile.user
        service_user = service_profile.user
        service_identity = get_default_service_identity(service_profile.user)
        makeFriends(friend_user, service_identity.user, service_identity.user, None, origin=ORIGIN_USER_INVITE)

        helper = FriendHelper.from_data_store(service_identity.user, FRIEND_TYPE_SERVICE)
        helper.get_service_profile()
        helper._service_profile = service_profile  # because we modify the service_profile which is cached by the helper

        menu = ServiceMenuTO.from_model(helper, user_profile.language, user_profile)
        self.assertEqual(0, len(menu.items))

        # No broadcast types --> error
        self.assertRaises(BusinessException, create_menu_item, service_user, "3d", "000000", "label", "tag", [1, 1, 1],
                          None, None, False, False, [], is_broadcast_settings=True, broadcast_branding=None)

        service_profile.broadcastTypes = ['Apes', 'Birds', 'Cats', 'Dogs']
        service_profile.put()

        friend_service_identity_connection = get_friend_serviceidentity_connection(friend_user, service_identity.user)
        friend_service_identity_connection.enabled_broadcast_types = service_profile.broadcastTypes
        friend_service_identity_connection.put()

        create_menu_item(service_user, "3d", "000000", "label", "tag", [1, 1, 1], None, None, False, False, [],
                         is_broadcast_settings=True, broadcast_branding=None)

        def _test_1_bc_settings_item():
            menu = ServiceMenuTO.from_model(helper, user_profile.language, user_profile)
            self.assertEqual(1, len(menu.items))
            smi = menu.items[0]
            self.assertTrue(smi.staticFlowHash)

            request = GetStaticFlowRequestTO()
            request.service = service_user.email()
            request.staticFlowHash = smi.staticFlowHash
            request.coords = smi.coords

            response = getStaticFlow(request)
            self.assertTrue(response)
            self.assertTrue(response.staticFlow)

        _test_1_bc_settings_item()

        move_menu_item(service_user, [1, 1, 1], [2, 2, 2])

        _test_1_bc_settings_item()

        # test Web-version of menu TO
        WebServiceMenuTO.from_model(helper, user_profile.language, user_profile)
开发者ID:rogerthat-platform,项目名称:rogerthat-backend,代码行数:54,代码来源:test_broadcast.py

示例12: populate_friend_response

# 需要导入模块: from rogerthat.bizz.friend_helper import FriendHelper [as 别名]
# 或者: from rogerthat.bizz.friend_helper.FriendHelper import from_data_store [as 别名]
    def populate_friend_response():
        friend_detail = friend_map.friendDetails[friend.email()]
        helper = FriendHelper.from_data_store(users.User(friend_detail.email), friend_detail.type)
        response.friend = FriendTO.fromDBFriendDetail(helper, friend_detail, True, True, targetUser=user)
        response.avatar = unicode(base64.b64encode(get_avatar(friend_detail.avatarId, avatar_size)))

        if friend_detail.type == FRIEND_TYPE_SERVICE:
            service_identity_user = add_slash_default(friend)
            keys = [UserData.createKey(user, service_identity_user),
                    FriendServiceIdentityConnection.createKey(user, service_identity_user)]
            user_data_model, fsic = db.get(keys)
            to_put.extend(create_send_user_data_requests(mobiles, user_data_model, fsic, user, service_identity_user))
            to_put.extend(
                create_send_app_data_requests(mobiles, user, helper))
开发者ID:our-city-app,项目名称:mobicage-backend,代码行数:16,代码来源:friends.py

示例13: test_friend_to

# 需要导入模块: from rogerthat.bizz.friend_helper import FriendHelper [as 别名]
# 或者: from rogerthat.bizz.friend_helper.FriendHelper import from_data_store [as 别名]
    def test_friend_to(self):
        self._extend_service()

        app_user = users.User(u'[email protected]')
        create_user_profile(app_user, u"John Doe")
        makeFriends(app_user, self.service_user, self.service_user, None, ORIGIN_USER_INVITE)

        cs_helper = FriendHelper.serialize(self.service_identity_user, FriendTO.TYPE_SERVICE)
        ds_helper = FriendHelper.from_data_store(self.service_user, FriendTO.TYPE_SERVICE)

        friend_map = get_friends_map(app_user)
        friend_detail = friend_map.friendDetails[self.service_user.email()]
        status = UpdateFriendRequestTO.STATUS_MODIFIED
        ds_friend = convert_friend(ds_helper, app_user, friend_detail, status)
        cs_friend = convert_friend(cs_helper, app_user, friend_detail, status)

        self.assertDictEqual(ds_friend.to_dict(), cs_friend.to_dict())
开发者ID:our-city-app,项目名称:mobicage-backend,代码行数:19,代码来源:test_update_friends.py

示例14: get

# 需要导入模块: from rogerthat.bizz.friend_helper import FriendHelper [as 别名]
# 或者: from rogerthat.bizz.friend_helper.FriendHelper import from_data_store [as 别名]
    def get(self):
        service_email = self.request.GET.get('service')
        azzert(service_email)

        user = users.get_current_user()
        service_identity_user = add_slash_default(users.User(service_email))
        azzert(get_friend_serviceidentity_connection(user, service_identity_user),
               "%s tried to get About page of service %s, but is not connected" % (user.email(), service_identity_user.email()))

        helper = FriendHelper.from_data_store(service_identity_user, FRIEND_TYPE_SERVICE)
        service = FriendTO.fromDBFriendMap(helper, get_friends_map(user), service_identity_user,
                                           includeServiceDetails=True, targetUser=user)
        azzert(service.type == FriendTO.TYPE_SERVICE)

        params = {'service': service,
                  'service_name': service.name or service.email,
                  'container_id': 'serviceAboutPageContainer_%s' % md5_hex(service_email)}
        self.response.out.write(render('service_about', [DEFAULT_LANGUAGE], params, 'web'))
开发者ID:our-city-app,项目名称:mobicage-backend,代码行数:20,代码来源:service_page.py

示例15: testServiceFriendTO

# 需要导入模块: from rogerthat.bizz.friend_helper import FriendHelper [as 别名]
# 或者: from rogerthat.bizz.friend_helper.FriendHelper import from_data_store [as 别名]
    def testServiceFriendTO(self):
        # Prepare service
        service_user, service_profile = self._prepareService('[email protected]')

        # Prepare human_users
        human_users = self._prepareHumans(['en', 'fr', 'nl', 'ar'])

        for human_user in human_users.itervalues():
            makeFriends(human_user, service_user, original_invitee=None, servicetag=None, origin=None)

        # Check FriendTO
        helper = FriendHelper.from_data_store(service_user, FRIEND_TYPE_SERVICE)
        for lang, human_user in human_users.iteritems():
            friend_map = get_friends_map(human_user)
            serviceTO = FriendTO.fromDBFriendMap(helper, friend_map, service_user, includeAvatarHash=False,
                                                 includeServiceDetails=True, targetUser=human_user)

            if lang == service_profile.defaultLanguage or lang not in service_profile.supportedLanguages:
                prefix = ""
            else:
                prefix = "%s_" % lang

            for to_attr in ["name", "description", "descriptionBranding", "qualifiedIdentifier"]:
                expected = prefix + to_attr
                self.assertEqual(getattr(serviceTO, to_attr), expected,
                                 "serviceTO.%s != '%s' (language: %s)" % (to_attr, expected, lang))

            for to_attr, service_profile_attr in {'aboutLabel': 'aboutMenuItemLabel',
                                                  'messagesLabel': 'messagesMenuItemLabel',
                                                  'shareLabel': 'shareMenuItemLabel',
                                                  'callLabel': 'callMenuItemLabel',
                                                  'callConfirmation': 'callMenuItemConfirmation'}.iteritems():
                expected = prefix + service_profile_attr
                self.assertEqual(getattr(serviceTO.actionMenu, to_attr), expected,
                                 "serviceTO.actionMenu.%s != '%s' (language: %s)" % (to_attr, expected, lang))

            for item in serviceTO.actionMenu.items:
                expected_label = prefix + "x".join(map(str, item.coords))
                self.assertEqual(item.label, expected_label,
                                 "item.label != '%s' (language: %s)" % (expected_label, lang))

                expected_screenBranding = prefix + 'screenBranding'
                self.assertEqual(item.screenBranding, expected_screenBranding,
                                 "item.screenBranding != '%s' (language: %s)" % (expected_screenBranding, lang))
开发者ID:rogerthat-platform,项目名称:rogerthat-backend,代码行数:46,代码来源:test_services.py


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