Sunday, August 3, 2008

Setting up the DNS

Trying to figure out DNS has given me some problems. Unfortunately some bugs exist in setting up the GAE so I will try and outline what I have found here.

You are able to register a domain with google for $10 a year, this is a great bargain as it includes privacy. At this stage it does not look as though they are allowing domain transfers.

1. Firstly you will have to have your domain name registered with google apps.
http://www.google.com/a/ - sign up here
Once you have signed up you can log in to your like this;
http://www.google.com/a/yourdomain.com

2. You will need to figure out the numbers needed for the A records from google. I have found them at this location: http://www.google.com/support/a/bin/answer.py?answer=91080&hl=en
The numbers when I last checked are;
  • 216.239.32.21
  • 216.239.34.21
  • 216.239.36.21
  • 216.239.38.21
3. Log in to your domain host e.g. GoDaddy (Which I have used in this example).
From the domain manager, select the domain you wish to use. The select "Total DNS control and MX records" (If this is missing you will need to make sure you have set godaddy as your dns host)
In the boxes you will need to delete all the current A records then add the following under A(host);
Host: @ Points to: 216.239.32.21
Host: @ Points to: 216.239.34.21
Host: @ Points to: 216.239.36.21
Host: @ Points to: 216.239.38.21

While you are there you should set up the rest of your dns.
Under CNAME (aliases);
Host: www Points to: ghs.google.com
(You can add whatever sub domains here that you wish to use)

If you are using google for your email double check the MX records while you are there.
Priority: 1 Host: @ Goes to:aspmx.l.google.com
Priority: 5 Host: @ Goes to:alt1.aspmx.l.google.com
Priority: 5 Host: @ Goes to:alt2.aspmx.l.google.com
Priority: 10 Host: @ Goes to:aspmx2.googlemail.com
Priority: 10 Host: @ Goes to:aspmx3.googlemail.com

This should be all you need to do on the DNS side of things.

4. Go to the Google application engine and make sure you do things in the right order;
From the dashboard select;
Add More Services, then type in the name of your google app e.g. myapp
Select the tick in the agree box, then type in the name of your web address;
Type in: temp.yourdomain.com DO NOT put: yourdomain.com
The press "continue to set up URL"

go back to the dashboard now add a new service yourdomain.com to yourapp
then do it again for www.yourdomain.com.

Once you have done this you can delete temp.yourdomain.com from your application.

5. Wait.
In theory this should work and you will never have to touch it again.
However check that it works sometime later (24 to 48 hours)
make sure you check both www.yourdomain.com and yourdomain.com

With one of my apps www.domain.com didn't work so I had to delete the www from myapp then add it again.

Hopefully that should get you around the two main bugs which I found, if you have any further questions or comments please feel free to ask on the google apps group.

Thursday, July 3, 2008

yaml and gae

Yaml (Yet Another Markup Language) is Google's prefered way of dealing with the structure of its web applications and in this case the Google Application Engine.

The documentation I can find is located at;
yaml.org
The getting started guide for configuring an app gives something of an overview.

For some strange reason an example on how to deal with a single static file is not found in the documentation. Looks like I will have to deal with things a little different to the way i am used to.
I also seem to have a problem with mime types using mime_type setting. The mime_type is overwritten by googles settings somewhere along the line.

The app.yaml file is far from alone, there is also settings.py file which is used by python and django also has a settings file (django_bootstrap.py) to add to the mix.
Example django bootstrap file.

Formatting Dates with Django

Simply letting a date field be displayed with django results in something like this;
2008-07-03 09:20:12.019000
Which is quite helpful in the scientific world but it doesn't really add much to a lot of applications other than confusion.
The way to handle dates is to pass them through something of a filter like this;
{{ datefield|date:"d M Y" }} and the output is : 03 Jul 2008

The filter list can be found in the Django documentation;
http://www.djangoproject.com/documentation/templates/#now

The is also a somewhat useful entry I found here on the topic;
http://www.magpiebrain.com/blog/2005/08/21/formatting-dates-with-django/

Thursday, June 26, 2008

Django includes

Another problem which has irked me in recent days is including another file within the one I am displaying.
If I use the include statement in a page which is used by django like
this;
{% include "includes/footer.html" %}
I need to change it to look like;
{% include "static/includes/footer.html" %}
What do I need to edit within django so it can represent or look
similar to changes I have made to the app.yaml file?
- url: /includes
static_dir: static/includes

While this is something of a fixable problem it is exacerbated when theapplication is loaded onto the Google appspot and the the file to include is ignored even though the file is present.

Filenames and case sensitivity.

If a reference an image from my local machine(windows) I have no problem accessing a filename such as: FileName.jpg even if the name of the file is filename.jpg.

Luckily it was a small problem to fix and caused no major problem other than a couple of minutes type fixing the variables with the .lower() command in python.

Monday, June 9, 2008

Favicon with gae

While creating any new web application the one thing which I look at the most is the logs. The logs tend to give me a good idea of what is happening and in my case what I am doing wrong.

One error message which I am getting a lot of is;
INFO 2008-06-09 17:14:37,313 dev_appserver.py] "GET /favicon.ico HTTP/1.1" 404 -

This means a favicon is missing. So I went to the google application website and picked up the favicon and dumped it in my application directory.
http://appengine.google.com/favicon.ico

I also needed to add to the file app.yaml.
- url: /favicon.ico
static_files: static/images/favicon.ico
upload: static/images/favicon.ico

This option allows any images to be automatically shown without having to be processed any further.

A problem which I have found by doing this is the mime_type really needs to be set to something else, but it doesn't seem to work.

You will need to ensure that this statement is placed before others that my overwrite it, so check the order in the yaml file

More about this can be read here;
http://code.google.com/appengine/docs/configuringanapp.html