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.