# Path: papaye/factories/root.py
# def user_root_factory(request_or_connection):
#     if isinstance(request_or_connection, (Request, DummyRequest)):
#         conn = get_connection(request_or_connection)
#     else:
#         conn = request_or_connection
#     zodb_root = conn.root()
#     if not '{}_root'.format(APP_NAME) in zodb_root:
#         return None
#     return zodb_root[APP_ROOT_NAME]['user']
# 
# def repository_root_factory(request_or_connection):
#     if isinstance(request_or_connection, (Request, DummyRequest)):
#         conn = get_connection(request_or_connection)
#     else:
#         conn = request_or_connection
#     zodb_root = conn.root()
#     if not '{}_root'.format(APP_NAME) in zodb_root:
#         return None
#     return zodb_root[APP_ROOT_NAME]['repository']
# 
# APP_ROOT_NAME = '{}_root'.format(APP_NAME)
# 
# Path: papaye/schemas.py
# class Metadata(colander.MappingSchema):
#     version = colander.SchemaNode(String(), missing=None)
#     author = colander.SchemaNode(String(), missing=None)
#     author_email = colander.SchemaNode(String(), missing=None)
#     home_page = colander.SchemaNode(String(), missing=None)
#     keywords = colander.SchemaNode(Tags(), default=[])
#     license = colander.SchemaNode(String(), missing=None)
#     summary = colander.SchemaNode(String(), missing=None)
#     maintainer = colander.SchemaNode(String(), missing=None)
#     maintainer_email = colander.SchemaNode(String(), missing=None)
#     description = colander.SchemaNode(Description(), default=None)
#     platform = colander.SchemaNode(String(), missing=None)
#     classifiers = colander.SchemaNode(Classifiers(), default=[])
#     name = colander.SchemaNode(String(), missing=None)


import datetime
import hashlib
import io
import json
import logging
import magic
import pkg_resources
import requests
from BTrees.OOBTree import OOBTree
from ZODB.blob import Blob
from beaker.cache import cache_region
from persistent import Persistent
from pkg_resources import parse_version
from pyramid.security import Allow, ALL_PERMISSIONS, Everyone
from pyramid.threadlocal import get_current_registry
from pyramid_zodbconn import db_from_uri
from repoze.evolution import ZODBEvolutionManager
from requests.exceptions import ConnectionError
from pytz import utc
from papaye.factories.root import user_root_factory, repository_root_factory, APP_ROOT_NAME
from papaye.schemas import Metadata




logger = logging.getLogger(__name__)
SW_VERSION = 1


def get_manager(config):
    conn = config.registry._zodb_databases[''].open()

# Path: papaye/factories/root.py
# def user_root_factory(request_or_connection):
#     if isinstance(request_or_connection, (Request, DummyRequest)):
#         conn = get_connection(request_or_connection)
#     else:
#         conn = request_or_connection
#     zodb_root = conn.root()
#     if not '{}_root'.format(APP_NAME) in zodb_root:
#         return None
#     return zodb_root[APP_ROOT_NAME]['user']
# 
# def repository_root_factory(request_or_connection):
#     if isinstance(request_or_connection, (Request, DummyRequest)):
#         conn = get_connection(request_or_connection)
#     else:
#         conn = request_or_connection
#     zodb_root = conn.root()
#     if not '{}_root'.format(APP_NAME) in zodb_root:
#         return None
#     return zodb_root[APP_ROOT_NAME]['repository']
# 
# APP_ROOT_NAME = '{}_root'.format(APP_NAME)
# 
# Path: papaye/schemas.py
# class Metadata(colander.MappingSchema):
#     version = colander.SchemaNode(String(), missing=None)
#     author = colander.SchemaNode(String(), missing=None)
#     author_email = colander.SchemaNode(String(), missing=None)
#     home_page = colander.SchemaNode(String(), missing=None)
#     keywords = colander.SchemaNode(Tags(), default=[])
#     license = colander.SchemaNode(String(), missing=None)
#     summary = colander.SchemaNode(String(), missing=None)
#     maintainer = colander.SchemaNode(String(), missing=None)
#     maintainer_email = colander.SchemaNode(String(), missing=None)
#     description = colander.SchemaNode(Description(), default=None)
#     platform = colander.SchemaNode(String(), missing=None)
#     classifiers = colander.SchemaNode(Classifiers(), default=[])
#     name = colander.SchemaNode(String(), missing=None)


# Path: papaye/evolve/models/snapshot1.py
import datetime
import hashlib
import io
import json
import logging
import magic
import pkg_resources
import requests
from BTrees.OOBTree import OOBTree
from ZODB.blob import Blob
from beaker.cache import cache_region
from persistent import Persistent
from pkg_resources import parse_version
from pyramid.security import Allow, ALL_PERMISSIONS, Everyone
from pyramid.threadlocal import get_current_registry
from pyramid_zodbconn import db_from_uri
from repoze.evolution import ZODBEvolutionManager
from requests.exceptions import ConnectionError
from pytz import utc
from papaye.factories.root import user_root_factory, repository_root_factory, APP_ROOT_NAME
from papaye.schemas import Metadata





logger = logging.getLogger(__name__)
SW_VERSION = 1


def get_manager(config):
    conn = config.registry._zodb_databases[''].open()

    root = conn.root()[APP_ROOT_NAME]