<%global> import string, re <%method user> <%init> return m.get_session().get('user', None) <%method securehref> <%args> href action <%init> user = m.get_session().get('user', None) % if action.access(user, **ARGS): <% m.content() %> % else: <% m.content() %> % <%method entryform> <%args> name=None action=None onsubmit=None ajaxtarget=None form=None <%init> if form is not None: name = form.name m.attributes[(self.owner.id, 'form')] = form if ajaxtarget is not None: onsubmit = m.comp("SELF:ajaxaction", target=ajaxtarget, form=form, name=name) + ";return false;"
<&|SELF:fields&> <% m.content() %>
<%cleanup> try: del m.attributes[(self.owner.id, 'form')] except KeyError: pass <%method ajaxaction> <%args> target form=None name=None <%init> if form is not None: if name is None: name = form.name formargs = m.scomp('SELF:formargs', form=form) else: formargs = '' return target + "(%s)" % formargs <%method formargs trim="both"> <%args> form name=None getargs(document.<% name or form.name %>, <% string.join(["'%s'" % f.displayname for f in form], ',') %>) <%method fields> <% m.content() %>
<%method field> <%args> type name=None field=None <%init> label = m.content() if field is None: form = m.attributes.get((self.owner.id, 'form'), None) if form is not None and name: field = form.get(name, None) if field is not None: ARGS['name'] = field.displayname ARGS.setdefault('value', field.display) ARGS['data'] = field.data ARGS['field'] = field else: if name is not None: ARGS.setdefault('value', m.root_request_args.get(name, None)) component = m.fetch_component("SELF:%s" % type) % if component.attributes.get('hidden', False) or not label: <% m.comp(component, **ARGS) %> % else: <% label %> <%python>m.comp(component, **ARGS) % if field is not None: <& /form:fieldstatus, field=field &> % % <%method row> <%args> colspan=None > <% m.content() %> <%method text> <%args> size=20 name value <%method password> <%args> size=20 name value <%method textarea> <%args> rows=5 cols=50 name value <%method hidden> <%args> name=None value <%attr> hidden=True <%method dropdown> <%args> name data=() onselect=None value=None <%method submit> <%args> value <%method button> <%args> value onclick > <%method popup> <%args> name
<% m.content() %>
<%method confirm> <%args> yes no
<% m.content() %>
<&/components:field, type="button", value="Yes", onclick=yes &> <&/components:field, type="button", value="No", onclick=no &>