I installed Pydev and have a pylons project structure, but when I type in the editor:
"self.c" no code completion box appears. I know I have to right-click on the project node and via is properties modify the PYTHONPATH to point to the "src" directory. As the pylons project structure doesn't have a "src" directory per-se, how can I get this invaluable code completion working? The default code completion sucks big time, so I need this "added" feature set.
Well... you don't put your python code under some folder? What is your structure for the project?
I checked out the ROOT from my subversion (SVN) server, so the project structure is as follows:
ECLIPSE PROJECT STRUCTURE
The below structure in my 'trunk' directory:
- Various files including paste_deploy_config.ini_tmpl
I have python modules all over the place (ie. in controllers, lib, modules, etc.,)
And how do you write the imports for one getting modules from the other in this case?
from helloworld import controllers?
or from controllers import xxx?
or each one is totally independent from the other?
from main.lib.base import *
import smtplib, random
from pylons import g
from main.lib.Utility import *
sample header from a module in my lib directory. But looking at my basic controller, after its initial creation, there is only 1 import stmt generated:
from main.lib.base import *
Now when I do self.c in the index action, no auto-complete happens? Am I missing something? I've seen both versions of the imports you mentioned. Not sure how that effects the auto-completion?
Anyone know what I can try in order to fix this issue? It's getting more annoying the more I code :-(
In your example:
where is that 'main' module that you use as the root for your code?
Also, it might be worth checking in some place what's the pythonpath that is used at runtime for a pylons project...
for p in sys.path: print p #get the pythonpath
It would be nice if you could post those results...
At the root of the Eclipse project titled "HelloWorld", is the following structure:
The 'main' you referred to, is under the following structure:
trunk > main > main
The 'last' main directory is where all my pylons structure code exists (for instance, controllers/public/models/etc.,)
So, my FormsController is actually under
trunk > main > main > controllers > forms.py
Results from sys.path (what do I add here?)
Just to add:
In my windows file system, the "HelloWorld" application is located here:
Ok, I've downloaded pylons here... and created a (rather short) tutorial on what you need to make it work with pydev:
1. get it with easy_install
2. check the pylons manual at: http://pylonshq.com/docs/0.9.4.1/getting_started.html -- I'm just going to extend it a bit here on what needs to be configured in pydev
3. Pydev specific: remove and add the interpreter again, so that it can find out about the new libraries (details on how to do that at: http://fabioz.com/pydev/manual_101_interpreter.html\)
4. Pydev specific: create a new project (let's call it pylons_test) -- uncheck the option to create a 'src' folder.
5. go into the pylons_test and execute in the command-line:
d:\bin\Python24\Scripts\paster.exe create --template=pylons helloworld
This should have created a structure below the project with:
6. Pydev specific: add the /helloworld to the project pythonpath (details on how to do that at: http://fabioz.com/pydev/manual_101_project_conf.html\)
7. Keep on with the pylons tutorial ;-)
Still, it seems that pydev could not make the complete below very well...
from helloworld.lib.base import *
self. <-- complete here
return Response('hello world')
but if you change 'from helloworld.lib.base import *' to 'from helloworld.lib.base import BaseController, Response' it works... may be a pydev bug (I have to check it better).
Aha! It works! Dude, this rocks. Thanks a great deal for your help Fabio. Very much appreciate your clear walk through of the steps.
It's just amazing how much I depend on code completion. But now it works, so I am happy and continue to be lazy! :-)
Just as a note... I've just fixed that error in the code completion for 1.2.7.