Loading ...
Sorry, an error occurred while loading the content.
 

[Cheetahtemplate-discuss] About cheetah cache

Expand Messages
  • Silvio Di Stefano
    Hey people, cheetah newbie says hi. I ve been playing with the cache and couldn t make it work at all. I tryed the three variants, and it just reloads the page
    Message 1 of 4 , Apr 28 7:41 AM
      Hey people, cheetah newbie says hi.
      I've been playing with the cache and couldn't make it work at all.
      I tryed the three variants, and it just reloads the page every time.
      Is there something I should consider?
      I'm using mod_python with this handler I wrote
      def handler(req):
      req.content_type='text/html'
      #Analyze URL
      uri=req.uri.split('/')
      function=uri[2]
      params=uri[3:]
      #Call function if exists
      if(True):
      globals()['TEMPLATE_PATH']=\
      req.get_options()['root_path']+'/api/templates/'
      sys.path+=(TEMPLATE_PATH,)
      EF.setReq(req)
      EF.startSession()
      from admin.client import client
      globals()['client']=client()
      req.write(params and eval(function)(params) or eval(function)())
      # except: return apache.HTTP_NOT_FOUND
      return apache.OK

      Any ideas?
      --
      Silvio Di Stefano


      -------------------------------------------------------
      Using Tomcat but need to do more? Need to support web services, security?
      Get stuff done quickly with pre-integrated technology to make your job easier
      Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
      http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642
      _______________________________________________
      Cheetahtemplate-discuss mailing list
      Cheetahtemplate-discuss@...
      https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
    • Mike Orr
      ... In answer to your email, I haven t used mod_python. There are Apache options to set the number of subprocesses, something like MaxSpareServers. I don t
      Message 2 of 4 , Apr 29 12:57 AM
        On 4/28/06, Mike Orr <sluggoster@...> wrote:
        > On 4/28/06, Silvio Di Stefano <sdistefano@...> wrote:
        > > Hey people, cheetah newbie says hi.
        > > I've been playing with the cache and couldn't make it work at all.
        > > I tryed the three variants, and it just reloads the page every time.
        > > Is there something I should consider?
        > > I'm using mod_python with this handler I wrote
        >
        > The caching is per process. If Apache is spawning multiple Python
        > processes and you hit a random one each time, it won't have been
        > cached.

        In answer to your email, I haven't used mod_python. There are Apache
        options to set the number of subprocesses, something like
        MaxSpareServers. I don't know how you'd tell mod_python to use only
        one process but still use multiple processes for other handlers.
        Unless you anticipate getting several requests a second on the same
        template, there's not much point in caching.

        --
        Mike Orr <sluggoster@...>
        (mso@... address is semi-reliable)


        -------------------------------------------------------
        Using Tomcat but need to do more? Need to support web services, security?
        Get stuff done quickly with pre-integrated technology to make your job easier
        Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
        http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642
        _______________________________________________
        Cheetahtemplate-discuss mailing list
        Cheetahtemplate-discuss@...
        https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
      • Shannon -jj Behrens
        Weird, looking at that code, can the user really choose to execute *any* function by putting it in the URL? By the way, Mike is right. If you have multiple
        Message 3 of 4 , May 1, 2006
          Weird, looking at that code, can the user really choose to execute
          *any* function by putting it in the URL?

          By the way, Mike is right. If you have multiple Python processes,
          which is pretty normal in mod_python, it's hard to get them to share a
          cache unless you cache to disk or use memcache, etc. I forget, does
          Cheetah support that? I personally have never needed to use the whole
          cache system. :-/

          -jj

          On 4/28/06, Silvio Di Stefano <sdistefano@...> wrote:
          > Hey people, cheetah newbie says hi.
          > I've been playing with the cache and couldn't make it work at all.
          > I tryed the three variants, and it just reloads the page every time.
          > Is there something I should consider?
          > I'm using mod_python with this handler I wrote
          > def handler(req):
          > req.content_type='text/html'
          > #Analyze URL
          > uri=req.uri.split('/')
          > function=uri[2]
          > params=uri[3:]
          > #Call function if exists
          > if(True):
          > globals()['TEMPLATE_PATH']=\
          > req.get_options()['root_path']+'/api/templates/'
          > sys.path+=(TEMPLATE_PATH,)
          > EF.setReq(req)
          > EF.startSession()
          > from admin.client import client
          > globals()['client']=client()
          > req.write(params and eval(function)(params) or eval(function)())
          > # except: return apache.HTTP_NOT_FOUND
          > return apache.OK
          >
          > Any ideas?
          > --
          > Silvio Di Stefano
          >
          >
          > -------------------------------------------------------
          > Using Tomcat but need to do more? Need to support web services, security?
          > Get stuff done quickly with pre-integrated technology to make your job easier
          > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
          > http://sel.as-us.falkag.net/sel?cmdlnk&kid0709&bid&3057&dat1642
          > _______________________________________________
          > Cheetahtemplate-discuss mailing list
          > Cheetahtemplate-discuss@...
          > https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
          >


          -------------------------------------------------------
          Using Tomcat but need to do more? Need to support web services, security?
          Get stuff done quickly with pre-integrated technology to make your job easier
          Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
          http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642
          _______________________________________________
          Cheetahtemplate-discuss mailing list
          Cheetahtemplate-discuss@...
          https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
        • Silvio Di Stefano
          Yes, but only functions inside that file, which are the ones I want them to execute. I don t think cheetah supports that. Anyway, here s a class I wrote, I
          Message 4 of 4 , May 1, 2006
            Yes, but only functions inside that file, which are the ones I want
            them to execute.
            I don't think cheetah supports that.
            Anyway, here's a class I wrote, I hope it's useful to someone.
            It is designed to work with small files, as it prefers to just rebuild
            the cache in case it gets corrupted rather than locking the file in
            each request.
            I think that's more practical with small files where you don't usually
            expect many connections to use the same cache (I have one cache file
            per user), but locking should be implemented for larger files.

            Greetings

            class Cache(dict):
            def __init__(self):
            """This should be overriden by subclass. self.path is
            required, self.logger recommended"""
            pass
            def __getitem__(self,key):
            try:
            if key in self.cache['__Outdated']:
            raise Exception()
            return self.cache[key]
            except: return False
            def __setitem__(self,key,value):
            self.cache[key]=value
            if key in self.cache['__Outdated']:
            self.cache['__Outdated'].remove(key)
            def load(self):
            import cPickle as pickle
            self._open('rb')
            try:
            self.cache=pickle.load(self.fh)
            self._close()
            except:
            #file broken, restart cache. If there's a
            logger defined, an even happier function
            try: self.logger.log.warning('Cache
            '+self.path+' was forcedly restarted.')
            except: pass
            self._close()
            self.create()
            self.load()
            def save(self):
            import cPickle as pickle
            self._open('wb')
            pickle.dump(self.cache,self.fh,1)
            self._close()
            def outDate(self,key):
            self.cache['__Outdated'].append(key)
            def _open(self,mode):
            if not self.path: raise Exception('A path must
            be set for cache')
            self.fh=file(self.path,mode)
            def _close(self):
            self.fh.close()
            def create(self):
            self.cache={'__Outdated':[]}
            self.save()
            def __repr__(self):
            return repr(self.cache)


            On 5/1/06, Shannon -jj Behrens <jjinux@...> wrote:
            > Weird, looking at that code, can the user really choose to execute
            > *any* function by putting it in the URL?
            >
            > By the way, Mike is right. If you have multiple Python processes,
            > which is pretty normal in mod_python, it's hard to get them to share a
            > cache unless you cache to disk or use memcache, etc. I forget, does
            > Cheetah support that? I personally have never needed to use the whole
            > cache system. :-/
            >
            > -jj
            >
            > On 4/28/06, Silvio Di Stefano <sdistefano@...> wrote:
            > > Hey people, cheetah newbie says hi.
            > > I've been playing with the cache and couldn't make it work at all.
            > > I tryed the three variants, and it just reloads the page every time.
            > > Is there something I should consider?
            > > I'm using mod_python with this handler I wrote
            > > def handler(req):
            > > req.content_type='text/html'
            > > #Analyze URL
            > > uri=req.uri.split('/')
            > > function=uri[2]
            > > params=uri[3:]
            > > #Call function if exists
            > > if(True):
            > > globals()['TEMPLATE_PATH']=\
            > > req.get_options()['root_path']+'/api/templates/'
            > > sys.path+=(TEMPLATE_PATH,)
            > > EF.setReq(req)
            > > EF.startSession()
            > > from admin.client import client
            > > globals()['client']=client()
            > > req.write(params and eval(function)(params) or eval(function)())
            > > # except: return apache.HTTP_NOT_FOUND
            > > return apache.OK
            > >
            > > Any ideas?
            > > --
            > > Silvio Di Stefano
            > >
            > >
            > > -------------------------------------------------------
            > > Using Tomcat but need to do more? Need to support web services, security?
            > > Get stuff done quickly with pre-integrated technology to make your job easier
            > > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
            > > http://sel.as-us.falkag.net/sel?cmdlnk&kid0709&bid&3057&dat1642
            > > _______________________________________________
            > > Cheetahtemplate-discuss mailing list
            > > Cheetahtemplate-discuss@...
            > > https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
            > >
            >


            --
            Silvio Di Stefano


            -------------------------------------------------------
            Using Tomcat but need to do more? Need to support web services, security?
            Get stuff done quickly with pre-integrated technology to make your job easier
            Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
            http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642
            _______________________________________________
            Cheetahtemplate-discuss mailing list
            Cheetahtemplate-discuss@...
            https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
          Your message has been successfully submitted and would be delivered to recipients shortly.