Last change
on this file since 1591 was
1,
checked in by myroslav, 19 years ago
|
Building directory structure
|
File size:
1.0 KB
|
Line | |
---|
1 | ## Controller Script Python "validate_talkback" |
---|
2 | ##bind container=container |
---|
3 | ##bind context=context |
---|
4 | ##bind namespace= |
---|
5 | ##bind script=script |
---|
6 | ##bind state=state |
---|
7 | ##bind subpath=traverse_subpath |
---|
8 | ##parameters=subject='',body_text='' |
---|
9 | ##title=validates a discussion entry |
---|
10 | |
---|
11 | from Products.CMFCore.utils import getToolByName |
---|
12 | |
---|
13 | if not subject: |
---|
14 | state.setError('subject', 'Please submit a subject.', 'subject_required') |
---|
15 | |
---|
16 | if not body_text: |
---|
17 | state.setError('body_text', 'Please submit a body.', 'body_required') |
---|
18 | |
---|
19 | |
---|
20 | isForAnonymous = context.isForAnonymous() |
---|
21 | if isForAnonymous: |
---|
22 | pm = getToolByName(context, 'portal_membership') |
---|
23 | isAnonym = pm.isAnonymousUser() |
---|
24 | if isAnonym: |
---|
25 | req = context.REQUEST |
---|
26 | if not (req.form.has_key('Creator') and not req.form['Creator'] == ""): |
---|
27 | state.setError('Creator', 'Please submit a Name.', 'name_required') |
---|
28 | |
---|
29 | if state.getErrors(): |
---|
30 | return state.set(status='failure', portal_status_message='Please correct the indicated errors.') |
---|
31 | else: |
---|
32 | return state |
---|
Note: See
TracBrowser
for help on using the repository browser.