# Path: ringo/lib/helpers/misc.py
# def get_item_modul(request, item):
#     if hasattr(item, "_modul_id"):
#         return _get_item_modul(request, item)
#     else:
#         return _get_item_modul(request, item.__class__)


import logging
from sqlalchemy.orm.exc import NoResultFound
from sqlalchemy.exc import DataError
from pyramid.httpexceptions import HTTPNotFound
from ringo.lib.helpers import get_item_modul

log = logging.getLogger(__name__)


def get_resource_factory(clazz, modul=None):
    """Dynamically create a Resource factory. The modul can be provided
    optionally to optimize loading additional data from the database. It
    prevents extra loading of the modul later."""
    name = clazz.__name__
    factory = type(name,
                   (RessourceFactory, ),
                   {'__model__': clazz, '__modul__': modul})
    return factory



# Path: ringo/lib/helpers/misc.py
# def get_item_modul(request, item):
#     if hasattr(item, "_modul_id"):
#         return _get_item_modul(request, item)
#     else:
#         return _get_item_modul(request, item.__class__)


# Path: ringo/resources.py
import logging
from sqlalchemy.orm.exc import NoResultFound
from sqlalchemy.exc import DataError
from pyramid.httpexceptions import HTTPNotFound
from ringo.lib.helpers import get_item_modul


log = logging.getLogger(__name__)


def get_resource_factory(clazz, modul=None):
    """Dynamically create a Resource factory. The modul can be provided
    optionally to optimize loading additional data from the database. It
    prevents extra loading of the modul later."""
    name = clazz.__name__
    factory = type(name,
                   (RessourceFactory, ),
                   {'__model__': clazz, '__modul__': modul})
    return factory



class RessourceFactory(object):