web2py with Eclipse

407 views
Skip to first unread message

weheh

unread,
May 10, 2011, 8:12:25 AM5/10/11
to web2py-users
I'm having trouble getting Eclipse to ignore undefined variable errors
for things imported from gluon, like A, auth, etc. There are numerous
threads on the subject, none of which I'm able to get to work,
including:
http://pierreth.blogspot.com/2010/10/web2py-eclipse-pydev-recipe.html
http://groups.google.com/group/web2py/browse_thread/thread/feb055577dfd4320

The method I like the best is to add this string to Window >
Preferences > Pydev > Code Analysis > Undefined under the "Consider
the following names as globals (comma separated)":

A,AUTH_ID,B,BEAUTIFY,BODY,BR,CENTER,CLEANUP,CODE,CRYPT,DIV,FORM,I,IFRAME,IMG,INPUT,IS_ALPHANUMERIC,IS_DATE,IS_DATETIME,IS_DATETIME_IN_RANGE,IS_DATE_IN_RANGE,IS_DECIMAL_IN_RANGE,IS_EMAIL,IS_EMPTY_OR,IS_EQUAL_TO,IS_EXPR,IS_FLOAT_IN_RANGE,IS_IMAGE,IS_INT_IN_RANGE,IS_IN_DB,IS_IN_SET,IS_IPV4,IS_LENGTH,IS_LIST_OF,IS_LOWER,IS_MATCH,IS_NOT_EMPTY,IS_NOT_IN_DB,IS_NULL_OR,IS_SLUG,IS_STRONG,IS_TIME,IS_UPLOAD_FILENAME,IS_UPPER,IS_URL,LABEL,LEGEND,LI,LINK,MARKMIN,MENU,META,OBJECT,OL,ON,OPTGROUP,OPTION,P,PRE,SCRIPT,SELECT,SPAN,TABLE,TAG,TBODY,TD,TEXTAREA,TFOOT,TH,THEAD,TITLE,TR,TT,UL,URL,XHTML,XML

But as I said, this doesn't seem to do anything at all.

Anybody know what to do?

Massimo Di Pierro

unread,
May 10, 2011, 8:46:00 AM5/10/11
to web2py-users
This is going to be easier in the future. Using trunk, just add this
to models:

from gluon import *
request,session,response,T,cache=current.request,current,session,curremt.response,current.t,current.cache



On May 10, 7:12 am, weheh <richard_gor...@verizon.net> wrote:
> I'm having trouble getting Eclipse to ignore undefined variable errors
> for things imported from gluon, like A, auth, etc. There are numerous
> threads on the subject, none of which I'm able to get to work,
> including:http://pierreth.blogspot.com/2010/10/web2py-eclipse-pydev-recipe.htmlhttp://groups.google.com/group/web2py/browse_thread/thread/feb055577d...

weheh

unread,
May 10, 2011, 11:32:24 AM5/10/11
to web2py-users
MDP - thanks for the quick response. I don't currently use trunk, only
Current Version. What then?

On May 10, 8:46 am, Massimo Di Pierro <massimo.dipie...@gmail.com>
wrote:
> This is going to be easier in the future. Using trunk, just add this
> to models:
>
> from gluon import *
> request,session,response,T,cache=current.request,current,session,curremt.response,current.t,current.cache
>
> On May 10, 7:12 am, weheh <richard_gor...@verizon.net> wrote:
>
>
>
>
>
>
>
> > I'm having trouble getting Eclipse to ignore undefined variable errors
> > for things imported from gluon, like A, auth, etc. There are numerous
> > threads on the subject, none of which I'm able to get to work,
> > including:http://pierreth.blogspot.com/2010/10/web2py-eclipse-pydev-recipe.html......

Ross Peoples

unread,
May 10, 2011, 12:52:15 PM5/10/11
to web...@googlegroups.com
The only thing that had really worked for me in the past was doing the if 0: trick:

if 0:
    from gluon.dal import DAL
    from gluon.tools import Auth
    db = DAL()
    auth = Auth()

The code won't actually get executed, it's just there to give Eclipse and other IDE's some direction.

If this still doesn't work, then you'll have to wait until the next web2py release, which could be in a week or two.

Sebastian E. Ovide

unread,
May 10, 2011, 4:44:06 PM5/10/11
to web...@googlegroups.com
yes, I'm using that trick and it is working fine... except in the views
--
Sebastian E. Ovide



weheh

unread,
May 10, 2011, 5:04:00 PM5/10/11
to web2py-users
Yeah, the fugly 0 trick works, but what a 2-bagger! Can't wait for the
new release.

On May 10, 4:44 pm, "Sebastian E. Ovide" <sebastian.ov...@gmail.com>
wrote:
> yes, I'm using that trick and it is working fine... except in the views
>

Pierre Thibault

unread,
Jun 20, 2011, 7:24:41 AM6/20/11
to web...@googlegroups.com
On May 10, 8:46 am, Massimo Di Pierro <massimo....@gmail.com>
wrote:
> This is going to be easier in the future. Using trunk, just add this
> to models:
>
> from gluon import *
> request,session,response,T,
cache=current.request,current,session,curremt.response,current.t,current.cache

Can we the same trick for the controllers?

sebastian

unread,
Jun 26, 2011, 10:58:02 AM6/26/11
to web...@googlegroups.com
what about the functions defined in the models ? (global functions)

Pierre Thibault

unread,
Jun 26, 2011, 3:39:10 PM6/26/11
to web...@googlegroups.com
2011/6/26 sebastian <sebasti...@gmail.com>

what about the functions defined in the models ? (global functions)


Pydev won't see them because they are imported implicitly by web2py. You can use the if 0: trick so the static code analyzer will not complain:

if 0:
  from applications.myapp.models import myfunc

In the preferences of Pydev you can make "if" fold-able to be able to fold the noisy code: Window > Preferences > Pydev > Editor > Folding

There is not much you can do because this is not a standard way to do things in Python. Breaking from the standard has his part of ugly.
--


A+

-------------
Pierre
My blog and profile (http://pierrethibault.posterous.com)
YouTube page (http://www.youtube.com/user/tubetib)
Twitter (http://twitter.com/pierreth2)

Sebastian E. Ovide

unread,
Jun 26, 2011, 6:43:03 PM6/26/11
to web...@googlegroups.com
Thanks Pierr,

I was trying to do that but it is not working... actually I have a bunch of imports insede that "if 0" trick that solve all the web2py dependencies errors...

the only errors stil there are those due to functions in my model files (as for example the models of my plugins)

I've tried also

from applications.myapp.models import *

and added a __init__.py inside the models folder....

any other ideas ?



On Sun, Jun 26, 2011 at 8:39 PM, Pierre Thibault <pierre.t...@gmail.com> wrote:

if 0:
  from applications.myapp.models import myfunc



--
Sebastian E. Ovide




Sebastian E. Ovide

unread,
Jun 26, 2011, 6:48:24 PM6/26/11
to web...@googlegroups.com
add info:

from applications.soso.models import my_db_helper_here

eclipse give this error:

Unresolved import: my_db_helper_here
Unused import: my_db_helper_here
--
Sebastian E. Ovide




Pierre Thibault

unread,
Jun 26, 2011, 8:16:00 PM6/26/11
to web...@googlegroups.com
2011/6/26 Sebastian E. Ovide <sebasti...@gmail.com>

add info:

from applications.soso.models import my_db_helper_here

eclipse give this error:

Unresolved import: my_db_helper_here
Unused import: my_db_helper_here


Is the web2py folder in your path?

I guess you are missing a level. Try something like:

from applications.soso.models.some_module import my_db_helper_here

I'm sorry I forgot the "some_module" in my first example.

Sebastian E. Ovide

unread,
Jun 27, 2011, 6:23:00 PM6/27/11
to web...@googlegroups.com
That's it !

thanks


On Mon, Jun 27, 2011 at 1:16 AM, Pierre Thibault <pierre.t...@gmail.com> wrote:
from applications.soso.models.some_module import my_db_helper_here

I'm sorry I forgot the "some_module" in my first example.



--
Sebastian E. Ovide


monotasker

unread,
Nov 3, 2011, 1:55:10 PM11/3/11
to web...@googlegroups.com
Can you tell me what the current status of this is? I'm running release 1.99.2. I've placed the snippet you provide here in the top of my model file, but PyDev still doesn't recognize "current" or "session" or any of the gluon classes called in the model file. Is this just not yet implemented?
Reply all
Reply to author
Forward
0 new messages