returning fresh instance of the main published class on every request

Ksenia Marasanova <[email protected]>
Newsgroups gmane.comp.web.quixote.user
Message-ID <[email protected]>
Hi,

I am sorry to say that this is Qx1 question, but maybe somebody can advise....

Would it be possible, in SCGI environment, somehow to return fresh
instance of the main published class, every time the base url / is
requested? The problem is that I have this class:

class Tree:
    _q_exports = []
    def __init__(self, page_id=None):
        if page_id is None:
            page_id = getHomepage()
        self.page_id = page_id

    def _q_index(self, request):
        return "I am page %d" % self.page_id

    def _q_lookup(self, request, name):
        return Tree(name)

that SCGI application uses as a main class mounted to "/".

My understanding is that when "/mypage/" is requested, _q_lookup is
called, the Tree instance is created that is unique for that
particular request. But the main Tree instance is initialized only
once, when application is started, so requesting "/" returns the same
tree instance for *all* requests (inside one SCGI process).
The problem here is that one application will serve multiple sites,
and homepage is different for all of them, depending on hostname and
such. I'd prefer not to redirect people to "/homepage/", which will
solve it, I guess. Another workaround is to reset all variables of the
main tree in every published method, but I was hoping maybe there is a
better solution.

Thanks,
--
Ksenia
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.