[Checkins] SVN: grok/trunk/ Change findFilesystem, now its dont't stop on unrecognized files and analyse only *.pt. People who use text editors

Mikhail Kashkin m at keysolutions.ru
Sat Jul 14 11:20:26 EDT 2007


Log message for revision 77935:
  Change findFilesystem, now its dont't stop on unrecognized files and analyse only *.pt. People who use text editors
  that generate backup and/or temploraty files should be happy
  

Changed:
  U   grok/trunk/CREDITS.txt
  U   grok/trunk/setup.py
  U   grok/trunk/src/grok/templatereg.py
  U   grok/trunk/src/grok/tests/view/dirtemplatesonly.py

-=-
Modified: grok/trunk/CREDITS.txt
===================================================================
--- grok/trunk/CREDITS.txt	2007-07-14 15:18:19 UTC (rev 77934)
+++ grok/trunk/CREDITS.txt	2007-07-14 15:20:26 UTC (rev 77935)
@@ -21,6 +21,8 @@
 
 * Christian Zagrodnick (early grok discussions)
 
+* Mikhail Kashkin
+
 * ME GROK (team mascot)
 
 Thank you

Modified: grok/trunk/setup.py
===================================================================
--- grok/trunk/setup.py	2007-07-14 15:18:19 UTC (rev 77934)
+++ grok/trunk/setup.py	2007-07-14 15:20:26 UTC (rev 77935)
@@ -33,6 +33,7 @@
                       'zope.component',
                       'zope.configuration',
                       'zope.dottedname',
+                      'zope.deprecation',
                       'zope.event',
                       'zope.formlib',
                       'zope.interface',

Modified: grok/trunk/src/grok/templatereg.py
===================================================================
--- grok/trunk/src/grok/templatereg.py	2007-07-14 15:18:19 UTC (rev 77934)
+++ grok/trunk/src/grok/templatereg.py	2007-07-14 15:20:26 UTC (rev 77935)
@@ -2,6 +2,7 @@
 
 import os
 import grok
+import warnings
 
 class TemplateRegistry(object):
 
@@ -34,9 +35,13 @@
                 continue
 
             if not template_file.endswith('.pt'):
-                raise GrokError("Unrecognized file '%s' in template directory "
-                                "'%s'." % (template_file, template_dir),
-                                module_info.getModule())
+                # Warning when importing files. This should be
+                # allowed because people may be using editors that generate
+                # '.bak' files and such.
+                warnings.warn("File '%s' has an unrecognized extension in "
+                              "directory '%s'" %
+                              (template_file, template_dir), UserWarning, 2)
+                continue
 
             template_name = template_file[:-3] # cut off .pt
             template = grok.PageTemplateFile(template_file, template_dir)

Modified: grok/trunk/src/grok/tests/view/dirtemplatesonly.py
===================================================================
--- grok/trunk/src/grok/tests/view/dirtemplatesonly.py	2007-07-14 15:18:19 UTC (rev 77934)
+++ grok/trunk/src/grok/tests/view/dirtemplatesonly.py	2007-07-14 15:20:26 UTC (rev 77935)
@@ -1,12 +1,22 @@
 """
 A template directory may only contain recognized template files:
+  >>> from zope.deprecation.tests import warn
+  >>> import warnings
+  >>> saved_warn = warnings.warn
+  >>> warnings.warn = warn
 
+
   >>> grok.grok(__name__)
-  Traceback (most recent call last):
-    ...
-  GrokError: Unrecognized file 'invalid.txt' in template directory '...dirtemplatesonly_templates'.
+    From tests.py's showwarning():
+    ...: UserWarning: File 'invalid.txt' has an unrecognized extension in directory '...dirtemplatesonly_templates'
+    
+  >>> warnings.warn = saved_warn
+
 """
 import grok
 
 class Mammoth(grok.Model):
     pass
+
+class Index(grok.View):
+    pass
\ No newline at end of file



More information about the Checkins mailing list