2 from Products
.Plinn
.utils
import makeValidId
3 form
= context
.REQUEST
.form
4 from Products
.CMFCore
.utils
import getToolByName
5 handler
= getToolByName(context
, 'portal_uidhandler')
9 if hasattr(item
, 'keys') and item
.has_key('type') :
14 if typeDic
.has_key('id') :
16 newid
= makeValidId(context
, title
)
18 context
.invokeFactory( typeDic
['type'], newid
, title
=title
)
19 newOb
= getattr(context
, newid
)
20 handler
= getToolByName(context
, 'portal_uidhandler')
21 handler
.register(newOb
)
22 ti
= newOb
.getTypeInfo()
23 immediate_view
= ti
.immediate_view
25 if immediate_view
.find('/') > 0 :
26 newOb
.setStatus('True', 'Object created.')
27 return newOb
.setRedirect(newOb
, immediate_view
, syncFragments
= ['Breadcrumbs', 'rightCell'], **form
)
29 from ZTUtils
import make_query
30 ob_url
= newOb
.absolute_url()
31 query
= make_query(portal_status_message
= 'Object created.', ajax
= form
.get('ajax'), syncFragments
= ['Breadcrumbs', 'rightCell'])
32 url
= "%s/%s?%s" % (ob_url
, immediate_view
, query
)
33 response
= context
.REQUEST
.RESPONSE
34 return response
.redirect(url
)
36 elif typeDic
.has_key('create_form') :
37 from Products
.CMFCore
.utils
import getToolByName
38 ttool
= getToolByName(context
, 'portal_types')
39 typeName
= typeDic
['type']
40 ti
= getattr(ttool
, typeName
)
41 ai
= ti
.getActionInfo('object/create', object=context
)
44 from ZTUtils
import make_query
45 query
= make_query(ajax
=form
.get('ajax'))
46 url
= '%s?%s' % (url
, query
)
47 response
= context
.REQUEST
.RESPONSE
48 return response
.redirect(url
)