Comments (3)
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:
- Replace with underscore
- 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 functoolsIt 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.
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.
Fixed in f8fba42.
from chameleon.
Related Issues (20)
- Double translation HOT 2
- Provide wheels HOT 8
- use-macro and variables HOT 2
- Fix language reference document structure
- Add support for pathlib-based paths HOT 3
- Work in FIPS enabled environments HOT 7
- python complains about BaseException being unsafe HOT 1
- 3.9.1: pytest is failing HOT 6
- Tag not Parseable with Tab and Colon HOT 6
- ``${}`` operator to expand attributes not working HOT 2
- Cannot access repeat variable when iterating over dict items HOT 3
- str() of Chameleon Exception throws UnicodeDecodeError
- Q: how to make condition without the element itself? HOT 1
- VS Code extension HOT 2
- SystemError AST constructor recursion depth mismatch error on Python 3.11 HOT 8
- Wheel releases? HOT 8
- sdist is missing tests HOT 1
- Chameleon support for Python 3.11? HOT 4
- i18n:target undefined variable HOT 2
- `target_language` not passed to the translate method in certain cases HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chameleon.