Anyway, the diff for django_adapter is as follows:
Index: django_adapter.py
===================================================================
--- django_adapter.py (revision 267)
+++ django_adapter.py (working copy)
@@ -7,9 +7,13 @@
from django.conf import settings
BREVE_ROOT = settings.BREVE_ROOT
+try:
+ BREVE_OPTS = settings.BREVE_OPTS
+except AttributeError:
+ BREVE_OPTS = {}
def flatten_string ( obj ):
- return unicode ( obj ).encode ( settings.DEFAULT_CHARSET )
+ return obj
class _loader ( object ):
def __init__ ( self, root, breve_opts = None ):
@@ -35,11 +39,12 @@
django.template.TemplateDoesNotExist.
"""
def __init__ ( self, names, root = BREVE_ROOT, breve_opts =
{ } ):
- self.template = Template ( tags = html.tags, root = root )
+ self.template = Template ( tags = html.tags, root = root,
**breve_opts)
self.names = names
self.breve_opts = breve_opts
def render ( self, vars = None ):
+ import os # why??
if vars == None:
vars = { }
elif isinstance ( vars, Context ):
@@ -69,7 +74,7 @@
for name in
self.names ] ) )
-loader = _loader ( root = BREVE_ROOT )
+loader = _loader ( root = BREVE_ROOT, breve_opts = BREVE_OPTS)
def render_to_response ( template, vars = None ):
t = loader.get_template ( template )
Most definitely. Fixed in CVS.
> Anyway, the diff for django_adapter is as follows:
>
> Index: django_adapter.py
> ===================================================================
> --- django_adapter.py (revision 267)
> +++ django_adapter.py (working copy)
> @@ -7,9 +7,13 @@
>
> from django.conf import settings
> BREVE_ROOT = settings.BREVE_ROOT
> +try:
> + BREVE_OPTS = settings.BREVE_OPTS
> +except AttributeError:
> + BREVE_OPTS = {}
>
> def flatten_string ( obj ):
> - return unicode ( obj ).encode ( settings.DEFAULT_CHARSET )
> + return obj
What is this going to mean in terms of existing code? I believe that
the line you're removing was in fact a patch from another Django user.
> class _loader ( object ):
> def __init__ ( self, root, breve_opts = None ):
> @@ -35,11 +39,12 @@
> django.template.TemplateDoesNotExist.
> """
> def __init__ ( self, names, root = BREVE_ROOT, breve_opts =
> { } ):
> - self.template = Template ( tags = html.tags, root = root )
> + self.template = Template ( tags = html.tags, root = root,
> **breve_opts)
> self.names = names
> self.breve_opts = breve_opts
>
> def render ( self, vars = None ):
> + import os # why??
Indeed, why? I notice the original has a seemingly unneeded "import os"
a bit later on.
I'm a bit curious what the overall effect of these changes are. I don't
use Django much myself (except Satchmo, but I just use the provided
templates for that), so I'm not in a good position to test this.
Cliff
The impact on existing code is zero. Any working project will work
just as well with this patch. This patch is only to allow the use of
the already existing breve_opt variable. That variable existed but
there was no way to actually give this variable any value. This allows
django+brevé users to customise the brevé behaviour via the django
settings file.
>
> > class _loader ( object ):
> > def __init__ ( self, root, breve_opts = None ):
> > @@ -35,11 +39,12 @@
> > django.template.TemplateDoesNotExist.
> > """
> > def __init__ ( self, names, root = BREVE_ROOT, breve_opts =
> > { } ):
> > - self.template = Template ( tags = html.tags, root = root )
> > + self.template = Template ( tags = html.tags, root = root,
> > **breve_opts)
> > self.names = names
> > self.breve_opts = breve_opts
>
> > def render ( self, vars = None ):
> > + import os # why??
>
> Indeed, why? I notice the original has a seemingly unneeded "import os"
> a bit later on.
I don't know. If I don't put that I get a NameError exception saying
that os is not defined (or that `os` is none, i don't remember). I
have no idea of why this is happening since `os` is imported at the
beginning of the file. I believe that the name `os` gets somehow
redefined or deleted along the way but i was not able to determine
exactly where.
>
> I'm a bit curious what the overall effect of these changes are. I don't
> use Django much myself (except Satchmo, but I just use the provided
> templates for that), so I'm not in a good position to test this.
As I said, the effect of this patch will go unnoticed to existing
project. It just adds new possibilities.
>
> Cliff