[Twisted-Python] submodel caching in woven

Michael Shyne devmail at crazydiamonds.com
Sat Jul 26 18:22:37 MDT 2003


I'm trying to create a web-app in woven using already existing data
objects.  I'm starting by just trying to display a name.  This is what
I've done:

components.registerAdapter(model.ObjectWrapper, myObj, interfaces.IModel)
class DisplayObj(page.Page):

    templateFile = "display-obj.html"

    def wmfactory_obj(self, request):
        id = request.args.get('id', (0,))[0]

        if id:
            return objFactory.getObj(id)

        return None

The template only referes to "obj/name".  This all works fine... except
when I change the id in the URL and reload the page.  The name displayed
doesn't change.  The problem is with the submodel caching in the root
model (the page).  I've attached the changes I made to fix it.  I'm new to
woven (and twisted in general) so I don't know if I'm doing something
wrong, or if my changes have far-reaching effects.

I should note that these changes merely improved the situation to mostly
working (which, of course, is much better than never working).  The
caching is keyed off of "id(request)".  However, it seems there is object
caching occuring with the request objects, "id(request)" often returns
identical results.  I believe that the submodel caching will also have to
look at a timestamp to work consistently.  This was too big of a change to
make at this point.  But if the list agrees with my current changes and
thinks adding a timestamp comparison is the right way to go, I would be
more than happy to do it.

-Michael Shyne

-------------- next part --------------
A non-text attachment was scrubbed...
Name: model.diff
Type: application/octet-stream
Size: 607 bytes
Desc: not available
URL: </pipermail/twisted-python/attachments/20030726/1966f68a/attachment-0002.obj>


More information about the Twisted-Python mailing list