Am 21.08.2010 14:09 schrieb Janosch Peters:
> I suggest adding sqlalchemy to the default "forced builtins". PyDev
> could not resolve all methods, before I added it to the forced builtins.
> ...
> Whenever I used the "session" variable in a module of this package,
> PyDev couldnt resolve its methods.

Hm, I'm using pretty much the same code in TurboGears projects (actually 
a scoped session but this shouldn't make a difference), and PyDev can 
resolve the methods of the session object, without sqlalchemy being 
added to the forced builtins. I only need to add it as a library.

However, I like to add a query attribute to model classes, like so:

     DeclarativeBase.query = DBSession.query_property()

This can be used to write things like:

     user = User.query.get(1)
     users = User.query.all()

But PyDev will complain here about the "get" and "all" methods.

My solution was to add a "fake" query property just for PyDev, like so:

     class DeclarativeBase(declarative_base()):
         class query: # fake property for code analysis only
             all = get = filter = filter_by = order_by = None
         query = DBSession.query_property() # the real property

Now PyDev won't complain any more.

If anybody can come up with a better solution, please let me know.

-- Christoph

------------------------------------------------------------------------------
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users 
worldwide. Take advantage of special opportunities to increase revenue and 
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
_______________________________________________
Pydev-users mailing list
Pydev-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pydev-users

Reply via email to