%global>
import string, re
%global>
<%method user>
<%init>
return m.get_session().get('user', None)
%init>
%method>
<%method securehref>
<%args>
href
action
%args>
<%init>
user = m.get_session().get('user', None)
%init>
% if action.access(user, **ARGS):
<% m.content() %>
% else:
<% m.content() %>
%
%method>
<%method entryform>
<%args>
name=None
action=None
onsubmit=None
ajaxtarget=None
form=None
%args>
<%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;"
%init>
<%cleanup>
try:
del m.attributes[(self.owner.id, 'form')]
except KeyError:
pass
%cleanup>
%method>
<%method ajaxaction>
<%args>
target
form=None
name=None
%args>
<%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
%init>
%method>
<%method formargs trim="both">
<%args>
form
name=None
%args>
getargs(document.<% name or form.name %>, <% string.join(["'%s'" % f.displayname for f in form], ',') %>)
%method>
<%method fields>
<% m.content() %>
%method>
<%method field>
<%args>
type
name=None
field=None
%args>
<%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)
%init>
% if component.attributes.get('hidden', False) or not label:
<% m.comp(component, **ARGS) %>
% else:
<% label %>
<%python>m.comp(component, **ARGS)%python>
% if field is not None:
<& /form:fieldstatus, field=field &>
%