[Twisted-Python] Woven using wrong model adapter

Kevin Turner acapnotic at twistedmatrix.com
Mon May 26 23:02:51 MDT 2003


On Mon, 2003-05-26 at 18:37, Christopher Armstrong wrote:
> > So why does woven persist in using the StringModel adapter in this case,
> > and how can I get it to stop?
> 
> IIRC, A workaround is to [...] 2) call self.invalidateCache() every 
> time the result of the conditional changes (or just on every request, if you
> don't care)

Model.invalidateCache is not what's needed here.  It turns out that when
that cache gets stale (either through explicit invalidateCache or just a
new Request), Model.getData will update the model data in
Model.original...  but it only swaps out the Model.original attribute,
it doesn't replace the Model with a new Model adapter for the new data. 
Which is how I was getting my FooReport instances ending up inside a
StringModel adapter.

What I've done now is, in Page.request: del self.submodels["report"]
This makes sure that old model adapters never hang around.  It also
smells bad.

Am I violating some unwritten contract here which says "a model factory
must always return models with the same interface"?

-- 
The moon is waning crescent, 15.6% illuminated, 25.7 days old.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: </pipermail/twisted-python/attachments/20030526/f10b43d2/attachment.sig>


More information about the Twisted-Python mailing list