GithubHelp home page GithubHelp logo

Comments (3)

malthe avatar malthe commented on May 26, 2024

It does not require them to be valid, but yes, it does make the
interpreter throw a warning – and should be fixed of course.

I think there's two options:

  1. Replace with underscore
  2. Don't include template name in cache filename

It's convenient in debug-mode to have the filename in there, but maybe
it could be an option, or connected to the CHAMELEON_DEBUG flag.

\malthe

On 16 July 2011 20:16, hannosch
[email protected]
wrote:

The old zope.pagetemplate implementation supports arbitrary filenames for templates. It looks like Chameleon requires them to be valid Python module names.

I noticed this with a template named "manage-dashboard.pt", overridden via z3c.jbot in a Plone context. While loading that template with the template cache being enabled, I get an error message on the console:

   /template_cache/plone.app.portlets.browser.templates.manage-dashboard_d7c6cb77a0fc8e04ef7c535b94fb9cd64a795443.py:44:
   RuntimeWarning: Parent module 'plone.app.portlets.browser.templates' not found while handling absolute import
   import functools

It looks to me like the chameleon.template.BaseTemplateFile._cook method could do some quoting here. In the snippet:

   def cook(self, body, digest):
       filename = os.path.basename(self.filename)
       base, ext = os.path.splitext(filename)
       name = "%s
%s.py" % (base, digest)
       cooked = self.loader.get(name)
       ...

it could quote the base part. I guess both dots and hyphens are problematic. Maybe replacing both of these with underscores would be simple enough.

Reply to this email directly or view it on GitHub:
#17

from chameleon.

hannosch avatar hannosch commented on May 26, 2024

I think having the filename in there is indeed useful. So simply replacing any non-alphanumeric, non-underscore character with an underscore might be good enough.

from chameleon.

malthe avatar malthe commented on May 26, 2024

Fixed in f8fba42.

from chameleon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.