Live Fast, Code Hard, Die Young

Archive for the ‘FAQ’ Category

Google App Engine SDK bug?

I encountered a problem with the Google App Engine development server today and it seemed like a good thing to blog about how I solved it.

I got this error when posting binary data to my locally running development server (GAE 1.8.9 and Python 2.7.2):

ProgrammingError(‘You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings.

I think the problem was due to some limitation in Sqlite but I didn’t dig very deep into it. So how to fix it?

I was able to get around the error by simply patching a source file that comes with the Google AppEngine SDK. In the file logservice_stub.py you can insert the following line:

logservice_stub_py_-_IrisServer_-____Documents_IrisServer_-10

(This file is usually located at /usr/local/google_appengine/google/appengine/api/logservice/logservice_stub.py)

Hope this helps!

 

Advertisement

Altering database tables with VS2010

One thing I find quite annoying in Visual Studio is when I try to modify an existing database table and get the following error dialog that prevents me from saving:

image

“You cannot save changes that would result in one or more tables being re-created”

So, what the heck is up with that? This seems to appear when you move columns around or change the “Allow Nulls” setting. I know I could do this in earlier version of Visual Studio so why can’t I do it anymore? Yes, I know I’m changing the table structure fundamentally but I know what I’m doing and it should be safe to do it – just let me save please!

Well, the wall of text in the dialog actually tells you what to do. You have to enable this in the VS options. For some reason this is disabled by default and my guess is that it is to prevent people who have no clue what they are doing from destroying the database schema…

Anyway here is where you find the option that you should disable. It is called “Prevent saving changes that require table re-creation”:

image

Does this mean that you entire table data will be erased when you make a change? No, certainly not! All it means is that your data will be copied to a temporary table and then copied back when the table has been altered. I guess this is how it has always worked but before you never had to bother about it – it just worked.

Well, thanks to this little option it now works again!

Problems with compiling XAML in Silverlight

Just recently we had some problems compiling XAML files in our Silverlight project. The files had been copied from one project to another class library and after renaming and refactoring the namespaces we still got compilation errors. The error we got was something like this:

The name ‘xxxxx’ does not exist in the current context

Visual Studio was complaining about code in our codebehind file. Apparently it could not find the controls that we had in our XAML although we were absolutely sure that they were there…

It turned out to be quite simple to solve. When we copied the files between projects Visual Studio changed the build action to “ApplicationDefinition”. This is clearly not right (may be a bug in VS2010). User controls should have a build action set to “Page” like this:

image

I hope this helps!