[Zope] Obj created in ExtMethod give "not allowed to use in this context"
Joel Burton
joel@joelburton.com
Fri, 26 Jul 2002 16:55:29 -0400
This is a multi-part message in MIME format.
------=_NextPart_000_005F_01C234C5.3F378500
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Dear all:
I have an External Method that creates a Formulator BasicForm on the fly and
returns it to a calling PageTemplate:
from Products.Formulator import Form
def make_form(self, origform, addlist):
"""Make form on the fly"""
nf = Form.BasicForm()
nf.add_fields( [ field
for field in origform.get_fields()
if field.getId() in addlist ] )
return nf
This seems to work fine -- If I run the ExternalMethod, it returns a
<Formulator.BasicForm> object.
My ZPT calls this using tal:define, and sets it to a variable:
<div tal:define="form python:here.MakeForm(here.LuachServiceListingForm,
here.AddList());">
This runs without error.
However, if I try to call any of the usual method calls on the new form
object, I get the error that "You are not allowed to access get_groups in
this context" (get_groups is a standard method for a Formulator form).
(Alternatively: the goal of all this is to be able to have one Formulator
form with many widgets defined, only some of which are needed for particular
forms. Rather than maintaining 15 different Formulator form objects with
largely overlapping stuff--ick--I'm hoping to use this technique to create a
Just-In-Time Formulator form and use that. If anyone can think of a better
way to do this, that would be great.)
I'm under a bit of time pressure here, so as much as I normally like to
explore my way to a solution, I'd appreciate a good nudge in the right
direction ASAP. Thanks!
- J.
--
Joel BURTON | joel@joelburton | www.joelburton.com | aim:wjoelburton
Information Technology & Knowledge Management Consultant
------=_NextPart_000_005F_01C234C5.3F378500
Content-Type: text/x-vcard;
name="Joel Burton.vcf"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="Joel Burton.vcf"
BEGIN:VCARD
VERSION:2.1
N:Burton;Joel
FN:Joel Burton
ORG:Joel Burton & Associates
TITLE:Principal
TEL;WORK;VOICE:(202) 483-7168
TEL;HOME;VOICE:(202) 483-7168
TEL;CELL;VOICE:(202) 251-4877
ADR;WORK:;;1705 P St NW #43;Washington;DC;20036;United States of America
LABEL;WORK;ENCODING=3DQUOTED-PRINTABLE:1705 P St NW =
#43=3D0D=3D0AWashington, DC 20036=3D0D=3D0AUnited States of America
ADR;HOME:;;1705 P St NW #43;Washington;DC;20036;United States of America
LABEL;HOME;ENCODING=3DQUOTED-PRINTABLE:1705 P St NW =
#43=3D0D=3D0AWashington, DC 20036=3D0D=3D0AUnited States of America
URL;WORK:http://joelburton.com
ROLE:Information Technology
BDAY:19721012
EMAIL;PREF;INTERNET:joel@joelburton.com
REV:20011203T044543Z
END:VCARD
------=_NextPart_000_005F_01C234C5.3F378500--