Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mongoengine compatibility #32

Closed
kengruven opened this issue Feb 24, 2015 · 4 comments

Comments

Projects
None yet
3 participants
@kengruven
Copy link

commented Feb 24, 2015

I'm trying to run pdoc on a program, and for the most part, it works well, except on one module that has mongoengine.Document subclasses.

mongoengine.Document has a class method "objects" so that if you have a class Foo(mongoengine.Document), then Foo.objects is a special "query set" object which can return all objects, or a filtered subset of them (based on subsequent chained methods).

Unfortunately, this doesn't seem to play nice with pdoc, which uses inspect.getmembers() to inspect the class. A simple example:

from mongoengine import Document
class Foo(Document):
    pass
import inspect
inspect.getmembers(Foo)

Result: this raises mongoengine.connection.ConnectionError: "You have not defined a default connection". Running pdoc on this causes the same exception, but with a deeper stack trace.

The pdoc documentation says "If the name is defined in a different module, it is not public", and since the class method "Document.objects" is defined in the mongoengine module, I would expect it not to be part of the "public interface", and thus not be documented by pdoc. But perhaps I'm misunderstanding.

At least, I'd like to be able to declare a custom blacklist so that it can know to avoid calling getattr(cls, 'objects') on any Document subclasses.

@TennyZhuang

This comment has been minimized.

Copy link

commented Aug 26, 2016

+1

@TennyZhuang

This comment has been minimized.

Copy link

commented Aug 26, 2016

is there a reasonable way to resolve this now?

@BurntSushi

This comment has been minimized.

Copy link
Contributor

commented Aug 26, 2016

Result: this raises mongoengine.connection.ConnectionError: "You have not defined a default connection". Running pdoc on this causes the same exception, but with a deeper stack trace.

pdoc only works on idiomatic Python modules. Python modules that raise exceptions upon inspection or try to do other weird things like initiate a database connection just from inspecting a class aren't something I'm inclined to expend much effort supporting.

At least, I'd like to be able to declare a custom blacklist so that it can know to avoid calling getattr(cls, 'objects') on any Document subclasses.

The documentation for pdoc includes this:

If pdoc[key] = None, then key will not be included in the public interface of the module.

You can try that, but I don't know if it will actually work in your case.

@kengruven

This comment has been minimized.

Copy link
Author

commented Aug 28, 2016

BurntSushi makes a good point. I'm withdrawing this request.

@kengruven kengruven closed this Aug 28, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.