Hi,
I'm pretty new to python, mongoDB and pymongo so I'm hoping this is
pretty easy to track down. When I invoke the following method from a
flex client I am seeing the error described below:
@service.amfrpc3("mydomain")
def test():
dbh = getConnection()
record =
dbh.events.find_one({"event_id":"{42152cf8-6a8c-5566-3d51-79915b6fbcb2}"})
returnableRecord = dict()
returnableRecord["event_id"] = record["event_id"]
return record;
#return returnableRecord;
The other important code for this method is as follows:
service = Service(globals())
def call():
session.forget()
return service()
def getConnection():
try:
conn = Connection('localhost', 27017)
except ConnectionFailure, e:
msg = "Failed to connect: %s" %e
print(msg)
dbh = conn["db"]
return dbh
The client side object looks like this:
<s:RemoteObject
id="amfService"
endpoint="http://127.0.0.1:8000/timestream_server/rpc/call/amfrpc3"
destination="mydomain"
showBusyCursor="true">
<mx:method name="test" result="resultHandler(event)"
fault="faultHandler(event)"/>
Here's the error:
faultCode:Channel.Call.Failed faultString:'error'
faultDetail:'NetConnection.Call.Failed: HTTP: Status 500'
If I comment out the "return record" in the test function and
uncomment the line below it ("return returnableRecord") then
everything works fine. No error and the flex client gets the right
thing. I have used a step debugger to step through the code and see
where the exception was being generated on the server and I found this
in a file called restricted.py:
def restricted(code, environment=None, layer='Unknown'):
"""
runs code in environment and returns the output. if an exception
occurs
in code it raises a RestrictedError containing the traceback.
layer is
passed to RestrictedError to identify where the error occurred.
"""
if environment is None: environment = {}
environment['__file__'] = layer
try:
if type(code) == types.CodeType:
ccode = code
else:
ccode = compile2(code,layer)
exec ccode in environment
except HTTP:
raise
except Exception, error:
# XXX Show exception in Wing IDE if running in debugger
if __debug__ and 'WINGDB_ACTIVE' in os.environ:
etype, evalue, tb = sys.exc_info()
sys.excepthook(etype, evalue, tb)
raise RestrictedError(layer, code, '', environment)
The second exception block is entered and the exception is:
AttributeError: 'ObjectId' object has no attribute 'i'
I have no idea what could be causing this. Any help would be greatly
appreciated.
Thanks,
Mike