Yeap, version 1.2.2 it's already out.
Code-completion had special attention in this release. After using it, it's hard to imagine how did I program without those features for so long... easy to get used to some things hum?
Ok, the difference is not the same as not having the extensions code-analysis, but still...
Well, check the details at: http://pydev.sourceforge.net and for the extensions: http://fabioz.com/pydev
Monday, July 24, 2006
Monday, July 17, 2006
Improving code-completion in pydev
The next release is taking a bit longer than usual, but I think it'll be worth it ;-)
The last releases were pretty much focused on getting pydev more efficient -- with lots of profiling -- and stable, and in this next release, I'll focus on features again (mostly on code-completion).
Calltips is one of those long-awaited features that can make your life so much easier, and will be added in this release (and needs no presentations), but as this release is focusing on features, it'll also add:
Toggling the completion mode
That's one of those things that's hard to explain... But I'll try it:
When you're in a piece of code such as
foo.doIt(a, b)
and you want to do a completion to change the method 'doIt' (after 'do') for 'doItNow', it would usually do: 'foo.doItNow(xx,yy)It(a,b)', and you'd have to delete that part with '(xx,yy)It' after applying the completion. Now, in the new release, after bringing the completions up, pressing 'ctrl' (the key that toggles the completion mode) will replace the rest of the method for the new completion, and don't put the parentesis if there is one already.
Cycling through completions
Now, pressing Ctrl+Space multiple types will cycle through the default completions and templates completion (so, if you're looking for a hard-to-find template, just press Ctrl+Space one more time).
Linked Mode
After applying some completion, if it has parameters, you'll be able to cycle through the arguments with Tab and pressing Enter will exit this mode and place the cursor just after the call.
The last releases were pretty much focused on getting pydev more efficient -- with lots of profiling -- and stable, and in this next release, I'll focus on features again (mostly on code-completion).
Calltips is one of those long-awaited features that can make your life so much easier, and will be added in this release (and needs no presentations), but as this release is focusing on features, it'll also add:
Toggling the completion mode
That's one of those things that's hard to explain... But I'll try it:
When you're in a piece of code such as
foo.doIt(a, b)
and you want to do a completion to change the method 'doIt' (after 'do') for 'doItNow', it would usually do: 'foo.doItNow(xx,yy)It(a,b)', and you'd have to delete that part with '(xx,yy)It' after applying the completion. Now, in the new release, after bringing the completions up, pressing 'ctrl' (the key that toggles the completion mode) will replace the rest of the method for the new completion, and don't put the parentesis if there is one already.
Cycling through completions
Now, pressing Ctrl+Space multiple types will cycle through the default completions and templates completion (so, if you're looking for a hard-to-find template, just press Ctrl+Space one more time).
Linked Mode
After applying some completion, if it has parameters, you'll be able to cycle through the arguments with Tab and pressing Enter will exit this mode and place the cursor just after the call.
Saturday, July 01, 2006
Configuring Pydev to work with Turbogears
I still haven't used turbogears myself, so, in the end, this might be interesting for other users that are starting in the turbogears world themselves ;-)
1st step: getting turbogears
OK: downloaded version 0.8.9, which seems to be the latest release
2nd step: installing it
Running setup.py install did some nice things for me... it downloaded setuptools automatically (as it was a pre-requisite) and then proceeded getting other dependencies (egg files) and installed all those without further problems (yeap, many dependencies there).
Now, I still don't have docutils (which it says will make it more 'fun') nor a database, so, I'll get it before I proceed.
It says to use easy_install to get docutils, but it needs some search to know exactly what it means (turns out to be a script installed in my computer at C:\bin\Python24\Scripts\easy_install.exe)
Turns out it didn't do it's job:
[C:\bin]c:\bin\Python24\Scripts\easy_install.exe docutils
Searching for docutils
Reading http://www.python.org/pypi/docutils/
Reading http://docutils.sourceforge.net/
Best match: docutils 0.4
Downloading http://prdownloads.sourceforge.net/docutils/docutils-0.4.tar.gz?download
Requesting redirect to (randomly selected) 'mesh' mirror
error: No META HTTP-EQUIV="refresh" found in Sourceforge page at http://prdownloads.sourceforge.net/
docutils/docutils-0.4.tar.gz?use_mirror=mesh
So, I went on to get it myself and then proceeded to get pysqlite (http://pysqlite.org).
Now that all the turbogears pre-requisites are there, let's see how pydev looks... First, my interpreter configuration has become obsolete, so, all those libraries that were added later are not there... To make it up-to-date, I have to remove the interpreter and add it again (so, it should get all those new libraries -- version 1.2.0 of pydev and earlier had a 'cache' bug, so, you'd need to remove the interpreter, press apply and only after it proceed to add the interpreter again).
Now, just to make sure pysqlite is there, create the following script to see if it works:
from pysqlite2 import dbapi2 as sqlite
con = sqlite.connect("mydb")
print con
Ok, connection there, and a mydb file created, so, everything seems fine.
I decided to go with the 20 minute-flash that turbogears has there...(now that I'm revising this, I'd advise against it and would go with the wiki tutorial, as the flash version hides too many things). It starts creating a project with tg_admin quickstart. So, I decided to create a new pydev project from eclipse before and placed it at d:\turbogears, and ran tg_admin quickstart from within that directory to get started.
I called the project "wiki test" and it created all the structure without any problems, and starting it with wikitest-start.py actually started the server without any problems (http://localhost:8080/)
Now, to configure pydev, you have to add the created folder d:\turbogears\wikitest as a source folder for the project (this would give you code-completion and code-analysis for that project). Details on how to do that can be found at http://fabioz.com/pydev/manual_101_project_conf2.html
Ok, now on to the database creation: got some things mixed up here because the video didn't specify the dev.cfg changes (but the written one does, so, not such a big problem).
Kid template editing: I'd reccomend having WTP (Web Tools Platform) to edit html files... surely makes things much nicer.
Interesting point: I've just now noted that turbogears spawns 2 shells when I run the server, I think that one is the http server and the other some auto-reloader, but this makes some things much harder:
1. If you run it from inside pydev and kill the shell from the eclipse console, the other process will not die (and as you don't have Ctrl+C in that console, you will have to keep killing the other shell manually).
2. You just won't be able to debug it from pydev, as that other shell will be the one that will actually serve the requests (altough you can do it with the remote debugger from pydev extensions).
So, after checking its code a little I've seen:
if conf('autoreload.on', defaultOn): ... do the auto-reload stuff, so, you can set autoreload.on=False in the configurations and run it from pydev, so that you can debug it (but this way, you'll loose the auto-reloader stuff, so, I guess you'll have to decide: pydev regular debugger without auto-reload or pydev extensions remote debugger with the auto-reload (in this case, you could even run it from outside of Eclipse).
So, I guess that's it. Pydev is configured up to the point where you can use code-completion, the debugger and code-analysis without any problems.
Cheers,
Fabio
1st step: getting turbogears
OK: downloaded version 0.8.9, which seems to be the latest release
2nd step: installing it
Running setup.py install did some nice things for me... it downloaded setuptools automatically (as it was a pre-requisite) and then proceeded getting other dependencies (egg files) and installed all those without further problems (yeap, many dependencies there).
Now, I still don't have docutils (which it says will make it more 'fun') nor a database, so, I'll get it before I proceed.
It says to use easy_install to get docutils, but it needs some search to know exactly what it means (turns out to be a script installed in my computer at C:\bin\Python24\Scripts\easy_install.exe)
Turns out it didn't do it's job:
[C:\bin]c:\bin\Python24\Scripts\easy_install.exe docutils
Searching for docutils
Reading http://www.python.org/pypi/docutils/
Reading http://docutils.sourceforge.net/
Best match: docutils 0.4
Downloading http://prdownloads.sourceforge.net/docutils/docutils-0.4.tar.gz?download
Requesting redirect to (randomly selected) 'mesh' mirror
error: No META HTTP-EQUIV="refresh" found in Sourceforge page at http://prdownloads.sourceforge.net/
docutils/docutils-0.4.tar.gz?use_mirror=mesh
So, I went on to get it myself and then proceeded to get pysqlite (http://pysqlite.org).
Now that all the turbogears pre-requisites are there, let's see how pydev looks... First, my interpreter configuration has become obsolete, so, all those libraries that were added later are not there... To make it up-to-date, I have to remove the interpreter and add it again (so, it should get all those new libraries -- version 1.2.0 of pydev and earlier had a 'cache' bug, so, you'd need to remove the interpreter, press apply and only after it proceed to add the interpreter again).
Now, just to make sure pysqlite is there, create the following script to see if it works:
from pysqlite2 import dbapi2 as sqlite
con = sqlite.connect("mydb")
print con
Ok, connection there, and a mydb file created, so, everything seems fine.
I decided to go with the 20 minute-flash that turbogears has there...(now that I'm revising this, I'd advise against it and would go with the wiki tutorial, as the flash version hides too many things). It starts creating a project with tg_admin quickstart. So, I decided to create a new pydev project from eclipse before and placed it at d:\turbogears, and ran tg_admin quickstart from within that directory to get started.
I called the project "wiki test" and it created all the structure without any problems, and starting it with wikitest-start.py actually started the server without any problems (http://localhost:8080/)
Now, to configure pydev, you have to add the created folder d:\turbogears\wikitest as a source folder for the project (this would give you code-completion and code-analysis for that project). Details on how to do that can be found at http://fabioz.com/pydev/manual_101_project_conf2.html
Ok, now on to the database creation: got some things mixed up here because the video didn't specify the dev.cfg changes (but the written one does, so, not such a big problem).
Kid template editing: I'd reccomend having WTP (Web Tools Platform) to edit html files... surely makes things much nicer.
Interesting point: I've just now noted that turbogears spawns 2 shells when I run the server, I think that one is the http server and the other some auto-reloader, but this makes some things much harder:
1. If you run it from inside pydev and kill the shell from the eclipse console, the other process will not die (and as you don't have Ctrl+C in that console, you will have to keep killing the other shell manually).
2. You just won't be able to debug it from pydev, as that other shell will be the one that will actually serve the requests (altough you can do it with the remote debugger from pydev extensions).
So, after checking its code a little I've seen:
if conf('autoreload.on', defaultOn): ... do the auto-reload stuff, so, you can set autoreload.on=False in the configurations and run it from pydev, so that you can debug it (but this way, you'll loose the auto-reloader stuff, so, I guess you'll have to decide: pydev regular debugger without auto-reload or pydev extensions remote debugger with the auto-reload (in this case, you could even run it from outside of Eclipse).
So, I guess that's it. Pydev is configured up to the point where you can use code-completion, the debugger and code-analysis without any problems.
Cheers,
Fabio
Subscribe to:
Posts (Atom)