[wingide-users] 4.0.1-1 - Django beheavior

Harald Thingelstad harald at thingelstad.org
Sun Apr 3 14:00:46 MDT 2011


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


More information about the wingide-users mailing list