Design: Idiom for classes and methods that are customizable by the user?
dieter
dieter at handshake.de
Fri May 13 03:21:56 EDT 2016
Dirk Bächle <tshortik at gmx.de> writes:
> ...
> My questions
> ============
>
> - Is this a good approach, that I could use for other parts of the architecture as well, e.g. the Node class mentioned above?
You might look at the "adpater" pattern.
It is heavily used in Zope - and there looks something like:
* components are abstracted by interfaces (--> "zope.interface")
* where flexibility is needed, the code looks like
component = queryAdapter(<context>, interface, default=...)
or
component = queryUtility(interface, default=...)
to get a component implementing "interface".
(utilities are in some way adapters for "None", i.e.
those independent of a context)
* there is an adapter registry,
its content is specified either via an XML specification file
or via Python code
More information about the Python-list
mailing list