Commit 2b54d21f authored by Pablo Panero's avatar Pablo Panero
Browse files

Initial commit with project files: schemas and records query working. TODO:...

Initial commit with project files: schemas and records query working. TODO: permissions to support POST
parent 40627493
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function
from .version import __version__
__all__ = ('__version__', )
\ No newline at end of file
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function
def _(x):
"""Identity function used to trigger string extraction."""
return x
# JSON Schemas configuration
# ==========================
JSONSCHEMAS_ENDPOINT = '/schemas'
JSONSCHEMAS_HOST = '0.0.0.0'
# Do not register the endpoints on the UI app."""
JSONSCHEMAS_REGISTER_ENDPOINTS_UI = False
# Search configuration
# =====================
SEARCH_MAPPINGS = ['records']
# SEARCH_ELASTIC_HOSTS = None # default localhost
# Records REST configuration
# =====================
#: Records REST API configuration
_Record_PID = 'pid(recid, record_class="cern_search_rest.modules.records.api:CernSearchRecord")' # TODO
RECORDS_REST_ENDPOINTS = dict(
docid=dict(
pid_type='recid',
pid_fetcher='recid',
pid_minter='recid',
default_endpoint_prefix=True,
default_media_type='application/json',
item_route='/record/<{0}:pid_value>'.format(_Record_PID),
list_route='/records/',
links_factory_imp='invenio_records_rest.links:default_links_factory',
record_class='cern_search_rest.modules.records.api:CernSearchRecord', # TODO
# record_loaders={ # TODO
# 'application/json': 'mypackage.loaders:json_loader'
# },
record_serializers={
'application/json': ('invenio_records_rest.serializers'
':json_v1_response'),
},
search_class=' invenio_search.api.RecordsSearch',
# search_factory_imp=search_factory(), # Default TODO
search_index='records',
search_serializers={
'application/json': ('invenio_records_rest.serializers'
':json_v1_search'),
},
# suggesters= {}, # TODO
# use_options_view=True, # TODO
max_result_window=10000,
read_permission_factory_imp=permission_check_factory(),
create_permission_factory_imp=deposit_read_permission_factory,
update_permission_factory_imp=permission_check_factory(),
delete_permission_factory_imp=deposit_read_permission_factory,
# error_handlers={}, # TODO
)
)
{
"title": "Custom record schema v0.0.1",
"id": "http://localhost:5000/schemas/doc-v0.0.1.json",
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"title": {
"type": "string",
"description": "Record title."
},
"description": {
"type": "string",
"description": "Description for record."
},
"custom_pid": {
"type": "string"
},
"$schema": {
"type": "string"
}
}
}
\ No newline at end of file
{
"settings": {
"index.percolator.map_unmapped_fields_as_string": true,
"index.mapping.total_fields.limit": 3000
},
"mappings": {
"doc-v0.0.1": {
"numeric_detection": true,
"_all": {
"analyzer": "english"
},
"properties": {
"title": {
"type": "string",
"analyzer": "english"
},
"description": {
"type": "string",
"analyzer": "english"
},
"custom_pid": {
"type": "string",
"index": "not_analyzed"
},
"$schema": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
\ No newline at end of file
#!/usr/bin/python
# -*- coding: utf-8 -*-
\ No newline at end of file
# -*- coding: utf-8 -*-
"""Version information for CERNSearch_REST.
This file is imported by ``cern_search_rest.__init__``,
and parsed by ``setup.py``.
"""
from __future__ import absolute_import, print_function
__version__ = '0.0.1a1'
\ No newline at end of file
# -*- coding: utf-8 -*-
import os
from setuptools import find_packages, setup
readme = open('README.rst').read()
history = open('CHANGES.rst').read()
tests_require = []
invenio_db_version = '>=1.0.0b8,<1.1.0'
extras_require = {
# Databases
'mysql': [
'invenio-db[mysql]' + invenio_db_version,
],
'postgresql': [
'invenio-db[postgresql]' + invenio_db_version,
],
# Elasticsearch
'elasticsearch5': [
'elasticsearch>=5.0.0,<6.0.0',
'elasticsearch-dsl>=5.0.0,<6.0.0',
],
'docs': [
'Sphinx>=1.5.1',
],
'tests': tests_require,
}
extras_require['all'] = []
for name, reqs in extras_require.items():
if name in ('mysql', 'postgresql', 'elasticsearch5'):
continue
extras_require['all'].extend(reqs)
setup_requires = []
install_requires = [
'invenio-app>=1.0.0b1,<1.1.0',
'invenio-base>=1.0.0a15,<1.1.0',
'invenio-config>=1.0.0b3,<1.1.0',
'invenio-jsonschemas>=1.0.0a5,<1.1.0',
'invenio-records-rest>=1.0.0b1,<1.1.0',
'invenio-records[mysql]>=1.0.0b2',
'invenio-rest[cors]>=1.0.0b2',
'invenio-search>=1.0.0a10,<1.1.0',
'redis>=2.10.0',
]
packages = find_packages()
# Get the version string. Cannot be done with import!
g = {}
with open(os.path.join("cern_search_rest", "version.py"), "rt") as fp:
exec(fp.read(), g)
version = g["__version__"]
setup(
name='cern-search-rest',
version=version,
description='CERN Search as a Service',
long_description=readme + '\n\n' + history,
license='GPLv3',
author='CERN',
author_email='cernsearch.support@cern.ch',
url='http://search.cern.ch/',
packages=packages,
zip_safe=False,
include_package_data=True,
platforms='any',
entry_points={
'invenio_config.module': [
'cern_search_rest = cern_search_rest.config',
],
'invenio_search.mappings': [
'records = cern_search_rest.mappings',
],
'invenio_jsonschemas.schemas': [
'cern_search_rest_schemas = cern_search_rest.jsonschemas'
],
},
extras_require=extras_require,
install_requires=install_requires,
setup_requires=setup_requires,
tests_require=tests_require,
classifiers=[
'Environment :: Web Environment',
'Intended Audience :: Developers',
'License :: OSI Approved :: GNU General Public License v2 (GPLv2)',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Topic :: Software Development :: Libraries :: Python Modules',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Development Status :: 2 - Pre-Alpha',
],
)
\ No newline at end of file
Supports Markdown
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