# Path: invenio_pidstore/ext.py
# class InvenioPIDStore(object):
#     """Invenio-PIDStore extension."""
# 
#     def __init__(self, app=None,
#                  minters_entry_point_group='invenio_pidstore.minters',
#                  fetchers_entry_point_group='invenio_pidstore.fetchers'):
#         """Extension initialization.
# 
#         :param minters_entry_point_group: The entrypoint for minters.
#             (Default: `invenio_pidstore.minters`).
#         :param fetchers_entry_point_group: The entrypoint for fetchers.
#             (Default: `invenio_pidstore.fetchers`).
#         """
#         if app:
#             self._state = self.init_app(
#                 app, minters_entry_point_group=minters_entry_point_group,
#                 fetchers_entry_point_group=fetchers_entry_point_group
#             )
# 
#     def init_app(self, app, minters_entry_point_group=None,
#                  fetchers_entry_point_group=None):
#         """Flask application initialization.
# 
#         Initialize:
# 
#         * The CLI commands.
# 
#         * Initialize the logger (Default: `app.debug`).
# 
#         * Initialize the default admin object link endpoint.
#             (Default: `{"rec": "recordmetadata.details_view"}` if
#             `invenio-records` is installed, otherwise `{}`).
# 
#         * Register the `pid_exists` template filter.
# 
#         * Initialize extension state.
# 
#         :param app: The Flask application
#         :param minters_entry_point_group: The minters entry point group
#             (Default: None).
#         :param fetchers_entry_point_group: The fetchers entry point group
#             (Default: None).
#         :returns: PIDStore state application.
#         """
#         self.init_config(app)
#         # Initialize CLI
#         app.cli.add_command(cmd)
# 
#         # Initialize logger
#         app.config.setdefault('PIDSTORE_APP_LOGGER_HANDLERS', app.debug)
#         if app.config['PIDSTORE_APP_LOGGER_HANDLERS']:
#             for handler in app.logger.handlers:
#                 logger.addHandler(handler)
# 
#         # Initialize admin object link endpoints.
#         try:
#             pkg_resources.get_distribution('invenio-records')
#             app.config.setdefault('PIDSTORE_OBJECT_ENDPOINTS', dict(
#                 rec='recordmetadata.details_view',
#             ))
#         except pkg_resources.DistributionNotFound:
#             app.config.setdefault('PIDSTORE_OBJECT_ENDPOINTS', {})
# 
#         # Register template filter
#         app.jinja_env.filters['pid_exists'] = pid_exists
# 
#         # Initialize extension state.
#         state = _PIDStoreState(
#             app=app,
#             minters_entry_point_group=minters_entry_point_group,
#             fetchers_entry_point_group=fetchers_entry_point_group,
#         )
#         app.extensions['invenio-pidstore'] = state
#         return state
# 
#     def init_config(self, app):
#         """Initialize configuration."""
#         for k in dir(config):
#             if k.startswith('PIDSTORE_') and k not in (
#                     'PIDSTORE_OBJECT_ENDPOINTS',
#                     'PIDSTORE_APP_LOGGER_HANDLERS'):
#                 app.config.setdefault(k, getattr(config, k))
# 
#     def __getattr__(self, name):
#         """Proxy to state object."""
#         return getattr(self._state, name, None)


import os
from flask import Flask
from flask_babelex import Babel
from flask_menu import Menu
from invenio_access import InvenioAccess
from invenio_accounts import InvenioAccounts
from invenio_accounts.views import blueprint as accounts_blueprint
from invenio_admin import InvenioAdmin
from invenio_db import InvenioDB
from invenio_records import InvenioRecords
from invenio_pidstore import InvenioPIDStore
    $ ./app-teardown.sh

SPHINX-END

"""

from __future__ import absolute_import, print_function



# Create Flask application
app = Flask(__name__)
app.config.update(
    DB_VERSIONING_USER_MODEL=None,
    SECRET_KEY='test_key',
    SECURITY_PASSWORD_HASH='pbkdf2_sha512',
    SECURITY_PASSWORD_SALT="CHANGE_ME_ALSO",
    SECURITY_PASSWORD_SCHEMES=[
        'pbkdf2_sha512', 'sha512_crypt', 'invenio_aes_encrypted_email'
    ],
    SQLALCHEMY_DATABASE_URI=os.environ.get(
        'SQLALCHEMY_DATABASE_URI', 'sqlite:///test.db'
    ),
    WTF_CSRF_ENABLED=False,
)

Babel(app)
Menu(app)
InvenioDB(app)
admin = InvenioAdmin(app)

# Path: invenio_pidstore/ext.py
# class InvenioPIDStore(object):
#     """Invenio-PIDStore extension."""
# 
#     def __init__(self, app=None,
#                  minters_entry_point_group='invenio_pidstore.minters',
#                  fetchers_entry_point_group='invenio_pidstore.fetchers'):
#         """Extension initialization.
# 
#         :param minters_entry_point_group: The entrypoint for minters.
#             (Default: `invenio_pidstore.minters`).
#         :param fetchers_entry_point_group: The entrypoint for fetchers.
#             (Default: `invenio_pidstore.fetchers`).
#         """
#         if app:
#             self._state = self.init_app(
#                 app, minters_entry_point_group=minters_entry_point_group,
#                 fetchers_entry_point_group=fetchers_entry_point_group
#             )
# 
#     def init_app(self, app, minters_entry_point_group=None,
#                  fetchers_entry_point_group=None):
#         """Flask application initialization.
# 
#         Initialize:
# 
#         * The CLI commands.
# 
#         * Initialize the logger (Default: `app.debug`).
# 
#         * Initialize the default admin object link endpoint.
#             (Default: `{"rec": "recordmetadata.details_view"}` if
#             `invenio-records` is installed, otherwise `{}`).
# 
#         * Register the `pid_exists` template filter.
# 
#         * Initialize extension state.
# 
#         :param app: The Flask application
#         :param minters_entry_point_group: The minters entry point group
#             (Default: None).
#         :param fetchers_entry_point_group: The fetchers entry point group
#             (Default: None).
#         :returns: PIDStore state application.
#         """
#         self.init_config(app)
#         # Initialize CLI
#         app.cli.add_command(cmd)
# 
#         # Initialize logger
#         app.config.setdefault('PIDSTORE_APP_LOGGER_HANDLERS', app.debug)
#         if app.config['PIDSTORE_APP_LOGGER_HANDLERS']:
#             for handler in app.logger.handlers:
#                 logger.addHandler(handler)
# 
#         # Initialize admin object link endpoints.
#         try:
#             pkg_resources.get_distribution('invenio-records')
#             app.config.setdefault('PIDSTORE_OBJECT_ENDPOINTS', dict(
#                 rec='recordmetadata.details_view',
#             ))
#         except pkg_resources.DistributionNotFound:
#             app.config.setdefault('PIDSTORE_OBJECT_ENDPOINTS', {})
# 
#         # Register template filter
#         app.jinja_env.filters['pid_exists'] = pid_exists
# 
#         # Initialize extension state.
#         state = _PIDStoreState(
#             app=app,
#             minters_entry_point_group=minters_entry_point_group,
#             fetchers_entry_point_group=fetchers_entry_point_group,
#         )
#         app.extensions['invenio-pidstore'] = state
#         return state
# 
#     def init_config(self, app):
#         """Initialize configuration."""
#         for k in dir(config):
#             if k.startswith('PIDSTORE_') and k not in (
#                     'PIDSTORE_OBJECT_ENDPOINTS',
#                     'PIDSTORE_APP_LOGGER_HANDLERS'):
#                 app.config.setdefault(k, getattr(config, k))
# 
#     def __getattr__(self, name):
#         """Proxy to state object."""
#         return getattr(self._state, name, None)


# Path: examples/app.py
import os
from flask import Flask
from flask_babelex import Babel
from flask_menu import Menu
from invenio_access import InvenioAccess
from invenio_accounts import InvenioAccounts
from invenio_accounts.views import blueprint as accounts_blueprint
from invenio_admin import InvenioAdmin
from invenio_db import InvenioDB
from invenio_records import InvenioRecords
from invenio_pidstore import InvenioPIDStore

    $ ./app-teardown.sh

SPHINX-END

"""

from __future__ import absolute_import, print_function



# Create Flask application
app = Flask(__name__)
app.config.update(
    DB_VERSIONING_USER_MODEL=None,
    SECRET_KEY='test_key',
    SECURITY_PASSWORD_HASH='pbkdf2_sha512',
    SECURITY_PASSWORD_SALT="CHANGE_ME_ALSO",
    SECURITY_PASSWORD_SCHEMES=[
        'pbkdf2_sha512', 'sha512_crypt', 'invenio_aes_encrypted_email'
    ],
    SQLALCHEMY_DATABASE_URI=os.environ.get(
        'SQLALCHEMY_DATABASE_URI', 'sqlite:///test.db'
    ),
    WTF_CSRF_ENABLED=False,
)

Babel(app)
Menu(app)
InvenioDB(app)
admin = InvenioAdmin(app)

InvenioPIDStore(app)