[ckan-changes] commit/ckan: 2 new changesets

Bitbucket commits-noreply at bitbucket.org
Thu Jun 2 10:04:27 UTC 2011


2 new changesets in ckan:

http://bitbucket.org/okfn/ckan/changeset/4e3f9cd5750f/
changeset:   4e3f9cd5750f
branches:    
user:        pudo
date:        2011-05-30 18:29:15
summary:     [lib] MockTranslator for CLI commands to always have a translator object set up
affected #:  2 files (707 bytes)

--- a/ckan/lib/cli.py	Tue May 31 18:50:32 2011 +0100
+++ b/ckan/lib/cli.py	Mon May 30 18:29:15 2011 +0200
@@ -4,9 +4,22 @@
 from pprint import pprint
 
 import paste.script
+from paste.registry import Registry
 from paste.script.util.logging_config import fileConfig
 import re
 
+class MockTranslator(object): 
+    def gettext(self, value): 
+        return value 
+
+    def ugettext(self, value): 
+        return value 
+
+    def ungettext(self, singular, plural, n):
+        if n > 1:
+            return plural
+        return singular
+
 class CkanCommand(paste.script.command.Command):
     parser = paste.script.command.Command.standard_parser(verbose=True)
     parser.add_option('-c', '--config', dest='config',
@@ -30,7 +43,12 @@
         except Exception: pass
         conf = appconfig('config:' + self.filename)
         load_environment(conf.global_conf, conf.local_conf)
-        
+
+        self.registry=Registry()
+        self.registry.prepare()
+        import pylons
+        self.translator_obj = MockTranslator()
+        self.registry.register(pylons.translator, self.translator_obj)
 
     def _setup_app(self):
         cmd = paste.script.appinstall.SetupCommand('setup-app') 


--- a/ckan/tests/pylons_controller.py	Tue May 31 18:50:32 2011 +0100
+++ b/ckan/tests/pylons_controller.py	Mon May 30 18:29:15 2011 +0200
@@ -12,20 +12,9 @@
 from pylons.controllers.util import Request, Response 
 
 from ckan.tests import *
+from ckan.lib.cli import MockTranslator
 
-class MockTranslator(object): 
-    def gettext(self, value): 
-        return value 
 
-    def ugettext(self, value): 
-        return value 
-
-    def ungettext(self, singular, plural, n):
-        if n > 1:
-            return plural
-        return singular
-
-    
 class PylonsTestCase(object):
     """A basic test case which allows access to pylons.c and pylons.request. 
     """


http://bitbucket.org/okfn/ckan/changeset/5730c79db461/
changeset:   5730c79db461
branches:    
user:        pudo
date:        2011-06-02 12:03:28
summary:     [lib] munge text into something taggish
affected #:  1 file (160 bytes)

--- a/ckan/lib/munge.py	Mon May 30 18:29:15 2011 +0200
+++ b/ckan/lib/munge.py	Thu Jun 02 12:03:28 2011 +0200
@@ -93,3 +93,10 @@
         else:
             r += str(char)
     return r
+
+
+def munge_tag(tag):
+    tag = substitute_ascii_equivalents(tag)
+    tag = tag.lower().strip()
+    return re.sub(r'[^a-zA-Z0-9 ]', '', tag).replace(' ', '-')
+

Repository URL: https://bitbucket.org/okfn/ckan/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.




More information about the ckan-changes mailing list