Wednesday, May 19, 2010

Using .hgignore

Being a Java guy by day I typically use the source control stalwarts subversion and cvs. I've been exposed to other source control software of course. I used Borland's StarTeam on one gig, and I had a brief, horrific experience with Visual Source Safe.

Now that I'm a Python guy by night I have been using Mercurial. I like it. Its fast. Bitbucket is really sweet.

I use it on the command line; although, NetBeans has built in support. Naturally I got tired of seeing all my compiled Python files (*.pyc) when I ran, "hg status."
hg status
...
flatpages/forms.pyc
flatpages/models.pyc
...
Putting a file, ".hgignore" in the root of the directory is the solution. This is duly documented all over the web. I had problems with the syntax nonetheless.

That was what I ended up with:
# use glob syntax.
syntax: glob
*.elc
*.pyc
*
*.bfproject
*.kpf

templates_compiled/**
The glob syntax is pretty intuitive.

Sunday, May 16, 2010

Parse Error: Expected no additional symbols at symbol select

Running the following query :
query = MODEL_NAME.gql("select * from MODEL_NAME where name = :1", supplied_name) 
I got the error below :
Traceback (most recent call last):                                                               
File "<console>", line 1, in <module>
File "[PATH TO APP ENGINE INSTALL]google_appengine_1.3.1/google/appengine/ext/db/__init__.py", line 1100, in gql
*args, **kwds)
File "[PATH TO APP ENGINE INSTALL]google_appengine_1.3.1/google/appengine/ext/db/__init__.py", line 2047, in __init__
self._proto_query = gql.GQL(query_string, _app=app)
File "[PATH TO APP ENGINE INSTALL]google_appengine_1.3.1/google/appengine/ext/gql/__init__.py", line 192, in __init__
if not self.__Select():
File "[PATH TO APP ENGINE INSTALL]google_appengine_1.3.1/google/appengine/ext/gql/__init__.py", line 799, in __Select
return self.__From()
File "[PATH TO APP ENGINE INSTALL]google_appengine_1.3.1/google/appengine/ext/gql/__init__.py", line 820, in __From
return self.__Where()
File "[PATH TO APP ENGINE INSTALL]google_appengine_1.3.1/google/appengine/ext/gql/__init__.py", line 833, in __Where
return self.__OrderBy()
File "[PATH TO APP ENGINE INSTALL]google_appengine_1.3.1/google/appengine/ext/gql/__init__.py", line 1056, in __OrderBy
return self.__Limit()
File "[PATH TO APP ENGINE INSTALL]google_appengine_1.3.1/google/appengine/ext/gql/__init__.py", line 1098, in __Limit
return self.__Offset()
File "[PATH TO APP ENGINE INSTALL]google_appengine_1.3.1/google/appengine/ext/gql/__init__.py", line 1117, in __Offset
return self.__Hint()
File "[PATH TO APP ENGINE INSTALL]google_appengine_1.3.1/google/appengine/ext/gql/__init__.py", line 1140, in __Hint
return self.__AcceptTerminal()
File "[PATH TO APP ENGINE INSTALL]google_appengine_1.3.1/google/appengine/ext/gql/__init__.py", line 784, in __AcceptTerminal
self.__Error('Expected no additional symbols')
File "[PATH TO APP ENGINE INSTALL]google_appengine_1.3.1/google/appeng
ine/ext/gql/__init__.py", line 724, in __Error
(error_message, self.__symbols[self.__next_symbol]))
BadQueryError: Parse Error: Expected no additional symbols at symbol select
This is a simple fix:
query = MODEL_NAME.gql("select * from MODEL_NAME where name = :1", supplied_name) 
App Engine's orm is already supplying the "select * from" part of the query.

Thursday, May 13, 2010

Gql and object inheritance

I am working on an AppEngine project using the Kay Framework.
I was testing my queries in Kay Framework's shell. If you are familiar with Django's shell it is essentially the same.

Running the following query :
query = db.GqlQuery("select * from MyUserObject where user_name = :1 and password = :2")
I got this error :
raise KindError('No implementation for kind \'%s\'' % kind)
I had imported the object. My object inherits from the framework's DatatstoreUser.


Changing to the following :
query = MyUserObject.gql("where user_name = :1", "testuser@testuser.com")
provided exactly what I needed.

Friday, April 30, 2010

Projects using GWT 1.5 or lower may only specify one entry point module to compile

Despite
Having the 2.0.3 GWT plugin installed
Never having used the 1.5 GWT plugin

I was getting the following error when clicking the GWT compile button :
 Projects using GWT 1.5 or lower may only specify one entry point module to compile
The solution was to move my GWT dependencies above my Maven dependencies.

Right click on the project -> Build Path -> Configure Build Path... -> Order and Export
Click on GWT SDK and Up until it is just below the JDK.

Please make sure the -vm option in eclipse.ini is pointing to a JDK

Ececutive summary : put the vm argument on the line after "-vm" in eclipse.ini.

I got the following dialog after a fresh Eclipse install :
The Maven Integration requires that Eclipse be running in a JDK, because a number of Maven core plugins are using jars from the JDK.
Please make sure the -vm option in eclipse.ini is pointing to a JDK and verify that Installed JREs are also using JDK installs.

The Installed JREs were already pointing to a JDK. I set my my eclipse.ini to : -vm C:\Sun\SDK\jdk
-vm C:\Sun\SDK\jdk\bin\javaw.exe

No luck.
Eclipsepedia has an eclipse.ini.

I put the vm location on the next line and everything worked.

Tuesday, March 16, 2010

Cool NetBeans Plugin

Last week at AJUG's Devnexus conference Venkat Subramanium made an interesting point about IDEs.

He asked how many of the people in attendance used Eclipse. Unsurprisingly almost everyone raised a hand.

Then he asked how many of us would use it if it cost $500. Almost all of the hands dropped, including mine.

I downloaded NetBeans and IntelliJ.

I had used NetBeans for a while before. One thing I liked was its themes. I like light text on a dark background.

I found this theme, Aloha, and installed it. Pretty nice.

Wednesday, March 10, 2010

Django Nonrel and Google App Engine

The guys behind appengine patch have a new project using the Django nonrel project to run on App Engine.

Clone the appropriate projects from bitbucket :
$ hg clone https://[Bitbucket User Name]@bitbucket.org/wkornewald/django-nonrel/
$ hg clone https://[Bitbucket User Name]@bitbucket.org/wkornewald/djangoappengine/
$ hg clone https://[Bitbucket User Name]@bitbucket.org/wkornewald/django-testapp/


The instructions say next, "Now you should be able to create a new app in the testapp folder and use native Django models on App Engine. Try it!"

dignan@dignan-laptop:~/workspace/django-nonrel/django-testapp$ python manage.py runserver
Traceback (most recent call last):
File "manage.py", line 4, in <module>
from djangoappengine.boot import setup_env
ImportError: No module named djangoappengine.boot

Hmmm.
The documentation calls for two symlinks :
django-testapp/common-apps/djangoappengine -> ../../djangoappengine
django-testapp/common-apps/djangoappengine -> ../../django-nonrel/django

I created them and tried again.
The Google App Engine SDK could not be found!
Make sure it's accessible via your PATH environment.
So I added the it to my path and tried again. Same result.

I found the following on the appengine-patch website:
"you can also put the SDK into any folder that is in the system's PATH environment variable as long as it's called "google_appengine" (this works with any OS)"

My sdk was in "google_appengine_1.3.0". I created a symlink, "google_appengine" and tried again.

/home/dignan/tools/appengine/google_appengine_1.3.0/google/appengine/api/datastore_file_stub.py:40: DeprecationWarning: the md5 module is deprecated; use hashlib instead                                                             
import md5
/home/dignan/tools/appengine/google_appengine_1.3.0/google/appengine/api/memcache/__init__.py:31: DeprecationWarning: the sha module is deprecated; use the hashlib module instead
import sha
WARNING 2010-03-10 22:41:09,468 datastore_file_stub.py:483] Could not read datastore data from /tmp/django_nonreltest.datastore
Traceback (most recent call last):
File "workspace/django-norel/django-testapp/manage.py", line 16, in <module>
execute_manager(settings)
File "/home/dignan/workspace/django-norel/django-testapp/common-apps/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/home/dignan/workspace/django-norel/django-testapp/common-apps/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "workspace/django-norel/django-testapp/common-apps/djangoappengine/management/commands/runserver.py", line 88, in run_from_argv
start_dev_appserver(argv)
File "workspace/django-norel/django-testapp/common-apps/djangoappengine/management/commands/runserver.py", line 74, in start_dev_appserver
dev_appserver_main.main([progname] + args + [os.getcwdu()])
File "/home/dignan/tools/appengine/google_appengine_1.3.0/google/appengine/tools/dev_appserver_main.py", line 360, in main
config, matcher = dev_appserver.LoadAppConfig(root_path, {})
File "/home/dignan/tools/appengine/google_appengine_1.3.0/google/appengine/tools/dev_appserver.py", line 3441, in LoadAppConfig
raise AppConfigNotFoundError
google.appengine.tools.dev_appserver.AppConfigNotFoundError



At least it started! I cd'd into the app's directory and ran:

python manage.py runserver


It started up. I got the default "It worked!" page.