[Zope3-dev] Re: ObjectHub

Steve Alexander steve@cat-box.net
Sat, 07 Dec 2002 13:47:16 +0000


> To new proposal:
> 
>  > For another example:
>  >
>  >   newly_registered_count = 0
>  >   for wrapped_object in iteratorOfSomeObjectHierarchy():
>  >       hubid, isregistered = hub.register(wrapped_object)
>  >       newly_registered_count += isregistered  # True == 1, False == 0
>  >   print "I registered %s additional objects" % newly_registered_count
> 
> ...I suppose.  +0.  That's a reasonable use case, but I don't care for 
> the return signature that much, and the code above doing a try-except 
> instead isn't that much uglier.

Can you explain what you want in terms of the Requirements for the 
'register' method that I posted?

Here they are again:

* Postcondition: the given object's location is registered

* If the postcondition cannot be met, you get an exception

   Otherwise...

* You want to know the hubid of the registration

* You want to know whether registration did any work


I'd like to start by finding out if the requirements for this method are 
reasonable. Then, we can move on to think about how we spell it.


>  > There's a similar issue with 'unregister': it raises a NotFoundError if
>  > the object/location is not registered.
>  >
>  > We can change 'unregister' to return a bool. This is fine, as it
>  > currently does not return anything meaningful.
> 
> +.5: if the change above is implemented,, +1, and if not, -0.

I'm drawing on experience from the Zope2 ZCatalog here: raising an 
exception for unregistering an object twice isn't all that helpful. The 
second unregistration isn't harmful. If you want to log this as an 
warning, the application method that calls 'unregister' can do that.

--
Steve Alexander