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


Python ContactManager.getTrustedContacts方法代码示例

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


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

示例1: get

# 需要导入模块: from newebe.contacts.models import ContactManager [as 别名]
# 或者: from newebe.contacts.models.ContactManager import getTrustedContacts [as 别名]
    def get(self):
        '''
        Retrieve whole contact list at JSON format.
        '''

        contacts = ContactManager.getTrustedContacts()

        self.return_documents(contacts)
开发者ID:mike-perdide,项目名称:newebe,代码行数:10,代码来源:handlers.py

示例2: send_creation_to_contacts

# 需要导入模块: from newebe.contacts.models import ContactManager [as 别名]
# 或者: from newebe.contacts.models.ContactManager import getTrustedContacts [as 别名]
    def send_creation_to_contacts(self, path, doc):
        '''
        Sends a POST request to all trusted contacts.

        Request body contains object to post at JSON format.
        '''

        contacts = ContactManager.getTrustedContacts()
        client = ContactClient(self.activity)
        for contact in contacts:
            try:
                client.post(contact, path, doc.toJson(localized=False))
            except HTTPError:
                self.activity.add_error(contact)
                self.activity.save()
开发者ID:rakoo,项目名称:newebe,代码行数:17,代码来源:handlers.py

示例3: send_profile_to_contacts

# 需要导入模块: from newebe.contacts.models import ContactManager [as 别名]
# 或者: from newebe.contacts.models.ContactManager import getTrustedContacts [as 别名]
    def send_profile_to_contacts(self):
        '''
        External methods to not send too much times the changed profile. 
        A timer is set to wait for other modifications before running this
        function that sends modification requests to every contacts.
        '''

        client = HTTPClient()
        self.sending_data = False

        user = UserManager.getUser()
        jsonbody = user.toJson()

        activity = Activity(
            authorKey = user.key,
            author = user.name,
            verb = "modifies",
            docType = "profile",
            method = "PUT",
            docId = "none",
            isMine = True
        )
        activity.save()     

        for contact in ContactManager.getTrustedContacts():

            try:
                request = HTTPRequest("%scontacts/update-profile/" % contact.url, 
                             method="PUT", body=jsonbody, validate_cert=False)
        
                response = client.fetch(request)

                if response.error:
                    logger.error("""
                        Profile sending to a contact failed, error infos are 
                        stored inside activity.
                    """)
                    activity.add_error(contact)
                    activity.save()
            except:
                logger.error("""
                    Profile sending to a contact failed, error infos are 
                    stored inside activity.
                """)
                activity.add_error(contact)
                activity.save()

            logger.info("Profile update sent to all contacts.")
开发者ID:mike-perdide,项目名称:newebe,代码行数:50,代码来源:handlers.py

示例4: send_files_to_contacts

# 需要导入模块: from newebe.contacts.models import ContactManager [as 别名]
# 或者: from newebe.contacts.models.ContactManager import getTrustedContacts [as 别名]
    def send_files_to_contacts(self, path, fields, files):
        '''
        Sends in a form given file and fields to all trusted contacts (at given
        path).

        If any error occurs, it is stored in linked activity.
        '''

        contacts = ContactManager.getTrustedContacts()
        client = ContactClient(self.activity)
        for contact in contacts:
            try:
                client.post_files(contact, path, fields = fields, files = files)
            except HTTPError:
                self.activity.add_error(contact)
                self.activity.save()
开发者ID:rakoo,项目名称:newebe,代码行数:18,代码来源:handlers.py

示例5: get

# 需要导入模块: from newebe.contacts.models import ContactManager [as 别名]
# 或者: from newebe.contacts.models.ContactManager import getTrustedContacts [as 别名]
    def get(self):
        '''
        Asks for all contacts to resend their data from last month. 
        As answer contacts send their profile. So contact data are updated, 
        then contacts resend all their from their last month just like they 
        were posted now.
        Current newebe has to check himself if he already has these data.
        '''

        client = ContactClient()
        user = UserManager.getUser()

        self.contacts = dict()
        for contact in ContactManager.getTrustedContacts():
            self.ask_to_contact_for_sync(client, user, contact)

        self.return_success("", 200)
开发者ID:mike-perdide,项目名称:newebe,代码行数:19,代码来源:handlers.py

示例6: send_deletion_to_contacts

# 需要导入模块: from newebe.contacts.models import ContactManager [as 别名]
# 或者: from newebe.contacts.models.ContactManager import getTrustedContacts [as 别名]
    def send_deletion_to_contacts(self, path, doc):
        '''
        Send a delete request (PUT because Tornado don't handle DELETE request
        with a body) to all trusted contacts.

        Request body contains object to delete at JSON format.
        '''

        contacts = ContactManager.getTrustedContacts()
        client = ContactClient(self.activity)
        date = date_util.get_db_date_from_date(doc.date)

        for contact in contacts:
            try:
                client.delete(contact, path, doc.toJson(localized=False), date)
            except HTTPError:
                import pdb
                pdb.set_trace()
                self.activity.add_error(contact, extra=date)
                self.activity.save()
开发者ID:rakoo,项目名称:newebe,代码行数:22,代码来源:handlers.py

示例7: get_trusted_contacts

# 需要导入模块: from newebe.contacts.models import ContactManager [as 别名]
# 或者: from newebe.contacts.models.ContactManager import getTrustedContacts [as 别名]
def get_trusted_contacts(step):
    world.contacts = ContactManager.getTrustedContacts()
开发者ID:mike-perdide,项目名称:newebe,代码行数:4,代码来源:steps.py


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