diff genshi/template/plugin.py @ 355:0fc758cb3a02 experimental-inline

inline branch: Merged [430:434/trunk].
author cmlenz
date Mon, 13 Nov 2006 18:16:57 +0000
parents 5f2c7782cd8a
children 55cf81951686
line wrap: on
line diff
--- a/genshi/template/plugin.py
+++ b/genshi/template/plugin.py
@@ -18,14 +18,17 @@
 
 from pkg_resources import resource_filename
 
-from genshi.eval import Undefined
 from genshi.input import ET, HTML, XML
 from genshi.output import DocType
 from genshi.template.core import Context, Template
+from genshi.template.eval import Undefined
 from genshi.template.loader import TemplateLoader
 from genshi.template.markup import MarkupTemplate
 from genshi.template.text import TextTemplate
 
+__all__ = ['ConfigurationError', 'MarkupTemplateEnginePlugin',
+           'TextTemplateEnginePlugin']
+
 
 class ConfigurationError(Exception):
     """Exception raised when invalid plugin options are encountered."""
@@ -44,14 +47,15 @@
         self.options = options
 
         self.default_encoding = options.get('genshi.default_encoding', 'utf-8')
-        auto_reload = options.get('genshi.auto_reload', '1').lower() \
-                            in ('1', 'yes', 'true')
+        auto_reload = options.get('genshi.auto_reload', '1')
+        if isinstance(auto_reload, basestring):
+            auto_reload = auto_reload.lower() in ('1', 'on', 'yes', 'true')
         search_path = options.get('genshi.search_path', '').split(':')
         try:
             max_cache_size = int(options.get('genshi.max_cache_size', 25))
         except ValueError:
             raise ConfigurationError('Invalid value for max_cache_size: "%s"' %
-                                     max_cache_size)
+                                     options.get('genshi.max_cache_size'))
 
         self.loader = TemplateLoader(filter(None, search_path),
                                      auto_reload=auto_reload,
@@ -116,12 +120,12 @@
     def __init__(self, extra_vars_func=None, options=None):
         AbstractTemplateEnginePlugin.__init__(self, extra_vars_func, options)
 
-        doctype = options.get('genshi.default_doctype')
+        doctype = self.options.get('genshi.default_doctype')
         if doctype and doctype not in self.doctypes:
             raise ConfigurationError('Unknown doctype "%s"' % doctype)
         self.default_doctype = self.doctypes.get(doctype)
 
-        format = options.get('genshi.default_format', 'html')
+        format = self.options.get('genshi.default_format', 'html')
         if format not in ('html', 'xhtml', 'xml', 'text'):
             raise ConfigurationError('Unknown output format "%s"' % format)
         self.default_format = format
@@ -148,11 +152,3 @@
     template_class = TextTemplate
     extension = '.txt'
     default_format = 'text'
-
-    def transform(self, info, template):
-        """Render the output to an event stream."""
-        data = {}
-        if self.get_extra_vars:
-            data.update(self.get_extra_vars())
-        data.update(info)
-        return super(TextTemplateEnginePlugin, self).transform(data, template)
Copyright (C) 2012-2017 Edgewall Software