[Zope] creating ZClasses with external method

Alex Rice alrice@swcp.com
Sun, 4 Jul 1999 17:55:14 -0600 (MDT)


I still cannot create ZClasses with an external method (using
aquisition) Since I can do it with ZPublisher.Client and by typing in a
URL into my browser, but not via an external method, this is really
seeming like a bug. Should I report this to Collector?

For instance, I can do it this way:

>>> from ZPublisher.Client import Function
>>> f = Function('http://localhost/zope2/alex/manage_addProduct/Foo/foo?id=hello', method='GET', username='...', password='...')
>>> apply(f)

I now have successfully created a foo type ZClass named 'hello' in the
Folder alex/. I also get a 302 http error back from apply(), so is this
is not the correct way to be programatically creating ZClasses? What is
the recommendeed way?

But cannot do it this way. If I create an external method with one line
like so:

def hello(self):
	self.manage_addProduct.Foo.foo(id='helloworld')

Now if I visit http://localhost/zope2/alex/hello

I get Error Type: AttributeError Error Value: Foo

Traceback (innermost last):
  File /usr/share/Zope-2.0.0a3-src/lib/python/ZPublisher/Publish.py,
line 256, in publish_module
  File /usr/share/Zope-2.0.0a3-src/lib/python/ZPublisher/Publish.py,
line 161, in publish
  File /usr/share/Zope-2.0.0a3-src/lib/python/ZPublisher/mapply.py, line
154, in mapply
    (Object: hello)
  File /usr/share/Zope-2.0.0a3-src/lib/python/ZPublisher/Publish.py,
line 98, in call_object
    (Object: hello)
  File
/usr/share/Zope-2.0.0a3-src/lib/python/Products/ExternalMethod/ExternalMethod.py,
line 259, in __call__
    (Object: hello)
    (Info: ((<Application instance at 81c0cd0>,), {}, None))
  File
/usr/share/Zope-2.0.0a3-src/lib/python/Products/ExternalMethod/ExternalMethod.py,
line 247, in __call__
    (Object: hello)
    (Info: ((<Application instance at 81c0cd0>,), {}, None))
  File /usr/share/zope/Extensions/hai.py, line 9, in hai
    (Object: ApplicationDefaultPermissions)
AttributeError: (see above)

Alex Rice    |    alrice@swcp.com    |    http://www.swcp.com/~alrice
    Current Location: N. Rio Grande Bioregion, Southwestern USA