Configurable Components
context = Zope component architecture... (Component Software)
Jeffrey P Shell on an architecture to give you Zope v3-ish Configurable Components in v2.
-
First, I knew that I needed Formulator on my side, but wanted to define my forms in Python Code rather than through the web. Basically, I wanted a way of describing configuration properties that was closer to Zope 3 Schema's than to Zope 2's usable but not as expressive Property Manager system. Snooping around Formulator's CVS tree, I finally came across Formulator Demo Product, a rudimentary Zope 2 product that shows a way of using Formulator with Python based product code.
-
Using Formulator Demo Product as a base example, I came up with a small persistent object called "Configuration", that took a list of Formulator Fields as an argument. This set of fields is used, like in the demo product code, to update a dictionary (Persistent Mapping in my case) upon successful validation of the form data.
-
some code as example of configuration definition
-
Next, Configuration Holder comes into play as the base class for the service objects that will be replacing certain folders in the system that contain nothing but scripts and SQL methods.
-
Since all of this is built purely out of descriptions, adding new configurations and configuration holders should be relatively easy.
-
Finally, there's the business and data access logic itself. (currently in lots of Python Script pieces)
-
I've done some refactoring in script land already - about as much as can be sanely done - by keeping the scripts that actually respond to HTTP requests small handlers that call into the larger "common" scripts.
-
Now these scripts are being taken apart using common refactoring techniques such as Extract Method to be applied. (and the code is moved to external python modules)
-
And then, like the little handlers on the public side of the site, the Configuration Holder becomes a simple front end, or Facade to the complex business object behind it
-
Next stop - XML import/export of configurations so that the different component configurations for customers can be tracked by the SCM process (such as it is).
Edited: | Tweet this! | Search Twitter for discussion
No twinpages!