Esempio n. 1
0
    def find_one(klass, *args, **kwargs):
        """
        Find a single object in the database, takes standard PyMongo-style
        input parameters (blocking)::

            thisUser = User.find_one({'username':username}) #Gets a specific user from the DB

        """
        from Mojo.ServerHelpers.RunServer import BACKEND_COLLECTION, DATABASE
        klass.collection_name = klass.__name__

        if DATABASE:
            if BACKEND_COLLECTION:
                this_collection = BACKEND_COLLECTION(DATABASE, klass)
                ret_obj = this_collection.find_one(*args, **kwargs)

                return ret_obj
Esempio n. 2
0
    def find_one(klass, *args, **kwargs):
        """
        Find a single object in the database, takes standard PyMongo-style
        input parameters (blocking)::

            thisUser = User.find_one({'username':username}) #Gets a specific user from the DB

        """
        from Mojo.ServerHelpers.RunServer import BACKEND_COLLECTION, DATABASE
        klass.collection_name = klass.__name__

        if DATABASE:
            if BACKEND_COLLECTION:
                this_collection = BACKEND_COLLECTION(DATABASE, klass)
                ret_obj = this_collection.find_one(*args, **kwargs)

                return ret_obj