2016-11-14 73 views
0

我試圖按照this教程定製CKAN模板,但我似乎無法運行開發服務器(貼膜服務/etc/ckan/default/development.ini),因爲一個錯誤'的導入錯誤:沒有名爲插件'的模塊。CKAN自定義主題錯誤

這是plugin.py代碼(位於/usr/lib/ckan/default/src/ckanext-example_theme/ckanext/example_theme/plugin.py)設置的

import ckan.plugins as plugins 
import ckan.plugins.toolkit as toolkit 
from ckan.common import config 

def show_most_popular_groups(): 
    value = config.get('ckan.example_theme.show_most_popular_groups',False) 
    value = toolkit.asbool(value) 
    return value 

def most_popular_groups(): 
    groups = toolkit.get_action('group_list')(data_dict={'sort' : 'package_count_desc', 'all_fields' : True}) 
    groups = groups[0:10] 

    return groups 

class Example_ThemePlugin(plugins.SingletonPlugin): 
    plugins.implements(plugins.IConfigurer) 
    plugins.implements(plugins.ITemplateHelpers) 
    # IConfigurer 

def update_config(self, config_): 
    toolkit.add_template_directory(config_, 'templates') 
    toolkit.add_public_directory(config_, 'public') 
    toolkit.add_resource('fanstatic', 'example_theme') 

def get_helpers(self): 
    return {'example_theme_most_popular_groups' : most_popular_groups, 
      'example_theme_show_most_popular_groups' : show_most_popular_groups} 

一部分。 PY源代碼是這樣的(位於/usr/lib/ckan/default/src/ckanext-example_theme/setup.py

entry_points=''' 
    [ckan.plugins] 
    example_theme=ckanext.example_theme.plugin:Example_ThemePlugin 

    [babel.extractors] 
    ckan = ckan.lib.extract:extract_ckan 
''', 

當運行蟒setup.py開發它ř UNS succesfully.However,當我運行/etc/ckan/default/development.ini它導致錯誤與消息貼膜服務器「導入錯誤:沒有模塊名爲插件

我已經包括在發展中的插件.ini文件(插件名稱爲example_theme)

ckan.plugins = stats text_view image_view recline_view pdf_view datastore datapusher **example_theme** 

有人可以幫我解決這個問題嗎?我哪裏做錯了?

任何幫助將不勝感激。由於

編輯 這是錯誤消息:

/usr/lib/ckan/default/local/lib/python2.7/site-packages/pylons/configuration.py:26: RuntimeWarning: Unable to load template engine entry point: 'pylonsmyghty = pylons.templating:MyghtyTemplatePlugin [myghty]': Traceback (most recent call last): 
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/pylons/templating.py", line 610, in <module> 
Engine = entry_point.load() 
File "/usr/lib/ckan/default/local/lib/python2.7/site-package/pkg_resources/__init__.py", line 2228, in load 
self.require(*args, **kwargs) 
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2245, in require 
items = working_set.resolve(reqs, env, installer) 
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 808, in resolve 
if not req_extras.markers_pass(req): 
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 993, in markers_pass 
return not req.marker or any(extra_evals) or req.marker.evaluate() 
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/pkg_resources/_vendor/packaging/markers.py", line 278, in evaluate 
return _evaluate_markers(self._markers, current_environment) 
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/pkg_resources/_vendor/packaging/markers.py", line 203, in _evaluate_markers 
lhs_value = _get_env(environment, lhs.value) 
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/pkg_resources/_vendor/packaging/markers.py", line 185, in _get_env 
"{0!r} does not exist in evaluation environment.".format(name) 

UndefinedEnvironmentName: 'extra' does not exist in evaluation environment. 

import pylons.templating 
Traceback (most recent call last): 
File "/usr/lib/ckan/default/bin/paster", line 11, in <module> 
sys.exit(run()) 
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/script/command.py", line 102, in run 
invoke(command, command_name, options, args[1:]) 
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/script/command.py", line 141, in invoke 
exit_code = runner.run(args) 
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/script/command.py", line 236, in run 
result = self.command() 
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/script/serve.py", line 284, in command 
relative_to=base, global_conf=vars) 
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/script/serve.py", line 329, in loadapp 
**kw) 
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 247, in loadapp 
return loadobj(APP, uri, name=name, **kw) 
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 272, in loadobj 
return context.create() 
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 710, in create 
return self.object_type.invoke(self) 
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 146, in invoke 
return fix_call(context.object, context.global_conf, **context.local_conf) 
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/deploy/util.py", line 55, in fix_call 
val = callable(*args, **kw) 
File "/home/fajarmp/ckan/lib/default/src/ckan/ckan/config/middleware/__init__.py", line 45, in make_app 
load_environment(conf, app_conf) 
File "/home/fajarmp/ckan/lib/default/src/ckan/ckan/config/environment.py", line 97, in load_environment 
p.load_all() 
File "/home/fajarmp/ckan/lib/default/src/ckan/ckan/plugins/core.py", line 139, in load_all 
load(*plugins) 
File "/home/fajarmp/ckan/lib/default/src/ckan/ckan/plugins/core.py", line 153, in load 
service = _get_service(plugin) 
File "/home/fajarmp/ckan/lib/default/src/ckan/ckan/plugins/core.py", line 255, in _get_service 
return plugin.load()(name=plugin_name) 
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2229, in load 
return self.resolve() 
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2235, in resolve 
module = __import__(self.module_name, fromlist=['__name__'], level=0) 
ImportError: No module named plugin 
+0

@HendrikBunke完成了,請參閱編輯 – djargonforce

+0

您是否在virtualenv中安裝了擴展? 'pip install -e ' –

+0

你的意思是像pip install -e requirements.txt? – djargonforce

回答

0

嘗試使用這些插件設置:

ckan.plugins = stats text_view recline_view example_theme 
ckan.plugins = stats text_view image_view recline_view 

把它們的順序,它應該工作。 我注意到我以前互換過。

+0

仍然會產生錯誤。這裏是我的production.ini btw: ckan.plugins = stats text_view recline_view example_theme ckan.plugins = stats text_view image_view recilne_view pdf_view datastore datapusher – djargonforce