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.
Please help!
/allmigh7y
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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:
e.g.
from main.lib.base import *
class FormsController(BaseController):
def index(self):
return Response('')
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?
/allmigh7y
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Still, it seems that pydev could not make the complete below very well...
from helloworld.lib.base import *
class HelloController(BaseController):
def index(self):
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).
Cheers,
Fabio
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Guys,
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.
Please help!
/allmigh7y
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
-------------------------
.settings
branches
tags
trunk
.project
The below structure in my 'trunk' directory:
--------------------------------------------
helloworld
- data
- helloworld
- config
- controllers
- docs
- i18n
- lib
- models
- public
- templates
- tests
- __init__.py
- websetup.py
- helloworld.egg-info
- Various files including paste_deploy_config.ini_tmpl
- development.ini
- setup.cfg
- setup.py
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:
e.g.
from main.lib.base import *
class FormsController(BaseController):
def index(self):
return Response('')
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?
/allmigh7y
Fabio/Anyone,
Anyone know what I can try in order to fix this issue? It's getting more annoying the more I code :-(
/allmigh7y
In your example:
from main.lib.base import *
class FormsController(BaseController):
def index(self):
return Response('')
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...
E.g.:
class FormsController(BaseController):
def index(self):
for p in sys.path: print p #get the pythonpath
return Response('')
It would be nice if you could post those results...
Cheers,
Fabio
At the root of the Eclipse project titled "HelloWorld", is the following structure:
settings
branches
tags
trunk
.project
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?)
-------------------------------------------
C:\dev\tools\eclipse\plugins\org.python.pydev.debug_1.2.4\pysrc
C:\dev\tools\python25\Lib\site-packages\simplejson-1.4-py2.5.egg
C:\dev\tools\python25\Lib\site-packages\myghtyutils-0.52-py2.5.egg
C:\dev\tools\python25\Lib\site-packages\setuptools-0.6c3-py2.5.egg
C:\dev\tools\python25\Lib\site-packages\sqlalchemy-0.3.0-py2.5.egg
c:\dev\tools\python25\lib\site-packages\docutils-0.4-py2.5.egg
c:\dev\tools\python25\lib\site-packages\mako-0.1.0-py2.5.egg
c:\dev\applications\pylons\quickwiki
c:\dev\tools\python25\lib\site-packages\pylons-0.9.4.1-py2.5.egg
c:\dev\tools\python25\lib\site-packages\nose-0.9.1-py2.5.egg
c:\dev\tools\python25\lib\site-packages\paste-1.1.1-py2.5.egg
c:\dev\tools\python25\lib\site-packages\beaker-0.6.2-py2.5.egg
c:\dev\tools\python25\lib\site-packages\routes-1.6.2-py2.5.egg
c:\dev\tools\python25\lib\site-packages\formbuild-0.1.6b-py2.5.egg
C:\dev\tools\python25\Lib\site-packages\pylons-0.9.2-py2.5.egg
C:\dev\tools\python25\Lib\site-packages\beaker-0.6.1-py2.5.egg
C:\dev\tools\python25\Lib\site-packages\nose-0.9.0-py2.5.egg
C:\dev\tools\python25\Lib\site-packages\webhelpers-0.2.2-py2.5.egg
C:\dev\tools\python25\Lib\site-packages\FormEncode-0.6-py2.5.egg
C:\dev\tools\python25\Lib\site-packages\pastescript-1.0-py2.5.egg
C:\dev\tools\python25\Lib\site-packages\pastedeploy-1.0-py2.5.egg
C:\dev\tools\python25\Lib\site-packages\paste-1.0-py2.5.egg
C:\dev\tools\python25\Lib\site-packages\myghty-1.1-py2.5.egg
C:\dev\tools\python25\Lib\site-packages\routes-1.5.2-py2.5.egg
C:\dev\tools\python25\Lib\site-packages\cheetah-1.0-py2.5.egg
C:\dev\tools\python25\DLLs
c:\dev\tools\python25\lib\site-packages
C:\dev\tools\python25\Lib
C:\dev\tools\python25\Lib\lib-tk
C:\dev\tools\python25
C:\dev\applications\pylons\ c:\dev\tools\python25\python25.zip
c:\dev\tools\python25\lib\plat-win
C:\dev\tools\python25\Lib\site-packages\routes-1.5.2-py2.5.egg
Just to add:
In my windows file system, the "HelloWorld" application is located here:
c:\dev\applications\pylons\HelloWorld
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:
/helloworld
/helloworld/helloworld
/helloworld/config
etc.
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 *
class HelloController(BaseController):
def index(self):
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).
Cheers,
Fabio
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! :-)
Cheers,
allmigh7y
Just as a note... I've just fixed that error in the code completion for 1.2.7.
Cheers,
Fabio