• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python component.createObject函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中zope.component.createObject函数的典型用法代码示例。如果您正苦于以下问题:Python createObject函数的具体用法?Python createObject怎么用?Python createObject使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: init_group

def init_group(container, admin_email, emailDomain):
    '''Initialise the first group.'''
    acl_users = container.site_root().acl_users
    site = getattr(container.Content, SITE_ID, None)
    if not site:
        m = 'No site "{0}" found in "{1}"'.format(SITE_ID, container)
        raise ValueError(m)
    siteInfo = createObject('groupserver.SiteInfo', site)

    starter = MoiraeForGroup(siteInfo)
    groupId = 'example_group'
    # We want the userInfo in the context of the site
    admin = acl_users.get_userByEmail(admin_email)
    adminInfo = createObject('groupserver.UserFromId', site, admin.getId())
    try:
        groupInfo = starter.create('Example group', groupId, 'public',
                                   emailDomain, adminInfo)
    except BadRequest:
        mumble_exists_mumble('init_group', 'groups/%s' % groupId)
        m = 'init_group: Skipping the rest of the group configuration.'
        log.warning(m)
    else:
        ju = JoiningUser(adminInfo)
        # Silent Join is used so if the SMTP config is borken everything
        # still works.
        ju.silent_join(groupInfo)
开发者ID:groupserver,项目名称:Products.GroupServer,代码行数:26,代码来源:creation.py


示例2: handle_get_groups

    def handle_get_groups(self, action, data):
        '''The form action for the *Leave group* page.

:param action: The button that was clicked.
:param dict data: The form data.'''
        r = OrderedDict()
        groupInfo = createObject('groupserver.GroupInfo', self.context, data['groupId'])
        userInfo = createObject('groupserver.UserFromId', self.context, data['userId'])
        if groupInfo.groupObj is None:
            r['status'] = self.NO_GROUP
            r['message'] = 'No such group "{0}"'.format(data['groupId'])
        elif userInfo.anonymous:
            r['status'] = self.NO_USER
            r['message'] = 'No such user "{0}"'.format(data['userId'])
        elif user_member_of_group(userInfo, groupInfo):
            leave_group(groupInfo, userInfo, self.request)
            r['status'] = self.SUCCESS
            r['message'] = '{0} has left {1}'.format(userInfo.name, groupInfo.name)
        else:
            r['status'] = self.NOT_MEMBER
            r['message'] = '{0} is not a member {1}'.format(userInfo.name, groupInfo.name)
        r['groupId'] = data['groupId']
        r['userId'] = data['userId']
        retval = to_json(r)
        return retval
开发者ID:groupserver,项目名称:gs.group.member.leave.json,代码行数:25,代码来源:hook.py


示例3: setUp

    def setUp(self):
        self.portal = self.layer['portal']
        setRoles(self.portal, TEST_USER_ID, ['Manager'])

        # Create a conversation.
        conversation = IConversation(self.portal.doc1)

        comment1 = createObject('plone.Comment')
        comment1.text = 'Comment Text'
        comment1.creator = "jim"
        comment1.author_username = "Jim"
        comment1.creation_date = datetime(2006, 9, 17, 14, 18, 12)
        comment1.modification_date = datetime(2006, 9, 17, 14, 18, 12)
        self.new_id1 = conversation.addComment(comment1)

        comment2 = createObject('plone.Comment')
        comment2.text = 'Comment Text'
        comment2.creator = "emma"
        comment2.author_username = "Emma"
        comment2.creation_date = datetime(2007, 12, 13, 4, 18, 12)
        comment2.modification_date = datetime(2007, 12, 13, 4, 18, 12)
        self.new_id2 = conversation.addComment(comment2)

        comment3 = createObject('plone.Comment')
        comment3.text = 'Comment Text'
        comment3.creator = "lukas"
        comment3.author_username = "Lukas"
        comment3.creation_date = datetime(2009, 4, 12, 11, 12, 12)
        comment3.modification_date = datetime(2009, 4, 12, 11, 12, 12)
        self.new_id3 = conversation.addComment(comment3)

        self.conversation = conversation
开发者ID:urska19,项目名称:Plone-test,代码行数:32,代码来源:test_indexers.py


示例4: test_conversations_method

    def test_conversations_method(self):
        self.topic.invokeFactory(
            'conversation',
            id='conv1',
            title='Conversation 1'
        )
        conversation = IConversation(self.topic.conv1)
        comment1 = createObject('plone.Comment')
        comment1.creation_date = datetime.utcnow()
        comment1.author_name = u'John Doe'
        conversation.addComment(comment1)
        comment2 = createObject('plone.Comment')
        comment2.creation_date = datetime.utcnow()
        comment2.author_name = u'Jane Doe'
        conversation.addComment(comment2)
        from collective.ploneboard.browser.topic import TopicView
        view = TopicView(self.topic, self.request)

        conversations = view.conversations()

        self.assertEqual(len(conversations), 1)
        self.assertEqual(
            conversations,
            [
                {
                    'title': u'Conversation 1',
                    'url': 'http://nohost/plone/board/topic1/conv1',
                    'total_comments': 2,
                    'last_commenter': u'Jane Doe',
                    'last_comment_date': comment2.creation_date,
                }
            ]
        )
开发者ID:Ammy2,项目名称:collective.ploneboard-1,代码行数:33,代码来源:test_topic.py


示例5: __init__

    def __init__(self, page):
        """Create an edit auditor.

        DESCRIPTION
            The constructor for an auditor is passed all the data
            that will be the same for the events that are created
            during one use of the auditor by a Zope 3 page-view.

        ARGUMENTS
            "page"    A IGSContentFolder representing the page being
                      edited.

        SIDE EFFECTS
            The page is set to the page that is passed in, and used
            as the context for the auditor.

            The user (who is acting on the page) is set after
            determining the logged-in user, using the page as the
            context.

            The site that all this is occurring on is set, after
            being determined by a similar mechanism to the user.

            A page-edit audit event factory is instantiated.
        """
        self.page = page
        self.userInfo = createObject('groupserver.LoggedInUser', page)
        self.siteInfo = createObject('groupserver.SiteInfo', page)

        self.queries = AuditQuery()

        self.factory = EditPageAuditEventFactory()
开发者ID:groupserver,项目名称:Products.GSContentManager,代码行数:32,代码来源:audit.py


示例6: __call__

    def __call__(self):
        siteInfo = createObject('groupserver.SiteInfo', self.context)
        auditor = Auditor(self.context, siteInfo)

        if len(self.traverse_subpath) == 1:
            # The reset ID is specified
            resetId = self.traverse_subpath[0]
            try:
                passwordResetUser = \
                    createObject('groupserver.PasswordResetUser', self.context,
                                resetId)
            except ResetIdNotFoundError:
                auditor.info(RESET_ID_404, instanceDatum=resetId)
                u = '/password-reset-not-found.html?resetId={0}'
                uri = u.format(resetId)
            else:
                if passwordResetUser.resetId_current(resetId):
                    auditor.info(RESET_LOGIN, passwordResetUser)
                    # Only log in when resetting the password
                    login(self.context, passwordResetUser.user)
                    uri = passwordResetUser.passwordSetUrl
                else:
                    auditor.info(RESET_ID_410, passwordResetUser, resetId)
                    u = '/password-reset-used.html?resetId={0}'
                    uri = u.format(resetId)
        else:
            auditor.info(RESET_ID_400)
            # the reset ID is not specified
            uri = '/password-reset-no-id.html'
        assert uri, 'URI not set'
        return self.request.RESPONSE.redirect(uri)
开发者ID:groupserver,项目名称:gs.profile.password,代码行数:31,代码来源:redirect.py


示例7: setUp

    def setUp(self):
        self.portal = self.layer['portal']
        setRoles(self.portal, TEST_USER_ID, ['Manager'])

        workflow = self.portal.portal_workflow
        workflow.doActionFor(self.portal.doc1, 'publish')

        # Create a conversation.
        conversation = IConversation(self.portal.doc1)

        comment1 = createObject('plone.Comment')
        comment1.text = 'Comment Text'
        comment1.creator = 'jim'
        comment1.author_username = 'Jim'
        comment1.creation_date = datetime(2006, 9, 17, 14, 18, 12)
        comment1.modification_date = datetime(2006, 9, 17, 14, 18, 12)
        self.new_id1 = conversation.addComment(comment1)

        comment2 = createObject('plone.Comment')
        comment2.text = 'Comment Text'
        comment2.creator = 'emma'
        comment2.author_username = 'Emma'
        comment2.creation_date = datetime(2007, 12, 13, 4, 18, 12)
        comment2.modification_date = datetime(2007, 12, 13, 4, 18, 12)
        self.new_id2 = conversation.addComment(comment2)

        comment3 = createObject('plone.Comment')
        comment3.text = 'Comment Text'
        comment3.creator = 'lukas'
        comment3.author_username = 'Lukas'
        comment3.creation_date = datetime(2009, 4, 12, 11, 12, 12)
        comment3.modification_date = datetime(2009, 4, 12, 11, 12, 12)
        self.new_id3 = conversation.addComment(comment3)

        self.conversation = conversation
开发者ID:RedTurtle,项目名称:plone.app.discussion,代码行数:35,代码来源:test_indexers.py


示例8: test_notify_user

    def test_notify_user(self):
        # Add a comment with user notification enabled. Add another comment
        # and make sure an email is send to the user of the first comment.
        comment = createObject("plone.Comment")
        comment.text = "Comment text"
        comment.user_notification = True
        comment.author_email = "[email protected]"
        self.conversation.addComment(comment)
        comment = createObject("plone.Comment")
        comment.text = "Comment text"

        comment_id = self.conversation.addComment(comment)

        self.assertEqual(len(self.mailhost.messages), 1)
        self.assertTrue(self.mailhost.messages[0])
        msg = str(self.mailhost.messages[0])
        self.assertTrue("To: [email protected]" in msg)
        self.assertTrue("From: [email protected]" in msg)
        # We expect the headers to be properly header encoded (7-bit):
        self.assertTrue("Subject: =?utf-8?q?A_comment_has_been_posted=2E?=\n" in msg)
        # The output should be encoded in a reasonable manner
        # (in this case quoted-printable):
        self.assertTrue("A comment on 'K=C3=B6lle Alaaf' has been posted here:" in msg)
        self.assertTrue("http://nohost/plone/d=\noc1/view#%s" % comment_id in msg)
        self.assertTrue("Comment text" in msg)
        self.assertFalse("Approve comment" in msg)
        self.assertFalse("Delete comment" in msg)
开发者ID:plonejp,项目名称:plone.app.discussion,代码行数:27,代码来源:test_notifications.py


示例9: setUp

 def setUp(self):
     self.app = self.layer["app"]
     self.portal = self.layer["portal"]
     self.request = self.layer["request"]
     setRoles(self.portal, TEST_USER_ID, ["Manager"])
     typetool = self.portal.portal_types
     typetool.constructContent("Document", self.portal, "doc1")
     self.wf = getToolByName(self.portal, "portal_workflow", None)
     self.context = self.portal
     self.portal.portal_workflow.setChainForPortalTypes(("Discussion Item",), "comment_review_workflow")
     self.wf_tool = self.portal.portal_workflow
     # Add a conversation with three comments
     conversation = IConversation(self.portal.doc1)
     comment1 = createObject("plone.Comment")
     comment1.title = "Comment 1"
     comment1.text = "Comment text"
     comment1.Creator = "Jim"
     new_id_1 = conversation.addComment(comment1)
     self.comment1 = self.portal.doc1.restrictedTraverse("++conversation++default/%s" % new_id_1)
     comment2 = createObject("plone.Comment")
     comment2.title = "Comment 2"
     comment2.text = "Comment text"
     comment2.Creator = "Joe"
     new_id_2 = conversation.addComment(comment2)
     self.comment2 = self.portal.doc1.restrictedTraverse("++conversation++default/%s" % new_id_2)
     comment3 = createObject("plone.Comment")
     comment3.title = "Comment 3"
     comment3.text = "Comment text"
     comment3.Creator = "Emma"
     new_id_3 = conversation.addComment(comment3)
     self.comment3 = self.portal.doc1.restrictedTraverse("++conversation++default/%s" % new_id_3)
     self.conversation = conversation
开发者ID:RedTurtle,项目名称:plone.app.discussion,代码行数:32,代码来源:test_moderation_view.py


示例10: add_new_user

    def add_new_user(self, toAddr, profileDict):
        # Email address does not exist, but it is a legitimate address
        user = create_user_from_email(self.context, toAddr)
        # force verify
        vid = '%s-%s-verified' % (toAddr, self.adminInfo.id)
        evu = createObject('groupserver.EmailVerificationUserFromEmail',
                           self.context, toAddr)
        evu.add_verification_id(vid)
        evu.verify_email(vid)

        # get the user object in the context of the group and site
        userInfo = createObject('groupserver.UserFromId', self.context,
                                user.id)
        self.add_profile_attributes(userInfo, profileDict)
        auditor = self.get_auditor(userInfo)
        status = ADD_NEW_USER
        auditor.info(status, toAddr)
        joininguser = IGSJoiningUser(userInfo)
        joininguser.silent_join(self.groupInfo)
        e = '<code class="email">{0}</code>'.format(toAddr)
        msg = _('new-profile-member',
                '<li>A profile for ${user} has been created, and given the '
                'email address ${email}.</li>\n'
                '<li>${user} has been joined to ${group}.</li>\n',
                mapping={'email': e,
                         'user': userInfo_to_anchor(userInfo),
                         'group': groupInfo_to_anchor(self.groupInfo)})
        retval = (msg, userInfo, status)
        return retval
开发者ID:groupserver,项目名称:gs.group.member.add.base,代码行数:29,代码来源:adder.py


示例11: setUp

    def setUp(self):
        # Setup session manager
        ztc.utils.setupCoreSessions(self.layer['app'])

        # Setup sandbox
        self.portal = self.layer['portal']
        self.request = self.layer['request']
        setRoles(self.portal, TEST_USER_ID, ['Manager'])
        name = self.portal.invokeFactory(
            id='doc1',
            title='Document 1',
            type_name='Document')

        self.document = self.portal[name]
        conversation = IConversation(self.document)
        replies = IReplies(conversation)

        comment = createObject('plone.Comment')
        comment.text = 'This is a comment'
        new_id = replies.addComment(comment)
        comment = self.document.restrictedTraverse(
            '++conversation++default/%s' % new_id)

        re_comment = createObject('plone.Comment')
        re_comment.text = 'This is a reply'
        re_comment.author_username = "julia"
        re_comment.author_name = "Juliana"
        re_comment.author_email = "[email protected]"

        replies = IReplies(comment)
        new_re_id = replies.addComment(re_comment)
开发者ID:CGTIC,项目名称:Plone_SP,代码行数:31,代码来源:test_contentrules.py


示例12: __call__

    def __call__(self):
        siteInfo = createObject('groupserver.SiteInfo', self.context)
        auditor = Auditor(self.context, siteInfo)

        if len(self.traverse_subpath) == 1:
            # A verification ID is present
            verificationId = self.traverse_subpath[0]
            try:
                emailVerificationUser = \
                    createObject('groupserver.EmailVerificationUser',
                                    self.context, verificationId)
            except VerificationIdNotFoundError:
                auditor.info(VERIFY_ID_404, instanceDatum=verificationId)
                uri = '/email-verify-not-found.html?verificationId=%s' % \
                    verificationId
            else:
                if emailVerificationUser.verificationId_current(verificationId):
                    auditor.info(VERIFY_LOGIN, emailVerificationUser)
                    # Only log in when able to verify the email address
                    login(self.context, emailVerificationUser.user)
                    uri = '%s?verificationId=%s' % \
                      (emailVerificationUser.emailVerifyUrl, verificationId)
                else:
                    auditor.info(VERIFY_ID_410, emailVerificationUser,
                        verificationId)
                    uri = '/email-verify-used.html?verificationId=%s' %\
                        verificationId
        else:
            auditor.info(VERIFY_ID_400)
            # No verification ID is present
            uri = '/email-verify-no-id.html'
        assert uri, 'URI not set'
        return self.request.RESPONSE.redirect(uri)
开发者ID:groupserver,项目名称:gs.profile.email.verify,代码行数:33,代码来源:redirect.py


示例13: test_marks_behavior

    def test_marks_behavior(self):

        fti = queryUtility(IDexterityFTI, 
                           name='upfront.assessmentitem.content.assessmentitem')
        factory = fti.factory
        new_assessmentitem = createObject(factory)
        self.failUnless(IAssessmentItem.providedBy(new_assessmentitem))

        fti = queryUtility(IDexterityFTI, 
                           name='upfront.assessmentitem.content.answer')
        factory = fti.factory
        new_answer = createObject(factory)
        self.failUnless(IAnswer.providedBy(new_answer))
 
        marks_behavior = getUtility(IBehavior, 
                        name = 'upfront.assessmentitem.behaviors.IMarks')

        # We expect this behavior to be a form field provider. Let's verify that
        self.failUnless(
            IFormFieldProvider.providedBy(marks_behavior.interface)
            )

        # assert that you cannot add this behavior to a non-dexterity 
        # content type
        doc = Document('doc')
        marks_adapter = IMarks(doc, None)
        self.assertEquals(False, marks_adapter is not None)

        # assert that new_assessmentitem object implements the behavior
        marks_adapter2 = IMarks(new_assessmentitem, None)
        self.assertEquals(True, marks_adapter2 is not None)
        
        # assert that new_answer object does not implements the behavior
        marks_adapter3 = IMarks(new_answer, None)
        self.assertEquals(False, marks_adapter3 is not None)
开发者ID:upfrontsystems,项目名称:upfront.assessmentitem,代码行数:35,代码来源:test_behaviors.py


示例14: test_add_comment

    def test_add_comment(self):
        # Add comments to a CommentReplies adapter

        # Create a conversation. In this case we doesn't assign it to an
        # object, as we just want to check the Conversation object API.
        conversation = IConversation(self.portal.doc1)

        # Add a comment to the conversation
        replies = IReplies(conversation)

        comment = createObject('plone.Comment')
        comment.text = 'Comment text'
        new_id = replies.addComment(comment)
        comment = self.portal.doc1.restrictedTraverse(
            '++conversation++default/%s' % new_id)

        # Add a reply to the CommentReplies adapter of the first comment
        re_comment = createObject('plone.Comment')
        re_comment.text = 'Comment text'

        replies = IReplies(comment)

        new_re_id = replies.addComment(re_comment)

        # check that replies provides the IReplies interface
        self.assertTrue(IReplies.providedBy(replies))

        # Make sure our comment was added
        self.assertTrue(new_re_id in replies)

        # Make sure it is also reflected in the conversation
        self.assertTrue(new_re_id in conversation)

        # Make sure the conversation has the correct comment id
        self.assertEqual(conversation[new_re_id].comment_id, new_re_id)
开发者ID:a-pasquale,项目名称:plone.app.discussion,代码行数:35,代码来源:test_comment.py


示例15: process_form

    def process_form(self):
        '''Process the forms in the page.

        This method uses the "submitted" pattern that is used for the
        XForms impementation on GroupServer.
          * The method is called whenever the page is loaded by
            tal:define="result view/process_form".
          * The submitted form is checked for the hidden "submitted" field.
            This field is only returned if the user submitted the form,
            not when the page is loaded for the first time.
            - If the field is present, then the form is processed.
            - If the field is absent, then the method re  turns.

        RETURNS
            A "result" dictionary, that at-least contains the form that
            was submitted
        '''
        form = self.context.REQUEST.form
        result = {}
        result['form'] = form

        if 'submitted' in form:
            groupIds = [k.split('-respond')[0] for k in form.keys()
              if '-respond' in k]
            responses = [form['%s-respond' % k] for k in groupIds]
            result['error'] = False
            acceptedMessage = declinedMessage = u''

            accepted = [k.split('-accept')[0] for k in responses
              if '-accept' in k]
            if accepted:
                acceptedGroups = [createObject('groupserver.GroupInfo',
                  self.groupsInfo.groupsObj, g) for g in accepted]
                self.accept_invitations(acceptedGroups)
                acceptedMessage = self.accept_message(acceptedGroups)

            declined = [k.split('-decline')[0] for k in responses
                        if '-decline' in k]
            for d in declined:
                assert d not in accepted
            if declined:
                declinedGroups = [createObject('groupserver.GroupInfo',
                  self.groupsInfo.groupsObj, g) for g in declined]
                self.decline_invitations(declinedGroups)
                declinedMessage = self.decline_message(declinedGroups)

            result['message'] = u'%s\n%s' % \
                (acceptedMessage, declinedMessage)
            self.__currentInvitations = None
            assert 'error' in result, 'No "errror" in the result'
            assert type(result['error']) == bool
            assert 'message' in result, 'No "message" in the result'
            assert type(result['message']) == unicode

            # Invalidate the current invitations property, so it is recomputed.
            del self._current_invitations

        assert 'form' in result
        assert type(result['form']) == dict
        return result
开发者ID:groupserver,项目名称:gs.profile.invite,代码行数:60,代码来源:invitationsrespond.py


示例16: __init__

    def __init__(self, site):
        self.site = site
        self.userInfo = createObject('groupserver.LoggedInUser', site)
        self.siteInfo = createObject('groupserver.SiteInfo', site)
        self.queries = AuditQuery()

        self.factory = ChangeAuditEventFactory()
开发者ID:groupserver,项目名称:gs.site.about,代码行数:7,代码来源:audit.py


示例17: test_traversal

    def test_traversal(self):
        # Create a nested structure of comment replies and check the traversal

        # make sure comments are traversable, have an id, absolute_url and
        # physical path
        conversation = IConversation(self.portal.doc1)

        comment1 = createObject('plone.Comment')
        comment1.text = 'Comment text'

        conversation.addComment(comment1)

        comment = createObject('plone.Comment')
        comment.text = 'Comment text'
        new_id = conversation.addComment(comment)
        comment = self.portal.doc1.restrictedTraverse(
            '++conversation++default/%s' % new_id)

        # Add a reply to the CommentReplies adapter of the first comment
        re_comment = createObject('plone.Comment')
        re_comment.text = 'Comment text'
        replies = IReplies(comment)
        new_re_id = replies.addComment(re_comment)
        re_comment = self.portal.doc1.restrictedTraverse(
                '++conversation++default/%s' % new_re_id)

        # Add a reply to the reply
        re_re_comment = createObject('plone.Comment')
        re_re_comment.text = 'Comment text'
        replies = IReplies(re_comment)
        new_re_re_id = replies.addComment(re_re_comment)
        re_re_comment = self.portal.doc1.restrictedTraverse(
                '++conversation++default/%s' % new_re_re_id)

        # Add a reply to the replies reply
        re_re_re_comment = createObject('plone.Comment')
        re_re_re_comment.text = 'Comment text'
        replies = IReplies(re_re_comment)
        new_re_re_re_id = replies.addComment(re_re_re_comment)
        re_re_re_comment = self.portal.doc1.restrictedTraverse(
            '++conversation++default/%s' % new_re_re_re_id)

        self.assertEqual(('', 'plone', 'doc1', '++conversation++default',
                           str(new_id)), comment.getPhysicalPath())
        self.assertEqual('http://nohost/plone/doc1/++conversation++default/' +
                          str(new_id), comment.absolute_url())
        self.assertEqual(('', 'plone', 'doc1', '++conversation++default',
                           str(new_re_id)), re_comment.getPhysicalPath())
        self.assertEqual('http://nohost/plone/doc1/++conversation++default/' +
                          str(new_re_id), re_comment.absolute_url())
        self.assertEqual(('', 'plone', 'doc1', '++conversation++default',
                           str(new_re_re_id)), re_re_comment.getPhysicalPath())
        self.assertEqual('http://nohost/plone/doc1/++conversation++default/' +
                          str(new_re_re_id), re_re_comment.absolute_url())
        self.assertEqual(('', 'plone', 'doc1', '++conversation++default',
                           str(new_re_re_re_id)),
                           re_re_re_comment.getPhysicalPath())
        self.assertEqual('http://nohost/plone/doc1/++conversation++default/' +
                          str(new_re_re_re_id),
                          re_re_re_comment.absolute_url())
开发者ID:giacomos,项目名称:plone.app.discussion,代码行数:60,代码来源:test_comment.py


示例18: __init__

    def __init__(self, user):
        self.user = user
        self.userInfo = createObject('groupserver.LoggedInUser', user)
        self.instanceUserInfo = IGSUserInfo(user)
        self.siteInfo = createObject('groupserver.SiteInfo', user)

        self.queries = AuditQuery()
        self.factory = CustomUserAuditEventFactory()
开发者ID:groupserver,项目名称:Products.CustomUserFolder,代码行数:8,代码来源:audituser.py


示例19: __init__

 def __init__(self, groupInfo, eDict):
     self.groupInfo = groupInfo
     self.userInfo = createObject('groupserver.UserFromId', self.groupInfo.groupObj,
                                  eDict['user_id'])
     self.date = eDict['date']
     self.removingUserInfo = createObject('groupserver.UserFromId', self.groupInfo.groupObj,
                                          eDict['admin_id'])
     self.css = 'leave-event'
开发者ID:groupserver,项目名称:gs.group.member.log,代码行数:8,代码来源:monthlog.py


示例20: test_commentators

    def test_commentators(self):
        # add and remove a few comments to make sure the commentators
        # property returns a true set

        # Create a conversation. In this case we doesn't assign it to an
        # object, as we just want to check the Conversation object API.
        conversation = IConversation(self.portal.doc1)

        self.assertEqual(conversation.total_comments, 0)

        # Add a four comments from three different users
        # Note: in real life, we always create
        # comments via the factory to allow different factories to be
        # swapped in
        comment1 = createObject('plone.Comment')
        comment1.text = 'Comment text'
        comment1.author_username = "Jim"
        conversation.addComment(comment1)

        comment2 = createObject('plone.Comment')
        comment2.text = 'Comment text'
        comment2.author_username = "Joe"
        conversation.addComment(comment2)

        comment3 = createObject('plone.Comment')
        comment3.text = 'Comment text'
        comment3.author_username = "Jack"
        new_comment3_id = conversation.addComment(comment3)

        comment4 = createObject('plone.Comment')
        comment4.text = 'Comment text'
        comment4.author_username = "Jack"
        new_comment4_id = conversation.addComment(comment4)

        # check if all commentators are in the commentators list
        self.assertEqual(conversation.total_comments, 4)
        self.assertTrue('Jim' in conversation.commentators)
        self.assertTrue('Joe' in conversation.commentators)
        self.assertTrue('Jack' in conversation.commentators)

        # remove the comment from Jack
        del conversation[new_comment3_id]

        # check if Jack is still in the commentators list (since
        # he had added two comments)
        self.assertTrue('Jim' in conversation.commentators)
        self.assertTrue('Joe' in conversation.commentators)
        self.assertTrue('Jack' in conversation.commentators)
        self.assertEqual(conversation.total_comments, 3)

        # remove the second comment from Jack
        del conversation[new_comment4_id]

        # check if Jack has been removed from the commentators list
        self.assertTrue('Jim' in conversation.commentators)
        self.assertTrue('Joe' in conversation.commentators)
        self.assertFalse('Jack' in conversation.commentators)
        self.assertEqual(conversation.total_comments, 2)
开发者ID:giacomos,项目名称:plone.app.discussion,代码行数:58,代码来源:test_conversation.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python component.getAdapter函数代码示例发布时间:2022-05-26
下一篇:
Python menu.BrowserSubMenuItem类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap