[Zope] object instance from script

Steven Hayles sh23@leicester.ac.uk
Fri, 4 Jul 2003 10:06:56 +0100 (BST)


Maybe this will help
  http://www.zopelabs.com/cookbook/1012279676

Steven Hayles - Computer Systems Developer, sh23@le.ac.uk
Learning Technology Section, Computer Centre,=20
University of Leicester, University Rd, Leicester, LE1 7RH=20
Fax (0/+44)116 2525027 WWW <URL:http://www.le.ac.uk/home/sh23>

On 3 Jul 2003, [ISO-8859-1] Aur=E9lien Camp=E9as wrote:

> I apologize in advance if this is some kind of FAQ,
>=20
> nervertheless, here's my quesion :
>=20
> I build some simple Product some days ago. It's accessible from the ZMI
> and works as expected.
>=20
> However, I really need it to be instanciated not from the ZMI but from
> one python script.
>=20
> The exact course of action remains quite unclear, even after reading
> huge amounts of various docs.
>=20
>=20
> The products is 'Candidat'.
>=20
> Here's what I put in some dumb script :
>=20
> print "Hello from build_candidat"
>=20
> cand =3D context.manage_addProduct['Candidat']
> try:
>  one_c =3D cand ("M", "A", "B", "add", "mail", "bp", "ville", "tel", "cv"=
,
> "motiv")
> except Exception, e:
>  print e
> print cand
>=20
> return printed
>=20
>=20
> when executed, I get this :
>=20
> Hello from build_candidat
> __call__
> <__FactoryDispatcher__ instance at 9089dc0>
>=20
>=20
> No comment about 1st line.
> Second line is the exception ('cand' not callable ???)
> Third line tells us about what is 'cand'.
>=20
> I'm sure there's something simple to do around those lines, but it's a
> little bit hard to find the right info...
>=20
> Thank you for your patience,
> Aur=E9lien.
>=20
>=20
>=20
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -=20
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )
>=20