Hello,
I'd like to use a python class instances in _q_exports
but can't figure out how to do the class _init_ at the
appropriate times.
Basically I want something like
_q_exports = ['someclassinstance']
someclassinstance = someclass('foo')
But where someclassinstance.__init__(self, 'foo') is
run each time someclassinstance is accessed.  In the
code fragment above someclass._init('foo') is only run
once at startup / module import.
The common approach seems to be to *not* use
_q_exports but rather to use _q_lookup to return a
fresh someclass instance.
Another approach is to make someclassinstance global
and put the initialization in _q_access but this is a
hack because 'someclassinstance' may not be accessed -
so why go ahead and initialize it.
What I am hoping for is some function or class F
such that
_q_exports = ['someclassinstance']
someclassinstance = F(someclass('foo'))
Will ensure someclass.init(self,'foo') gets called
every time 'someclassinstance' gets traversed.
Below is the actual code I am trying to get working.
The problem with it is that tailtest.__init__ is
called only once when the module is loaded, so hitting
reload on /tailtest/x keeps appending data to
self.args
Thanks,
Dan
# basemodule.py #
import taileater
_q_exports = ['tailtest']
tailtest = taileater.TailEater(taileater.test,
'tailtest');
# taileater.py #
# use: from taileater import tailtest
#      _q_exports = ['tailtest']
class TailEater:
     _q_exports = []
     def __init__(self, handler, first_component):
         self.handler = handler
         self.args = [first_component]
         print "Init: TailEater"
     def _q_index(self, request):
         return self.handler(request, self.args)
     __call__ = _q_index
     def _q_lookup(self, request, component):
         self.args.append(component)
         return self
def test [html] (request,c):
    c