[Twisted-web] [PATCH] Are we ready for a Page.remember fix?

Matt Goodall matt at pollenation.net
Tue Nov 23 04:37:40 MST 2004


> This was suggested a long time ago, and when I tried adding it, I broke
> Quotient somewhat badly. From what I can tell, the problem in Quotient
> which
> prevented Page.remember from being changed has been fixed; I'd like to see
> this patch added.
>
> Some have suggested a SiteContext as an alternative; however, I see these
> two as addressing two different concerns. A SiteContext (as described in
> Roundup <http://divmod.org/users/roundup.twistd/nevow/issue137>) would be
> good for remembering data that are universal to a specific NevowSite
> instance. However, this is not my use case.

Yes, remembering on the site vs page have quite different uses.

>
> In my case, I want my Realm to be able to remember objects that are
> particular to a certain logged in user. The obvious example is an
> ICurrentUser interface, which lets the resource hierarchy quickly
> reference
> what user (if any) is logged in. I'm sure I'll come up with other uses,
> but
> this is my current need. Doing this at the SiteContext level would (from
> what I can tell) produce overlaps when more than one user is logged in.

This is a common usecase and definitely not something to remember in the
site's context.

I have implemented this using a resource wrapper but that is somewhat
complex for what it's actually doing.

>
> So, are there any objections to Page.remember()? Even if it's not an
> elegant
> solution, it works for me, and it's generic enough that I think it's worth
> keeping.

For some reason I've never liked Page.remember() even though I would
probably use it if it existed (and worked properly).

So, a reluctant +1 from me.

There's one problem with the patch - once the PageContext has been created
Page.remember() doesn't do anything. The Page *used* to have a context set
via a property but that's been gone for a while now. Any ideas how to fix
that?

Perhaps the solution is to change the method name to something more in
line with what it's doing, i.e. addToRemember, rememberLater, etc, and
update the docstring to explain.

Cheers, Matt

-- 
     __
    /  \__     Matt Goodall, Pollenation Internet Ltd
    \__/  \    w: http://www.pollenation.net
  __/  \__/    e: matt at pollenation.net
 /  \__/  \    t: +44 (0)113 2252500
 \__/  \__/
 /  \          Any views expressed are my own and do not necessarily
 \__/          reflect the views of my employer.




More information about the Twisted-web mailing list