[Zope3-dev] Re: Keening for the poultry

jürgen Kartnaller j.kartnaller at cable.vol.at
Thu Oct 13 12:53:17 EDT 2005


Hi Tres.

I just want to show you what I have so far.
See the attached test file.

I took me really a lot of time to figure out all these things.
Currently I'm at a point where the view is missing the activeTool which
is set up in __init__.

How should a zope rookie be able to write such a test if the zope pro
gives up :)

Jürgen


Tres Seaver wrote:
> I have been trying to write a doctest for the "tools" stuff to show
> Jürgen Kartnaller how[1], so he could write a test for the bug he found
> in tool deletion[2].
> 
> While writing the test, I found myself mourning for the huge flock of
> assorted fowl I was slaughtering, trying to get the planets aligned[3]
> so that the SiteManagerView could actually install a tool implmentation.

Hugh, this sentence really needs a dictionary for a non native english
speaker :)

> 
> I have finally given up, and ask abjectly for elightenment from the
> hierarchs of Z3.  Please see the attached doctest and setup code for my
> efforts so far,
> 
> [1] http://article.gmane.org/gmane.comp.web.zope.zope3/14477
> 
> [2] http://article.gmane.org/gmane.comp.web.zope.zope3/14459
> 
> [3] No, I'm not mixing metaphors:  the ritual slaughter is precisely
>     intended to cause the planets to realign themselves.
> 
> Removing-bloody-apron-and-picking-down-out-of-my-ears'ly,
> 
> 
> Tres.
> --
> ===================================================================
> Tres Seaver          +1 202-558-7113          tseaver at palladion.com
> Palladion Software   "Excellence by Design"    http://palladion.com
-------------- next part --------------
==============
The Tools View
==============

  >>> from zope.app import zapi
  >>> from zope.app.component.browser.tools import SiteManagementView
  >>> from zope import interface

  >>> class IFooUtil(interface.Interface):
  ...     pass
  >>> class FooUtil(object):
  ...     interface.implements(IFooUtil)

  >>> from zope.component.interfaces import IFactory
  >>> from zope.component.factory import Factory
  >>> from zope import component

  >>> from zope.app.security import protectclass
  >>> protectclass.protectName(Factory, '__call__', 'zope.public')

  >>> factory = Factory(FooUtil, 
  ...                   'Utility for foo',
  ...                   'This factory creates a foo utility.')
  >>> component.provideUtility(factory, IFactory, 'IFooUtil')

  >>> from zope.publisher.browser import TestRequest
  >>> request = TestRequest()

  >>> view = SiteManagementView('context', request)
  >>> view.getTools()
  []
  >>> view.update()
  u''
  >>> request.form['ADD-TOOL-SUBMIT']='submit'
  >>> request.form['type_name']='IFooUtil'
  >>> request.form['id']='foo1'
  >>> view.update()

  >>> component.getUtility(IFooUtil, 'foo1') is not None
  True



More information about the Zope3-dev mailing list