Exemple #1
0
    def __call__(self):

        ctype = self.request.params.get("ctype", None)

        clazz = Registry.get(ctype)

        initial_data = self.request.params.copy()
        del initial_data['ctype']

        content = clazz("_TMP", data=initial_data)

        content.owner = self.user

        content_id = str(uuid.uuid1())
        content.set_id(content_id)

        alsoProvides(content, ITemporaryObject)

        self.context.add_content(content)

        self.request.registry.notify(
            TemporaryObjectCreated(content, self.request))

        return HTTPFound(location='%sedit' %
                         self.request.resource_url(content))
    def __init__(self, context, request):

        BaseView.__init__(self, context, request)

        ctype = request.params.get("ctype", None)

        clazz = Registry.get(ctype)

        tmp_obj = clazz("TMP")

        form = tmp_obj.__form__(request)

        # note: If you want to prefill the formdata, you can use
        # the __form__ override, or if in pycms, use the IFormModifier

        pyramidformview.__init__(self, context, request,
                                 form,
                                 retrieve_data=False)

        self.ctype = ctype
        self.clazz = clazz