def invokeFactory(self, type_name, id, RESPONSE=None, *args, **kw):
            """ Invokes the portal_types tool.
            """
            alsoProvides(self.REQUEST, IDuringContentCreation)
            pt = getToolByName(self, 'portal_types')
            myType = pt.getTypeInfo(self)

            if myType is not None:
                if not myType.allowType(type_name):
                    raise ValueError('Disallowed subobject type: %s' %
                                     type_name)

            # Consider possible default values for title and description,
            # and inject them into kw if necessary.
            inject_title_and_description_defaults(kw, type_name, self)

            new_id = pt.constructContent(type_name, self, id, RESPONSE, *args,
                                         **kw)
            content = self[new_id]

            # Set default values
            set_default_values(content, self, kw)

            noLongerProvides(self.REQUEST, IDuringContentCreation)
            return new_id
        def __call__(self, validate_all=False, data=None, create=False):
            if data is None:
                data = json_body(self.request)

            # set default values
            if create:
                container = aq_parent(aq_inner(self.context))
                set_default_values(self.context, container, data)

            # super call
            return original___call__(self, validate_all, data, create)
Пример #3
0
        def __call__(self, validate_all=False, data=None, create=False):
            if data is None:
                data = json_body(self.request)

            # set default values
            if create:
                container = aq_parent(aq_inner(self.context))
                set_default_values(self.context, container, data)

            # super call
            return original___call__(self, validate_all, data, create)
Пример #4
0
    def notifyMemberAreaCreated(self):
        """Add additional local_roles to the members folder.

        This method is called by the MembershipTool after MembersFolder
        creation.
        """
        api.user.grant_roles(username=self.getOwner().getId(), obj=self,
                             roles=PRIVATE_FOLDER_DEFAULT_ROLES)

        # MembershipTool.createMemberarea() uses yet another way for content
        # creation, that doesn't properly set default values. We therefore
        # apply them here after creation.
        set_default_values(self, self.aq_parent, {})
Пример #5
0
    def notifyMemberAreaCreated(self):
        """Add additional local_roles to the members folder.

        This method is called by the MembershipTool after MembersFolder
        creation.
        """
        api.user.grant_roles(username=self.getOwner().getId(),
                             obj=self,
                             roles=PRIVATE_FOLDER_DEFAULT_ROLES)

        # MembershipTool.createMemberarea() uses yet another way for content
        # creation, that doesn't properly set default values. We therefore
        # apply them here after creation.
        set_default_values(self, self.aq_parent, {})
Пример #6
0
        def createContentWithDefaults(portal_type, container, **kw):
            fti = getUtility(IDexterityFTI, name=portal_type)
            content = createObject(fti.factory)
            set_default_values(content, container, kw)

            # Note: The factory may have done this already, but we want to be sure
            # that the created type has the right portal type. It is possible
            # to re-define a type through the web that uses the factory from an
            # existing type, but wants a unique portal_type!
            content.portal_type = fti.getId()

            for (key, value) in kw.items():
                setattr(content, key, value)

            notify(ObjectCreatedEvent(content))
            return content
Пример #7
0
        def createContentWithDefaults(portal_type, container, **kw):
            fti = getUtility(IDexterityFTI, name=portal_type)
            content = createObject(fti.factory)
            set_default_values(content, container, kw)

            # Note: The factory may have done this already, but we want to be sure
            # that the created type has the right portal type. It is possible
            # to re-define a type through the web that uses the factory from an
            # existing type, but wants a unique portal_type!
            content.portal_type = fti.getId()

            for (key, value) in kw.items():
                setattr(content, key, value)

            notify(ObjectCreatedEvent(content))
            return content
Пример #8
0
        def invokeFactory(self, type_name, id, RESPONSE=None, *args, **kw):
            """ Invokes the portal_types tool.
            """
            alsoProvides(self.REQUEST, IDuringContentCreation)
            pt = getToolByName(self, 'portal_types')
            myType = pt.getTypeInfo(self)

            if myType is not None:
                if not myType.allowType( type_name ):
                    raise ValueError('Disallowed subobject type: %s' % type_name)

            new_id = pt.constructContent(type_name, self, id, RESPONSE, *args, **kw)
            content = self[new_id]

            # Set default values
            set_default_values(content, self, kw)

            noLongerProvides(self.REQUEST, IDuringContentCreation)
            return new_id
 def create(self, data):
     container = aq_inner(self.context)
     obj = original_create(self, data)
     set_default_values(obj, container, data)
     return obj
Пример #10
0
 def create(self, data):
     container = aq_inner(self.context)
     obj = original_create(self, data)
     set_default_values(obj, container, data)
     return obj