[ckan-changes] [okfn/ckan] 5ceee2: [xs] spelling
GitHub
noreply at github.com
Fri Apr 20 10:17:08 UTC 2012
Branch: refs/heads/enhancement-2251-tracking
Home: https://github.com/okfn/ckan
Commit: 5ceee26d8cb0b7c6df390d09f978b0acfa6275e5
https://github.com/okfn/ckan/commit/5ceee26d8cb0b7c6df390d09f978b0acfa6275e5
Author: Toby <toby.junk at gmail.com>
Date: 2012-04-19 (Thu, 19 Apr 2012)
Changed paths:
M ckan/plugins/toolkit.py
Log Message:
-----------
[xs] spelling
diff --git a/ckan/plugins/toolkit.py b/ckan/plugins/toolkit.py
index 27e0fd0..de72479 100644
--- a/ckan/plugins/toolkit.py
+++ b/ckan/plugins/toolkit.py
@@ -1,7 +1,7 @@
## This file is intended to make functions/objects consistently
## available to plugins whilst giving developers the ability move code
## around or change underlying frameworks etc. It should not be used
-## internaly within ckan only by extensions. Functions should only be
+## internally within ckan only by extensions. Functions should only be
## removed from this file after reasonable depreciation notice has
## been given.
================================================================
Commit: cf1211145f7cc1896f4bae49c37936dccce112a9
https://github.com/okfn/ckan/commit/cf1211145f7cc1896f4bae49c37936dccce112a9
Author: Toby <toby.junk at gmail.com>
Date: 2012-04-19 (Thu, 19 Apr 2012)
Changed paths:
M ckan/plugins/toolkit.py
Log Message:
-----------
plugin.toolkit NotFound -> ActionNotFound
diff --git a/ckan/plugins/toolkit.py b/ckan/plugins/toolkit.py
index de72479..e635c43 100644
--- a/ckan/plugins/toolkit.py
+++ b/ckan/plugins/toolkit.py
@@ -34,7 +34,7 @@
'literal', # stop tags in a string being escaped
'get_action', # get logic action function
'check_access', # check logic function authorisation
- 'NotFound', # action not found exception
+ 'ActionNotFound', # action not found exception (ckan.logic.NotFound)
'NotAuthorized', # action not authorized exception
'ValidationError', # model update validation error
'CkanCommand', # class for providing cli interfaces
@@ -59,7 +59,7 @@
get_action = logic.get_action
check_access = logic.check_access
-NotFound = logic.NotFound
+ActionNotFound = logic.NotFound ## Name change intentional
NotAuthorized = logic.NotAuthorized
ValidationError = logic.ValidationError
================================================================
Commit: 66b596ce01b1613a9398bb25d6b266e4b4828b6e
https://github.com/okfn/ckan/commit/66b596ce01b1613a9398bb25d6b266e4b4828b6e
Author: Toby <toby.junk at gmail.com>
Date: 2012-04-20 (Fri, 20 Apr 2012)
Changed paths:
M ckan/lib/base.py
Log Message:
-----------
import clean
diff --git a/ckan/lib/base.py b/ckan/lib/base.py
index da9d69f..075029c 100644
--- a/ckan/lib/base.py
+++ b/ckan/lib/base.py
@@ -22,7 +22,7 @@
import ckan.exceptions
import ckan
-from ckan import authz
+import ckan.authz as authz
from ckan.lib import i18n
import ckan.lib.helpers as h
from ckan.plugins import PluginImplementations, IGenshiStreamFilter
================================================================
Commit: 79e42821a2eddfaedb12e6d6a5376ae4a6354a70
https://github.com/okfn/ckan/commit/79e42821a2eddfaedb12e6d6a5376ae4a6354a70
Author: Toby <toby.junk at gmail.com>
Date: 2012-04-20 (Fri, 20 Apr 2012)
Changed paths:
M ckan/lib/cli.py
Log Message:
-----------
import clean in lib/cli
diff --git a/ckan/lib/cli.py b/ckan/lib/cli.py
index 5146aa9..6798cc4 100644
--- a/ckan/lib/cli.py
+++ b/ckan/lib/cli.py
@@ -84,7 +84,7 @@ class ManageDb(CkanCommand):
def command(self):
self._load_config()
- from ckan import model
+ import ckan.model as model
import ckan.lib.search as search
cmd = self.args[0]
@@ -164,7 +164,7 @@ def _postgres_dump(self, filepath):
self._run_cmd(pg_dump_cmd)
def _postgres_load(self, filepath):
- from ckan import model
+ import ckan.model as model
assert not model.repo.are_tables_created(), "Tables already found. You need to 'db clean' before a load."
pg_cmd = self._get_psql_cmd() + ' -f %s' % filepath
self._run_cmd(pg_cmd)
@@ -194,7 +194,7 @@ def load(self, only_load=False):
pg_cmd = self._postgres_load(dump_path)
if not only_load:
print 'Upgrading DB'
- from ckan import model
+ import ckan.model as model
model.repo.upgrade_db()
print 'Rebuilding search index'
@@ -205,7 +205,7 @@ def load(self, only_load=False):
print 'Done'
def simple_dump_csv(self):
- from ckan import model
+ import ckan.model as model
if len(self.args) < 2:
print 'Need csv file path'
return
@@ -215,7 +215,7 @@ def simple_dump_csv(self):
dumper.SimpleDumper().dump(dump_file, format='csv')
def simple_dump_json(self):
- from ckan import model
+ import ckan.model as model
if len(self.args) < 2:
print 'Need json file path'
return
@@ -452,7 +452,7 @@ class Sysadmin(CkanCommand):
def command(self):
self._load_config()
- from ckan import model
+ import ckan.model as model
cmd = self.args[0] if self.args else None
if cmd == None or cmd == 'list':
@@ -465,7 +465,7 @@ def command(self):
print 'Command %s not recognized' % cmd
def list(self):
- from ckan import model
+ import ckan.model as model
print 'Sysadmins:'
sysadmins = model.Session.query(model.SystemRole).filter_by(role=model.Role.ADMIN)
print 'count = %i' % sysadmins.count()
@@ -477,7 +477,7 @@ def list(self):
user_or_authgroup.id)
def add(self):
- from ckan import model
+ import ckan.model as model
if len(self.args) < 2:
print 'Need name of the user to be made sysadmin.'
@@ -501,7 +501,7 @@ def add(self):
print 'Added %s as sysadmin' % username
def remove(self):
- from ckan import model
+ import ckan.model as model
if len(self.args) < 2:
print 'Need name of the user to be made sysadmin.'
@@ -537,7 +537,7 @@ class UserCmd(CkanCommand):
def command(self):
self._load_config()
- from ckan import model
+ import ckan.model as model
if not self.args:
self.list()
@@ -563,7 +563,7 @@ def get_user_str(self, user):
return user_str
def list(self):
- from ckan import model
+ import ckan.model as model
print 'Users:'
users = model.Session.query(model.User)
print 'count = %i' % users.count()
@@ -571,14 +571,14 @@ def list(self):
print self.get_user_str(user)
def show(self):
- from ckan import model
+ import ckan.model as model
username = self.args[0]
user = model.User.get(unicode(username))
print 'User: \n', user
def setpass(self):
- from ckan import model
+ import ckan.model as model
if len(self.args) < 2:
print 'Need name of the user.'
@@ -593,7 +593,7 @@ def setpass(self):
print 'Done'
def search(self):
- from ckan import model
+ import ckan.model as model
if len(self.args) < 2:
print 'Need user name query string.'
@@ -618,7 +618,7 @@ def password_prompt(cls):
return password1
def add(self):
- from ckan import model
+ import ckan.model as model
if len(self.args) < 2:
print 'Need name of the user.'
@@ -671,7 +671,7 @@ def add(self):
print user
def remove(self):
- from ckan import model
+ import ckan.model as model
if len(self.args) < 2:
print 'Need name of the user.'
@@ -704,7 +704,7 @@ class DatasetCmd(CkanCommand):
def command(self):
self._load_config()
- from ckan import model
+ import ckan.model as model
if not self.args:
print self.usage
@@ -722,7 +722,7 @@ def command(self):
self.show(self.args[0])
def list(self):
- from ckan import model
+ import ckan.model as model
print 'Datasets:'
datasets = model.Session.query(model.Package)
print 'count = %i' % datasets.count()
@@ -732,19 +732,19 @@ def list(self):
print '%s %s %s' % (dataset.id, dataset.name, state)
def _get_dataset(self, dataset_ref):
- from ckan import model
+ import ckan.model as model
dataset = model.Package.get(unicode(dataset_ref))
assert dataset, 'Could not find dataset matching reference: %r' % dataset_ref
return dataset
def show(self, dataset_ref):
- from ckan import model
import pprint
dataset = self._get_dataset(dataset_ref)
pprint.pprint(dataset.as_dict())
def delete(self, dataset_ref):
- from ckan import model, plugins
+ from ckan import plugins
+ import ckan.model as model
dataset = self._get_dataset(dataset_ref)
old_state = dataset.state
@@ -756,7 +756,8 @@ def delete(self, dataset_ref):
print '%s %s -> %s' % (dataset.name, old_state, dataset.state)
def purge(self, dataset_ref):
- from ckan import model, plugins
+ from ckan import plugins
+ import ckan.model as model
dataset = self._get_dataset(dataset_ref)
name = dataset.name
@@ -802,7 +803,7 @@ def run_(self):
def view(self):
self._load_config()
- from ckan import model
+ import ckan.model as model
from kombu.transport.sqlalchemy.models import Message
q = model.Session.query(Message)
q_visible = q.filter_by(visible=True)
@@ -816,7 +817,7 @@ def view(self):
def clean(self):
self._load_config()
- from ckan import model
+ import ckan.model as model
import pprint
tasks_initially = model.Session.execute("select * from kombu_message").rowcount
if not tasks_initially:
@@ -847,7 +848,7 @@ class Ratings(CkanCommand):
def command(self):
self._load_config()
- from ckan import model
+ import ckan.model as model
cmd = self.args[0]
if cmd == 'count':
@@ -860,14 +861,14 @@ def command(self):
print 'Command %s not recognized' % cmd
def count(self):
- from ckan import model
+ import ckan.model as model
q = model.Session.query(model.Rating)
print "%i ratings" % q.count()
q = q.filter(model.Rating.user_id == None)
print "of which %i are anonymous ratings" % q.count()
def clean(self, user_ratings=True):
- from ckan import model
+ import ckan.model as model
q = model.Session.query(model.Rating)
print "%i ratings" % q.count()
if not user_ratings:
================================================================
Commit: e3c3c004ff21fa3848d49251310a8a4b399ab496
https://github.com/okfn/ckan/commit/e3c3c004ff21fa3848d49251310a8a4b399ab496
Author: Toby <toby.junk at gmail.com>
Date: 2012-04-20 (Fri, 20 Apr 2012)
Changed paths:
M ckan/plugins/__init__.py
Log Message:
-----------
avoid circular imports in plugins.toolkit
diff --git a/ckan/plugins/__init__.py b/ckan/plugins/__init__.py
index fcb6055..e11e909 100644
--- a/ckan/plugins/__init__.py
+++ b/ckan/plugins/__init__.py
@@ -1,3 +1,19 @@
from ckan.plugins.core import *
from ckan.plugins.interfaces import *
-import toolkit
+
+
+class _Toolkit(object):
+ ''' This object allows us to avoid circular imports while making
+ functions/objects available to plugins. '''
+
+ def __init__(self):
+ self.toolkit = None
+
+ def __getattr__(self, name):
+ if not self.toolkit:
+ import toolkit
+ self.toolkit = toolkit
+ return getattr(self.toolkit, name)
+
+toolkit = _Toolkit()
+del _Toolkit
================================================================
Commit: 0933da5ce0c0179b1f2277e1b53dfd263827e489
https://github.com/okfn/ckan/commit/0933da5ce0c0179b1f2277e1b53dfd263827e489
Author: Toby <toby.junk at gmail.com>
Date: 2012-04-20 (Fri, 20 Apr 2012)
Changed paths:
M ckan/lib/base.py
M ckan/lib/cli.py
M ckan/plugins/__init__.py
M ckan/plugins/toolkit.py
Log Message:
-----------
Merge branch 'master' into enhancement-2251-tracking
diff --git a/ckan/lib/base.py b/ckan/lib/base.py
index da9d69f..075029c 100644
--- a/ckan/lib/base.py
+++ b/ckan/lib/base.py
@@ -22,7 +22,7 @@
import ckan.exceptions
import ckan
-from ckan import authz
+import ckan.authz as authz
from ckan.lib import i18n
import ckan.lib.helpers as h
from ckan.plugins import PluginImplementations, IGenshiStreamFilter
diff --git a/ckan/lib/cli.py b/ckan/lib/cli.py
index 0c6fcbb..4f1c01a 100644
--- a/ckan/lib/cli.py
+++ b/ckan/lib/cli.py
@@ -85,7 +85,7 @@ class ManageDb(CkanCommand):
def command(self):
self._load_config()
- from ckan import model
+ import ckan.model as model
import ckan.lib.search as search
cmd = self.args[0]
@@ -165,7 +165,7 @@ def _postgres_dump(self, filepath):
self._run_cmd(pg_dump_cmd)
def _postgres_load(self, filepath):
- from ckan import model
+ import ckan.model as model
assert not model.repo.are_tables_created(), "Tables already found. You need to 'db clean' before a load."
pg_cmd = self._get_psql_cmd() + ' -f %s' % filepath
self._run_cmd(pg_cmd)
@@ -195,7 +195,7 @@ def load(self, only_load=False):
pg_cmd = self._postgres_load(dump_path)
if not only_load:
print 'Upgrading DB'
- from ckan import model
+ import ckan.model as model
model.repo.upgrade_db()
print 'Rebuilding search index'
@@ -206,7 +206,7 @@ def load(self, only_load=False):
print 'Done'
def simple_dump_csv(self):
- from ckan import model
+ import ckan.model as model
if len(self.args) < 2:
print 'Need csv file path'
return
@@ -216,7 +216,7 @@ def simple_dump_csv(self):
dumper.SimpleDumper().dump(dump_file, format='csv')
def simple_dump_json(self):
- from ckan import model
+ import ckan.model as model
if len(self.args) < 2:
print 'Need json file path'
return
@@ -453,7 +453,7 @@ class Sysadmin(CkanCommand):
def command(self):
self._load_config()
- from ckan import model
+ import ckan.model as model
cmd = self.args[0] if self.args else None
if cmd == None or cmd == 'list':
@@ -466,7 +466,7 @@ def command(self):
print 'Command %s not recognized' % cmd
def list(self):
- from ckan import model
+ import ckan.model as model
print 'Sysadmins:'
sysadmins = model.Session.query(model.SystemRole).filter_by(role=model.Role.ADMIN)
print 'count = %i' % sysadmins.count()
@@ -478,7 +478,7 @@ def list(self):
user_or_authgroup.id)
def add(self):
- from ckan import model
+ import ckan.model as model
if len(self.args) < 2:
print 'Need name of the user to be made sysadmin.'
@@ -502,7 +502,7 @@ def add(self):
print 'Added %s as sysadmin' % username
def remove(self):
- from ckan import model
+ import ckan.model as model
if len(self.args) < 2:
print 'Need name of the user to be made sysadmin.'
@@ -538,7 +538,7 @@ class UserCmd(CkanCommand):
def command(self):
self._load_config()
- from ckan import model
+ import ckan.model as model
if not self.args:
self.list()
@@ -564,7 +564,7 @@ def get_user_str(self, user):
return user_str
def list(self):
- from ckan import model
+ import ckan.model as model
print 'Users:'
users = model.Session.query(model.User)
print 'count = %i' % users.count()
@@ -572,14 +572,14 @@ def list(self):
print self.get_user_str(user)
def show(self):
- from ckan import model
+ import ckan.model as model
username = self.args[0]
user = model.User.get(unicode(username))
print 'User: \n', user
def setpass(self):
- from ckan import model
+ import ckan.model as model
if len(self.args) < 2:
print 'Need name of the user.'
@@ -594,7 +594,7 @@ def setpass(self):
print 'Done'
def search(self):
- from ckan import model
+ import ckan.model as model
if len(self.args) < 2:
print 'Need user name query string.'
@@ -619,7 +619,7 @@ def password_prompt(cls):
return password1
def add(self):
- from ckan import model
+ import ckan.model as model
if len(self.args) < 2:
print 'Need name of the user.'
@@ -672,7 +672,7 @@ def add(self):
print user
def remove(self):
- from ckan import model
+ import ckan.model as model
if len(self.args) < 2:
print 'Need name of the user.'
@@ -705,7 +705,7 @@ class DatasetCmd(CkanCommand):
def command(self):
self._load_config()
- from ckan import model
+ import ckan.model as model
if not self.args:
print self.usage
@@ -723,7 +723,7 @@ def command(self):
self.show(self.args[0])
def list(self):
- from ckan import model
+ import ckan.model as model
print 'Datasets:'
datasets = model.Session.query(model.Package)
print 'count = %i' % datasets.count()
@@ -733,19 +733,19 @@ def list(self):
print '%s %s %s' % (dataset.id, dataset.name, state)
def _get_dataset(self, dataset_ref):
- from ckan import model
+ import ckan.model as model
dataset = model.Package.get(unicode(dataset_ref))
assert dataset, 'Could not find dataset matching reference: %r' % dataset_ref
return dataset
def show(self, dataset_ref):
- from ckan import model
import pprint
dataset = self._get_dataset(dataset_ref)
pprint.pprint(dataset.as_dict())
def delete(self, dataset_ref):
- from ckan import model, plugins
+ from ckan import plugins
+ import ckan.model as model
dataset = self._get_dataset(dataset_ref)
old_state = dataset.state
@@ -757,7 +757,8 @@ def delete(self, dataset_ref):
print '%s %s -> %s' % (dataset.name, old_state, dataset.state)
def purge(self, dataset_ref):
- from ckan import model, plugins
+ from ckan import plugins
+ import ckan.model as model
dataset = self._get_dataset(dataset_ref)
name = dataset.name
@@ -803,7 +804,7 @@ def run_(self):
def view(self):
self._load_config()
- from ckan import model
+ import ckan.model as model
from kombu.transport.sqlalchemy.models import Message
q = model.Session.query(Message)
q_visible = q.filter_by(visible=True)
@@ -817,7 +818,7 @@ def view(self):
def clean(self):
self._load_config()
- from ckan import model
+ import ckan.model as model
import pprint
tasks_initially = model.Session.execute("select * from kombu_message").rowcount
if not tasks_initially:
@@ -848,7 +849,7 @@ class Ratings(CkanCommand):
def command(self):
self._load_config()
- from ckan import model
+ import ckan.model as model
cmd = self.args[0]
if cmd == 'count':
@@ -861,14 +862,14 @@ def command(self):
print 'Command %s not recognized' % cmd
def count(self):
- from ckan import model
+ import ckan.model as model
q = model.Session.query(model.Rating)
print "%i ratings" % q.count()
q = q.filter(model.Rating.user_id == None)
print "of which %i are anonymous ratings" % q.count()
def clean(self, user_ratings=True):
- from ckan import model
+ import ckan.model as model
q = model.Session.query(model.Rating)
print "%i ratings" % q.count()
if not user_ratings:
diff --git a/ckan/plugins/__init__.py b/ckan/plugins/__init__.py
index fcb6055..e11e909 100644
--- a/ckan/plugins/__init__.py
+++ b/ckan/plugins/__init__.py
@@ -1,3 +1,19 @@
from ckan.plugins.core import *
from ckan.plugins.interfaces import *
-import toolkit
+
+
+class _Toolkit(object):
+ ''' This object allows us to avoid circular imports while making
+ functions/objects available to plugins. '''
+
+ def __init__(self):
+ self.toolkit = None
+
+ def __getattr__(self, name):
+ if not self.toolkit:
+ import toolkit
+ self.toolkit = toolkit
+ return getattr(self.toolkit, name)
+
+toolkit = _Toolkit()
+del _Toolkit
diff --git a/ckan/plugins/toolkit.py b/ckan/plugins/toolkit.py
index 27e0fd0..e635c43 100644
--- a/ckan/plugins/toolkit.py
+++ b/ckan/plugins/toolkit.py
@@ -1,7 +1,7 @@
## This file is intended to make functions/objects consistently
## available to plugins whilst giving developers the ability move code
## around or change underlying frameworks etc. It should not be used
-## internaly within ckan only by extensions. Functions should only be
+## internally within ckan only by extensions. Functions should only be
## removed from this file after reasonable depreciation notice has
## been given.
@@ -34,7 +34,7 @@
'literal', # stop tags in a string being escaped
'get_action', # get logic action function
'check_access', # check logic function authorisation
- 'NotFound', # action not found exception
+ 'ActionNotFound', # action not found exception (ckan.logic.NotFound)
'NotAuthorized', # action not authorized exception
'ValidationError', # model update validation error
'CkanCommand', # class for providing cli interfaces
@@ -59,7 +59,7 @@
get_action = logic.get_action
check_access = logic.check_access
-NotFound = logic.NotFound
+ActionNotFound = logic.NotFound ## Name change intentional
NotAuthorized = logic.NotAuthorized
ValidationError = logic.ValidationError
================================================================
Commit: 45e73b1226a3810d34ac67b8cbe876d379a927bf
https://github.com/okfn/ckan/commit/45e73b1226a3810d34ac67b8cbe876d379a927bf
Author: Toby <toby.junk at gmail.com>
Date: 2012-04-20 (Fri, 20 Apr 2012)
Changed paths:
M ckan/lib/cli.py
M ckan/model/package.py
Log Message:
-----------
add tracking command for paster
diff --git a/ckan/lib/cli.py b/ckan/lib/cli.py
index 4f1c01a..6ca8e1f 100644
--- a/ckan/lib/cli.py
+++ b/ckan/lib/cli.py
@@ -1,4 +1,5 @@
import os
+import datetime
import sys
import logging
import datetime
@@ -894,7 +895,7 @@ class Tracking(CkanCommand):
def command(self):
self._load_config()
- from ckan import model
+ import ckan.model as model
engine = model.meta.engine
if len(self.args) == 1:
@@ -977,4 +978,3 @@ def update_tracking(self, engine, summary_date):
AND t1.package_id IS NOT NULL
AND t1.package_id != '~~not~found~~';'''
engine.execute(sql)
-
diff --git a/ckan/model/package.py b/ckan/model/package.py
index 4365963..a65c1d3 100644
--- a/ckan/model/package.py
+++ b/ckan/model/package.py
@@ -170,6 +170,7 @@ def add_tag(self, tag):
package_tag = model.PackageTag(self, tag)
model.Session.add(package_tag)
+
def add_tags(self, tags):
for tag in tags:
self.add_tag(tag)
================================================================
Commit: 680d751cdd05e87a01ae828625b6adfd86d0925d
https://github.com/okfn/ckan/commit/680d751cdd05e87a01ae828625b6adfd86d0925d
Author: Toby <toby.junk at gmail.com>
Date: 2012-04-20 (Fri, 20 Apr 2012)
Changed paths:
M ckan/lib/helpers.py
Log Message:
-----------
remove now redundant helpers
diff --git a/ckan/lib/helpers.py b/ckan/lib/helpers.py
index e9a11c9..b4dd06e 100644
--- a/ckan/lib/helpers.py
+++ b/ckan/lib/helpers.py
@@ -658,32 +658,6 @@ def _auto_log_message():
return _('Edited settings.')
return ''
-def tracking_count_package(package_id):
- import ckan.model as model
- sql = '''SELECT running_total
- FROM tracking_summary
- WHERE package_id='%s'
- ORDER BY date DESC LIMIT 1''' % package_id
- result = model.Session.execute(sql).fetchall()
- if result:
- count = result[0]['running_total']
- return literal('<span title="') + 'Viewed %s times' % count + literal('"><i class="icon-eye-open"></i> %s</span>' % count)
- else:
- return literal('<span> </span>')
-
-def tracking_count_resource(url):
- import ckan.model as model
- sql = '''SELECT running_total
- FROM tracking_summary
- WHERE url='%s'
- ORDER BY date DESC LIMIT 1''' % url
- result = model.Session.execute(sql).fetchall()
- if result:
- count = result[0]['running_total']
- return literal('<span title="') + 'Downloaded %s times' % count + literal('"><i class="icon-eye-open"></i> %s</span>' % count)
- else:
- return literal('<span> </span>')
-
def activity_div(template, activity, actor, object=None, target=None):
actor = '<span class="actor">%s</span>' % actor
if object:
================================================================
Compare: https://github.com/okfn/ckan/compare/a411e22...680d751
More information about the ckan-changes
mailing list