[Zope3-dev] Re: Zope3/src/zope/app/browser/skins/debug/exceptions.py:1.1
Jim Fulton
jim@zope.com
Wed, 12 Mar 2003 09:51:22 -0500
Steve Alexander wrote:
...
>>> The query:
>>>
>>> I'm pretty sure that __used_for__ has been a single interface,
>>> not a tuple of interfaces. Was there a particular reason you used
>>> a tuple?
>>
>>
>> Nope. I think I saw it that way someplace, but could be wrong. I
>> thought of it as syntactically similar to __implements__.
>
>
> Good point. I guess this should be reevaluated when the new interfaces
> proposal is implemented.
__used_for__ should be a single interface. Allowing multiple interfaces
here would also require that adapters and view me registered for multiple
interfaces. This would complicate lots of things. I really don't want to
go there unless there is a really compelling need.
>
>>> Classes in Zope 3 should usually be new-style classes rather
>>> than classic classes. This is usually done using
>>>
>>> __metaclass__ = type
>>>
>>> at the module level.
>>>
>>> This is important for views, as the code that sets up views from zcml
>>> directives sometimes does some fancy things that only work properly
>>> with new-style classes.
>>
>>
>>
>> Cool. I've seen that, but didn't know when / why to follow suit.
>
>
> As a rule, whenever the module contains classes that don't derive from
> other classes.
IMO, this is a matter of taste.
I personally, have come to dislike inheritance. I somehow find it
more satisfying to see:
class C:
....
rather than:
class C(object):
which seems redundant to me, as all classes should be new-style classes.
I don't feel very strongly about this.
>
>> I hadn't considered that the module was doing anything testable, and was
>> looking at the content of the other two skin directories when I built
>> 'debug'. Neither of '{rotterdam,zopetop}/standardmacros.py' has tests
>> (but they don't do much interesting, either).
>
>
> The rotterdam/standardmacros.py and zopetop/standardmacros.py should
> have a minimal unit test.
>
> A typical scenario is:
>
> * Joe Developer corrects a typo in a comment in standardmacros.py
>
> * Unfortunately, his finger slips and he introduces a syntax error,
> or deletes a name from a variable, without realising it
>
> * Joe runs all the unit tests before checking in with no problems
>
> * Joe also starts up Zope, and it seems to work and render some
> basic pages in the browser
>
> * Joe checks in the broken code
>
> Actually, because these classes are refered to in zcml, the 'functional'
> test of starting up Zope should catch any syntax errors. However,
> unplanned changes in variable names would still slip through.
>
> Have I made a good enough case to persuade the zopetop/rotterdam
> maintainers to add a unit test? ;-)
>
> If they're too busy just now, they let me know and I'll write the tests.
We *really* need a functional testing framework.
I'm going to try to make this a priority soon.
Jim
--
Jim Fulton mailto:jim@zope.com Python Powered!
CTO (888) 344-4332 http://www.python.org
Zope Corporation http://www.zope.com http://www.zope.org