[SQLObject] Re: SQLObject & Webware FormKit Integration
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: David B. <db...@fi...> - 2004-01-13 16:50:16
|
"Ian Sparks" <Ian...@et...> writes:
> I really meant that Interfaces mean its no longer enough to create a
> class. I now need to create an Interface "prototype" and then
> classes that implement that Interface. One of the great things about
> Python (for me) is that you can say "Does it quack? Ok, lets assume
> its a duck" without a lot of rigmarole. I'm probably showing my
> (deep) ignorance but the whole Interfaces thing seems to be putting
> the rigmarole back in.
What I find attractive about PyProtocols (and probably the others) is
that you still get the "Does it quack?" approach, but you do so with a
single adaptation call ("adapt" with PyProtocols"). And that's an
often discussed topic in the Python arena - just how do you ask "Does
it quack?"
So you don't have to attempt random calls into the object. When you
couple that with the fact that you can externally adapt or register
that an object supports an interface, and it's really a very dynamic
way to handle well-defined interfaces.
The typing really isn't that much. Yes, you need to define an
interface, but to be honest, you should be doing that anyway as a way
of documenting the "duck" that your object expects.
In terms of the classes itself, if you use the abstract-base-case
approach to your interface, just inherit from it for your class. Or,
for any class, just add an "advise(instancesProvide=[XXXX]))" call in
your class to say it provides interface XXXX. Or, you can indicate
your object supports an interface from the "outside" without ever
touching your object code (or register an adapter to take an existing
object and wrap it to conform to the interface).
And in the end, nothing is hard-enforced. Any class can claim to
support an interface without really doing so, and you can be in
precisely the same state as now as if you hadn't claimed that fact but
just used the object.
-- David
|