05e19286370da1d55314aff89f7268be2e5dd4e7
1 ##parameters=allow_discussion=None, title=None, subject=None, description=None, contributors=None, effective_date=None, expiration_date=None, format=None, language=None, rights=None, ajax='', **kw
3 from Products
.CMFCore
.utils
import getToolByName
4 from Products
.CMFDefault
.exceptions
import ResourceLockedError
6 dtool
= getToolByName(script
, 'portal_discussion')
10 if not same_type( value
, () ):
11 value
= tuple( value
)
13 temp
= filter( None, value
)
17 title
= context
.Title()
20 subject
= context
.Subject()
22 subject
= tuplify( subject
)
24 if description
is None:
25 description
= context
.Description()
27 if contributors
is None:
28 contributors
= context
.Contributors()
30 contributors
= tuplify( contributors
)
32 if effective_date
is None:
33 effective_date
= context
.effective()
35 if dict(effective_date
) == {'year':'1969', 'month':'12', 'day':'31', 'hour':'00', 'minute':'00'} :
38 effective_date
= '%(year)s/%(month)s/%(day)s %(hour)s:%(minute)s' % effective_date
40 if expiration_date
is None:
41 expiration_date
= context
.expires()
43 expiration_date
= '%(year)s/%(month)s/%(day)s %(hour)s:%(minute)s' % expiration_date
47 format
= context
.Format()
50 language
= context
.Language()
53 rights
= context
.Rights()
55 if allow_discussion
is not None :
56 if allow_discussion
== 'default':
57 allow_discussion
= None
58 if allow_discussion
== 'off':
59 allow_discussion
= False
60 elif allow_discussion
== 'on':
61 allow_discussion
= True
62 dtool
.overrideDiscussionFor(context
, allow_discussion
)
65 context
.editMetadata( title
=title
66 , description
=description
68 , contributors
=contributors
69 , effective_date
=effective_date
70 , expiration_date
=expiration_date
75 if ajax
: return '...'
76 context
.setStatus(True, 'Metadata changed.')
77 return context
.setRedirect(context
, 'object/edit')
78 except ResourceLockedError
, errmsg
: