hmarr/mongoengine — Issue #315: Accessing "pk" raises an error
Author: jpfarias
Created: 2011-10-12 19:44:45+00:00
State: open

Hi!

It is probably not good practice, but trying to access "pk" on a EmbeddedDocument raises KeyError: 'id_field'.

Perhaps this should be fixed.

I run into this error when I tried to do ```[getattr(obj, fieldname) for fieldname in dir(obj) if not fieldname.startswith('_')]``` which might be a real use case. I fixed with a work around by adding ``` and fieldname not in ('pk', 'validate', 'to_mongo')``` to the condition.