source: trunk/skins/lemill/content_edit.cpy @ 3076

Revision 3076, 2.0 KB checked in by jukka, 9 years ago (diff)

Portfolio for groups is working, starting to remove debugging prints.

Line 
1## Script (Python) "content_edit"
2##title=Edit content
3##bind container=container
4##bind context=context
5##bind namespace=
6##bind script=script
7##bind state=state
8##bind subpath=traverse_subpath
9##parameters=id=''
10##
11REQUEST = context.REQUEST
12
13### This is greatly simplified version of Archetypes/skins/archetypes/content_edit_impl.py
14
15# Removed features:
16# * state-based portal status messages (we should use only plone_tool-based ones.
17# * multi-page edit forms. (we have manual navigation to these)
18# * support for references. (we don't use plone's reference widgets)
19# * mysterious current-lang thingy
20
21# Basically only thing left is to do processForm() and shout about errors.
22
23# Checked, this is ok, doesn't take much time.
24try:
25    new_context = context.portal_factory.doCreate(context, id)
26except AttributeError:
27    # Fallback for AT + plain CMF where we don't have a portal_factory
28    new_context = context
29new_context.processForm()
30
31if not state.errors:
32    from Products.Archetypes import transaction_note
33    transaction_note('Edited %s %s at %s' % (new_context.meta_type,
34                                             new_context.title_or_id(),
35                                             new_context.absolute_url()))
36if REQUEST.form.get('stay',0):
37    edit = REQUEST.form.get('chapter_edited',-1)
38    anchor = REQUEST.form.get('chapter_anchor',0)
39    return state.set(next_action='redirect_to:string:edit?chapter_edited=%s#%s' % (edit, anchor), status='stay', context=new_context)
40
41if state.errors:
42    errors = state.errors
43    s_items = [(s, schemata[s].keys()) for s in schemata.keys()]
44    fields = []
45    for s, f_names in s_items:
46        for f_name in f_names:
47            fields.append((s, f_name))
48    for s_name, f_name in fields:
49        if errors.has_key(f_name):
50            REQUEST.set('fieldset', s_name)
51            return state.set(
52                status='failure',
53                context=new_context)
54
55# XXX disabled mark creation flag
56#context.remove_creation_mark(old_id)
57
58
59return state.set(status='success', context=new_context)
Note: See TracBrowser for help on using the repository browser.