[wingide-users] 4.0.1-1 - Django beheavior

Fabio Fornaro fabio.fornaro at gmail.com
Mon Apr 4 01:20:57 MDT 2011


Hi Harald,
I'm also quite new to the language, and WingIDE itself for that matter and
some assertions I make could be wrong. Yes, WingIDE does static analysis, so
I'm aware of the fact that dynamic classes and such specific constructs may
be not found by the code analysis subsystem.
But I think this is not my case because the *
django.db.models.fields.CharField* extends *django.db.fields.Field* class
that specifies "max_length" *statically *in its *__init__* method:

class Field(object):
    """Base class for all field types"""

{omissis}

    def __init__(self, verbose_name=None, name=None, primary_key=False,
            *max_length*=None, unique=False, blank=False, null=False,
            db_index=False, rel=None, default=NOT_PROVIDED, editable=True,
            serialize=True, unique_for_date=None, unique_for_month=None,
            unique_for_year=None, choices=None, help_text='',
db_column=None,
            db_tablespace=None, auto_created=False, validators=[],
            error_messages=None):

{omissis}

JetBrains PyCharm, just to mention another IDE for Python that I was also
evaluating these days, behaviors differently and *correctly *displays in its
code-completion all the parameters (inherited from the Field class) for the
CharField class.

Far away to start a "this IDE works better than this other one" or pointless
holy wars because this is not the scope of this mail (I currently hold a
license for WingIDE, so who cares about that ? :-), but I'm only pointing
out to the fact that why a Java-based IDE for Python should have something
that "*apparently works smarter"  *(from my limited perspective)* *than a
1st class Python-based IDE like WingIDE  ?
Maybe someone could argue that it just works differently and not smarter or
better: it depends on one's specific expectations I guess.

But, at the end of the day, my question is : is there something wrong with
the static analysis concerning django classes analysis (for my case) or it's
just the way it works and everything is ok ?

Best Regards,
Fabio

On Sun, Apr 3, 2011 at 10:00 PM, Harald Thingelstad
<harald at thingelstad.org>wrote:

> On Sat, 2 Apr 2011 23:58:39 +0200
> Fabio Fornaro <fabio.fornaro at gmail.com> wrote:
>
> > Hello,
> > I'm experiencing this behavior in WingIDE 4.0.1-1 :
> >
> > I have this simple class
> > *
> > *
> > class Accountant(models.Model):
> >     def __init__(self)
> >         name = models.CharField(max_length=10)
> >         surname = models.CharField(max_length=20)
> >
> > First Problem: I get no auto-completion for the models.CharField(...)
> > parameters (ie. max_length, unique etc...) --- I tried also to force
> >  "site-packages\django" path in project's python path but with no
> > luck.
> >
> > Second Problem: on issuing the "Django" -> "Generate SQL" command
> > menu I only get:
> >
> > BEGIN;
> > CREATE TABLE "ApplicationOne_Accountant" (
> >     "id" integer NOT NULL PRIMARY KEY
> > )
> > ;
> > COMMIT;
> >
> > with  no "name" nor "surname" table columns definition. I tried both
> > sqlite & mssql django backends with the same behavior.
> >
> > I'm running Python 2.6.6 with django 1.2.5 on Windows.
> >
> > Can anybody help?
> >
>
> Hi!
> I'm very much an 'anybody' here, and by no means an expert. Actually I
> think I have more to learn, so some few cents here and some groundwork,
> perhaps someone else can fill me in?
>
> So...
> Python is very much a dynamic language. That means, you can make your
> program change inside out while running. That's not just practical for
> interpreters, debuggers and so on, programs that analyze your code
> while running it, people sometimes make 'factories'. That is, code that
> adds classes, methods etc. to itself while running.
> For example, your models.Charfield class may not exist before Django
> has started running, but some code in there may put those classes
> in place while running. Or (I think this is the case (or
> thereabouts..)) makes use of your classes as a recipe for something
> entirely different.
>
> Wingide on the other side, makes use of static analysis (as far as I
> know). That means, it only looks at the code before it is run. If some
> code is being changed dynamically, static analysis won't find it.
> (Booo!)
>
> I guess some mapping could be made in Wingide that makes you 'find'
> such classes, but if the code changes underneath (or if you otherwise
> would want differing version) then the mapping won't fit anymore. (And
> you'd just end up having to make a major amount of mappings.)
> I guess the coding of such packages could be nicer to static analysis,
> too. Include placeholders etc., but first you'll have to convince the
> developers to care about static analysis. I'm not so sure there...
>
> Perhaps something could be done, somewhere in the middle, for popular
> packages? Who would do that, I ask.
>
> Hope it helps, somewhere!
> Harald Thingelstad
> _________________________________________________
> Wing IDE users list
> http://wingware.com/lists/wingide
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/wingide-users/attachments/20110404/90697c64/attachment.html


More information about the wingide-users mailing list