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