# Path: norm/orm/error.py
# class NotFound(Error):
#     pass
# 
# Path: norm/interface.py
# class IOperator(Interface):
#     """
#     I provide functions for doing operations.  My methods are suitable for
#     use as the function in L{IRunner.runInteraction}.
#     """
# 
# 
#     def insert(cursor, obj):
#         """
#         Insert the ORM object into the database, update the object's attributes
#         and return the object.
#         """
# 
# 
#     def query(cursor, query):
#         """
#         XXX
#         """
# 
# 
#     def refresh(cursor, obj):
#         """
#         XXX
#         """
# 
# 
#     def update(cursor, obj):
#         """
#         XXX
#         """
# 
# 
#     def delete(cursor, obj):
#         """
#         XXX
#         """


from collections import defaultdict, MutableMapping
from zope.interface import implements
from norm.orm.error import NotFound
from norm.interface import IOperator
        from norm.orm.expr import Eq
        from norm.orm.expr import Neq
        from norm.orm.expr import Gt
        from norm.orm.expr import Gte
        from norm.orm.expr import Lt
        from norm.orm.expr import Lte
import inspect
import weakref
    def __le__(self, other):
        return Lte(self, other)


class _WeakIdentityDict(MutableMapping):
    def __init__(self):
        def remove(k, selfref=weakref.ref(self)):
            self = selfref()
            if self is not None:
                del self.data[k.key]
        self._remove = remove
        self.data = {}

    def __delitem__(self, key):
        del self.data[id(key)]

    def __getitem__(self, key):
        return self.data[id(key)][1]

    def __setitem__(self, key, value):
        wr = weakref.KeyedRef(key, self._remove, id(key))
        self.data[id(key)] = (wr, value)

    def __contains__(self, key):
        return id(key) in self.data

    def __iter__(self):
        for item in self.data.itervalues():
            obj = item[0]()
            if obj is not None:

# Path: norm/orm/error.py
# class NotFound(Error):
#     pass
# 
# Path: norm/interface.py
# class IOperator(Interface):
#     """
#     I provide functions for doing operations.  My methods are suitable for
#     use as the function in L{IRunner.runInteraction}.
#     """
# 
# 
#     def insert(cursor, obj):
#         """
#         Insert the ORM object into the database, update the object's attributes
#         and return the object.
#         """
# 
# 
#     def query(cursor, query):
#         """
#         XXX
#         """
# 
# 
#     def refresh(cursor, obj):
#         """
#         XXX
#         """
# 
# 
#     def update(cursor, obj):
#         """
#         XXX
#         """
# 
# 
#     def delete(cursor, obj):
#         """
#         XXX
#         """


# Path: norm/orm/base.py
from collections import defaultdict, MutableMapping
from zope.interface import implements
from norm.orm.error import NotFound
from norm.interface import IOperator
        from norm.orm.expr import Eq
        from norm.orm.expr import Neq
        from norm.orm.expr import Gt
        from norm.orm.expr import Gte
        from norm.orm.expr import Lt
        from norm.orm.expr import Lte
import inspect
import weakref

    def __le__(self, other):
        return Lte(self, other)


class _WeakIdentityDict(MutableMapping):
    def __init__(self):
        def remove(k, selfref=weakref.ref(self)):
            self = selfref()
            if self is not None:
                del self.data[k.key]
        self._remove = remove
        self.data = {}

    def __delitem__(self, key):
        del self.data[id(key)]

    def __getitem__(self, key):
        return self.data[id(key)][1]

    def __setitem__(self, key, value):
        wr = weakref.KeyedRef(key, self._remove, id(key))
        self.data[id(key)] = (wr, value)

    def __contains__(self, key):
        return id(key) in self.data

    def __iter__(self):
        for item in self.data.itervalues():
            obj = item[0]()
            if obj is not None:

                yield obj