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

[Cheetahtemplate-discuss] problems with Cheetah base class being in templates directory

Expand Messages
  • mobiledreamers@gmail.com
    *How do we setup Cheetah so it runs with all templates in the templates directory and all code in the .. directory code.py* production=True if not production:
    Message 1 of 2 , May 28, 2009
    • 0 Attachment
      How do we setup Cheetah so it runs with all templates in the templates directory and all code in the .. directory

      code.py

      production=True
      if not production:
          try:web.render('mafbase.tmpl', None, True, 'mafbase')
          except:pass
      else:
          from templates import mafbase


      templates/mafbase.tmpl
      templates/mafbase.py


          try:web.render('mafbase.tmpl', None, True, 'mafbase')
      This works but is very slow to load and causes timeout errors


          from templates import mafbase

      This doesnt work
         return self._delegate(fn, self.fvars, args)
        File "/home/mark/work/common/web/application.py", line 411, in _delegate
          return handle_class(cls)
        File "/home/mark/work/common/web/application.py", line 386, in handle_class
          return tocall(*args)
        File "user.py", line 262, in proxyfunc
          return func(self, *args, **kw)
        File "/home/mark/work/pop/code.py", line 1796, in GET
          return web.render('subclass.html')
        File "/home/mark/work/common/web/cheetah.py", line 104, in render
          return str(compiled_tmpl)
        File "/usr/lib/python2.5/site-packages/Cheetah-2.0.1-py2.5-linux-i686.egg/Cheetah/Template.py", line 982, in __str__
          def __str__(self): return getattr(self, mainMethName)()
        File "mafbase.py", line 634, in respond
        File "/usr/lib/python2.5/site-packages/Cheetah-2.0.1-py2.5-linux-i686.egg/Cheetah/Template.py", line 1512, in _handleCheetahInclude
          nestedTemplateClass = compiler.compile(source=source,file=file)
        File "/usr/lib/python2.5/site-packages/Cheetah-2.0.1-py2.5-linux-i686.egg/Cheetah/Template.py", line 693, in compile
          fileHash = str(hash(file))+str(os.path.getmtime(file))
        File "/usr/lib/python2.5/posixpath.py", line 143, in getmtime
          return os.stat(filename).st_mtime
      OSError: [Errno 2] No such file or directory: '/home/mark/work/pop/widgetbox.html'



      --
      Bidegg worlds best auction site
      http://bidegg.com
    • R. Tyler Ballance
      ... Please stop cross-posting to every damn Python list you know of, this either *only* belongs on the Cheetah mailing list, or it *only* belongs on the Webpy
      Message 2 of 2 , May 29, 2009
      • 0 Attachment
        On Thu, May 28, 2009 at 06:47:44PM -0700, mobiledreamers@... wrote:
        > How do we setup Cheetah so it runs with all templates in the templates
        > directory and all code in the .. directory

        Please stop cross-posting to every damn Python list you know of, this
        either *only* belongs on the Cheetah mailing list, or it *only* belongs
        on the Webpy mailing list. (I've dropped them all from the CC list)


        As to your actual issue, it has to do with your paths on your #include
        statement in mafbase.tmpl being wrong. Nobody can help you without
        either source code or reproduction steps.

        Emails like this "Why not work? <stacktrace>" are practically useless to
        us unless you provide relevant details or a *reproduction case* that we
        can run locally. Please keep this in mind with future posts.

        >
        > code.py
        > production=True
        > if not production:
        > try:web.render('mafbase.tmpl', None, True, 'mafbase')
        > except:pass
        > else:
        > from templates import mafbase
        >
        > templates/mafbase.tmpl
        > templates/mafbase.py
        >
        > try:web.render('mafbase.tmpl', None, True, 'mafbase')
        > This works but is very slow to load and causes timeout errors
        >
        > from templates import mafbase
        >
        > This doesnt work
        > return self._delegate(fn, self.fvars, args)
        > File "/home/mark/work/common/web/application.py", line 411, in _delegate
        > return handle_class(cls)
        > File "/home/mark/work/common/web/application.py", line 386, in
        > handle_class
        > return tocall(*args)
        > File "user.py", line 262, in proxyfunc
        > return func(self, *args, **kw)
        > File "/home/mark/work/pop/code.py", line 1796, in GET
        > return web.render('subclass.html')
        > File "/home/mark/work/common/web/cheetah.py", line 104, in render
        > return str(compiled_tmpl)
        > File
        > "/usr/lib/python2.5/site-packages/Cheetah-2.0.1-py2.5-linux-i686.egg/Cheetah/Template.py",
        > line 982, in __str__
        > def __str__(self): return getattr(self, mainMethName)()
        > File "mafbase.py", line 634, in respond
        > File
        > "/usr/lib/python2.5/site-packages/Cheetah-2.0.1-py2.5-linux-i686.egg/Cheetah/Template.py",
        > line 1512, in _handleCheetahInclude
        > nestedTemplateClass = compiler.compile(source=source,file=file)
        > File
        > "/usr/lib/python2.5/site-packages/Cheetah-2.0.1-py2.5-linux-i686.egg/Cheetah/Template.py",
        > line 693, in compile
        > fileHash = str(hash(file))+str(os.path.getmtime(file))
        > File "/usr/lib/python2.5/posixpath.py", line 143, in getmtime
        > return os.stat(filename).st_mtime
        > OSError: [Errno 2] No such file or directory:
        > '/home/mark/work/pop/widgetbox.html'
        >
        > --
        > Bidegg worlds best auction site
        > http://bidegg.com

        > ------------------------------------------------------------------------------
        > Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
        > is a gathering of tech-side developers & brand creativity professionals. Meet
        > the minds behind Google Creative Lab, Visual Complexity, Processing, &
        > iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
        > Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com
        > _______________________________________________
        > Cheetahtemplate-discuss mailing list
        > Cheetahtemplate-discuss@...
        > https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss


        --
        -R. Tyler Ballance
        Slide, Inc.
      Your message has been successfully submitted and would be delivered to recipients shortly.