[wingide-users] Alternative ways of generating links to object definitions, (resend without pgp messing up).

Wingware Support support at wingware.com
Wed Aug 29 07:43:36 MDT 2012


Gadget/Steve wrote:
> I have the following scenario that I could use some help with:
>
> A large number of message structures are defined in a messages package
> within my application, including a MsgNoBody for message types that
> consist of just a header, with a fixed file naming convention,
> (Msg/MessageName/.py).  There is a single python file called
> OnOfEachMsg.py that creates one instance of each message, (called each
> called Cmd/MessageName/), including the messages that do not have a
> body, these are created from a list of tupples like the following:
> ...
> (/"MessageName", MsgFamily, MsgId/, True), # Message that has a body
> defining file
> (/"AnotherMessageName", AnotherFamily, AnotherId/, False), # Message
> with no body
> ...
>
> These values are then used during the loading of OneOfEachMsg to
> generate and import the appropriate file, if any, and create one message
> object of the correct type, family, id, name and add it to a dictionary
> that is used for the decoding received messages, etc., in my
> application.  Some other parts of the application only act on one or two
> message types and they will use something like *from OneOfEachMsg import
> CmdMessageName *so as only to have the specific message type in scope.
>
> Elsewhere in the code I have also used some similar methods to cope with
> large numbers of imports.
>
> While this is great for code size, maintainability, etc., it does have
> the slight problem that if defeats the WingIDE code parsing so I can not
> use Goto Definition.
>
> My question is, (at last you say), is there a way that I can generate a
> file that will allow WingIDE to know where the definitions are to be found?

I'm not quite understanding why the imports you have are defeating Wing, 
but assuming it's not that you need to add to the Python Path in Project 
Properties then you can put in some dummy imports like this:

if 0:
   from OneOfEachMsg import *

The code is of course never executed but Wing ignores the 'if 0' and 
will put everything in the named module into the local scope.

If you want to avoid changing code you can also write a file xxx.pi next 
to xxx.py that contains the above.  Recent Wing versions should merge 
the two as far as its analysis of what's in the name spaces.  It appears 
you do need to right click on xxx.py and select Reanalyze File before 
Wing will load the newly introduced xxx.pi (just the first time it's 
added while Wing is running).  Also, you don't need the 'if 0' in the 
xxx.pi.

Please let me know if this does not help.

Thanks,

-- 

Stephan Deibel
Wingware | Python IDE
Advancing Software Development

www.wingware.com


More information about the wingide-users mailing list