Skip to content

Commit

Permalink
[#2618] extensions can add resource libs
Browse files Browse the repository at this point in the history
  • Loading branch information
tobes committed Aug 16, 2012
1 parent 4106f7e commit 8f70817
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions ckan/plugins/toolkit.py
Expand Up @@ -50,6 +50,7 @@ class _Toolkit(object):

## Fully defined in this file ##
'add_template_directory',
'add_resource',
'add_public_directory',
'requires_ckan_version',
'check_ckan_version',
Expand Down Expand Up @@ -97,6 +98,7 @@ def _initialize(self):
t['render_snippet'] = self._render_snippet
t['add_template_directory'] = self._add_template_directory
t['add_public_directory'] = self._add_public_directory
t['add_resource'] = self._add_resource
t['requires_ckan_version'] = self._requires_ckan_version
t['check_ckan_version'] = self._check_ckan_version
t['CkanVersionException'] = CkanVersionException
Expand Down Expand Up @@ -145,6 +147,18 @@ def _add_served_directory(cls, config, relative_path, config_var):
else:
config[config_var] = absolute_path

@classmethod
def _add_resource(cls, path, name):
# we want the filename that of the function caller but they will
# have used one of the available helper functions
frame, filename, line_number, function_name, lines, index =\
inspect.getouterframes(inspect.currentframe())[1]

this_dir = os.path.dirname(filename)
absolute_path = os.path.join(this_dir, path)
import ckan.lib.fanstatic_resources
ckan.lib.fanstatic_resources.create_library(name, absolute_path)

@classmethod
def _version_str_2_list(cls, v_str):
''' convert a version string into a list of ints
Expand Down

0 comments on commit 8f70817

Please sign in to comment.