Commit edeaaf5c authored by David Read's avatar David Read
Browse files

Mention installing SNI support. Fixes from sorting out qa. Style.

parent a2e85a91
......@@ -157,6 +157,34 @@ To delete all the items on the queue::
redis-cli -n 1 DEL bulk
Installing SNI support
----------------------
When archiving resources on servers which use HTTPS, you might encounter this error::
requests.exceptions.SSLError: [Errno 1] _ssl.c:504: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure
Whilst this could be a problem with the server, it is likely due to you needing to install SNI support on the machine that ckanext-archiver runs. Server Name Indication (SNL) is for when a server has multiple SSL certificates, which is a relatively new feature. This requires installing a recent version of OpenSSL plus the python libraries to make use of this feature..
If you have SNI support installed then this should run without the error::
python -c 'import requests; requests.get("http://files.datapress.com")'
On Ubuntu 12.04 you can install SNI support by doing this::
sudo apt-get install libffi-dev
. /usr/lib/ckan/default/bin/activate
pip install 'cryptography==0.9.3' pyOpenSSL ndg-httpsclient pyasn1
You should also check your OpenSSL version is greater than 1.0.0. Apparently SNI was added in 0.9.8j but apparently there are reported problems with 0.9.8y, 0.9.8zc & 0.9.8zg so 1.0.0+ is recommended.
python -c "import ssl; print ssl.OPENSSL_VERSION"
For more about enabling SNI in python requests see:
* https://stackoverflow.com/questions/18578439/using-requests-with-tls-doesnt-give-sni-support/18579484#18579484
* https://github.com/kennethreitz/requests/issues/2022
Config settings
---------------
......@@ -299,3 +327,12 @@ My site has an IDatasetForm already - how can I include the archiver information
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you have another extension with an IDatasetForm for customizing the dataset form/schema, then you can simply add to it the schema customizations from this module - see this module's plugins.py in the section for IDatasetForm.
'SSL handshake' error
~~~~~~~~~~~~~~~~~~~~~
When archiving resources on servers which use HTTPS, you might encounter this error::
requests.exceptions.SSLError: [Errno 1] _ssl.c:504: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure
This is probably because you don't have SNI support and requires installing OpenSSL - see section "Installing SNI support".
......@@ -31,7 +31,7 @@ def archiver_is_resource_cached_html(resource):
# Replacement for the core ckan helper 'format_resource_items'
# but with our own blacklist
def archiver_format_resource_items(items):
blacklist = ['archiver']
blacklist = ['archiver', 'qa']
items_ = [item for item in items
if item[0] not in blacklist]
import ckan.lib.helpers as ckan_helpers
......
import logging
import ckan.logic as logic
import ckan.plugins as p
from ckan import model
from ckanext.archiver.model import Archival, aggregate_archivals_for_a_dataset
NotFound = logic.NotFound
_get_or_bust = logic.get_or_bust
ObjectNotFound = p.toolkit.ObjectNotFound
_get_or_bust = p.toolkit.get_or_bust
log = logging.getLogger(__name__)
......@@ -23,7 +22,7 @@ def archiver_resource_show(context, data_dict=None):
id_ = _get_or_bust(data_dict, 'id')
archival = Archival.get_for_resource(id_)
if archival is None:
raise NotFound
raise ObjectNotFound
archival_dict = archival.as_dict()
p.toolkit.check_access('archiver_resource_show', context, data_dict)
return archival_dict
......@@ -42,7 +41,7 @@ def archiver_dataset_show(context, data_dict=None):
id_ = _get_or_bust(data_dict, 'id')
dataset = model.Package.get(id_)
if not dataset:
raise NotFound
raise ObjectNotFound
archivals = Archival.get_for_package(dataset.id)
archival_dict = aggregate_archivals_for_a_dataset(archivals)
p.toolkit.check_access('archiver_dataset_show', context, data_dict)
......
......@@ -4,7 +4,6 @@ import logging
from ckan import model
from ckan.model.types import make_uuid
from ckan import plugins as p
import ckan.plugins.toolkit as toolkit
from ckan.lib.celery_app import celery
from ckanext.report.interfaces import IReport
......@@ -16,7 +15,7 @@ from ckanext.archiver.model import Archival, aggregate_archivals_for_a_dataset
log = logging.getLogger(__name__)
class ArchiverPlugin(p.SingletonPlugin, toolkit.DefaultDatasetForm):
class ArchiverPlugin(p.SingletonPlugin, p.toolkit.DefaultDatasetForm):
"""
Registers to be notified whenever CKAN resources are created or their URLs
change, and will create a new ckanext.archiver celery task to archive the
......@@ -28,7 +27,7 @@ class ArchiverPlugin(p.SingletonPlugin, toolkit.DefaultDatasetForm):
p.implements(p.IActions)
p.implements(p.IAuthFunctions)
p.implements(p.ITemplateHelpers)
p.implements(p.IDatasetForm, inherit=True)
#p.implements(p.IDatasetForm, inherit=True)
# IDomainObjectModification
......@@ -51,7 +50,7 @@ class ArchiverPlugin(p.SingletonPlugin, toolkit.DefaultDatasetForm):
# IConfigurer
def update_config(self, config):
toolkit.add_template_directory(config, 'templates')
p.toolkit.add_template_directory(config, 'templates')
# IActions
......@@ -75,6 +74,7 @@ class ArchiverPlugin(p.SingletonPlugin, toolkit.DefaultDatasetForm):
if callable(function) and name[0] != '_')
# IDatasetForm
def package_types(self):
return ['dataset']
......@@ -87,17 +87,17 @@ class ArchiverPlugin(p.SingletonPlugin, toolkit.DefaultDatasetForm):
return True
def update_package_schema(self):
schema = toolkit.DefaultDatasetForm.update_package_schema(self)
schema = p.toolkit.DefaultDatasetForm.update_package_schema(self)
# don't save archiver info in the dataset, since it is stored in the
# archival table instead, and the value added into the package_show
# result in the show_package_schema
ignore = toolkit.get_validator('ignore')
ignore = p.toolkit.get_validator('ignore')
schema['archiver'] = [ignore]
schema['resources']['archiver'] = [ignore]
return schema
def show_package_schema(self):
schema = toolkit.DefaultDatasetForm.show_package_schema(self)
schema = p.toolkit.DefaultDatasetForm.show_package_schema(self)
schema['archiver'] = [add_archival_information]
return schema
......@@ -121,8 +121,8 @@ def add_archival_information(key, data, errors, context):
break
res_id = data[res_id_key]
archival = archivals_by_res_id.get(res_id)
archival_dict = archival.as_dict()
if archival:
archival_dict = archival.as_dict()
del archival_dict['id']
del archival_dict['package_id']
del archival_dict['resource_id']
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment