Hi all -
Well, we've identified a few things that are merely
'irritations' at this point, but will become serious
trouble for our use of SQLObject in the future.
First problem: The inability of classRegistry/needSet to
import classes that aren't explicitly imported. For
example, if we have three classes "ProductSaved", "Product"
and "ProductType", and we're only dealing with
"ProductSaved" instances in a given class, accessing
"savedProductInstance.product.type" throws an exception (no
attribute _SO_class_ProductType), because ProductType is
not imported by either ProductSaved or Product (just
referenced by name as a foreignKey in Product).
Is the best solution to this just to do an import of all
classes referred to in a class (even if just by name) in
the class file? ie, Product would import ProductType? This
seems to be working for us, but should probably be
explicitly mentioned in the docs if it's the best way.
(Yes, I know such access breaks Law of Demeter or whatever,
but I believe the above example is a fairly reasonable one.
:)
Second problem, and one I don't have a solution for right
now: the interpreter-global uniqueness required of class
names for classRegistry. We don't run many instances of
Webware/Webkit for multiple sites, just run them as
multiple contexts. This makes two sites who have separate
"Product" objects conflict, but it seems to be a very
realistic problem...
Possible high-level solutions I can think of right now:
making class registry be keyed by the class modules'
__file__ attribute or similar (not fully thought through, I
realize this won't work because of needSet's now-ambiguous
names....)
Or having the ability to create specific classRegistrys,
sort of like having multiple object Stores. Haven't fully
thought this through, but my first thought is to simply add
another class-level or module-level attribute called
"_registry". The SQLObject classRegistry/needset would now
become dictionaries of dicationaries/lists, with a default
registry key called perhaps "__global" or some other
unlikely name. So needSet/setNeedSet would check the class
for the _registry variable, and search within the specified
sub-keyed areas only.
Not sure I explained that too well. classRegistry would now
look like (for my multiple Product example):
{
'__global': {},
'site1': {'Product': ...},
'site2': {'Product': ...}
}
based on the two Product classes specifying site1 or site2
as their registry.
Thoughts?
- Luke
|