def find_first_object(self, ObjectClass, **kwargs):
        """ Retrieve the first object of type ``ObjectClass``,
        matching the specified filters in ``**kwargs`` -- case sensitive.
        """

        # Convert each name/value pair in 'kwargs' into a filter
        query = ObjectClass.query
        for field_name, field_value in kwargs.items():

            # Make sure that ObjectClass has a 'field_name' property
            field = getattr(ObjectClass, field_name, None)
            if field is None:
                raise KeyError("BaseAlchemyAdapter.find_first_object(): Class '%s' has no field '%s'." % (ObjectClass, field_name))

            # Add a case sensitive filter to the query
            query = query.filter(field==field_value)  # case sensitive!!

        # Execute query
        return query.first()
def find_first_object ( self , ObjectClass , ** kwargs ) : query = ObjectClass . query for field_name , field_value in kwargs . items ( ) : field = getattr ( ObjectClass , field_name , None ) if field is None : raise KeyError ( "BaseAlchemyAdapter.find_first_object(): Class '%s' has no field '%s'." % ( ObjectClass , field_name ) ) query = query . filter ( field == field_value ) return query . first ( )
Retrieve the first object of type ``ObjectClass``,
        matching the specified filters in ``**kwargs`` -- case sensitive.