Designing the Appengine

What I am trying to do with my project is to read the unique sequence of the RFID tag given to different user and to record the time of reading in the appengine for further needed processing. Can be used in attendance marking, recording of bus timings at a particular place etc.

Thus the job of appengine is to capture the posted message which contain the unique sequence, time of reading and place of reading. It also has to display the contents in the database when requested by the GET method. It has to refresh the page automatically in every 10-15 seconds. The refresh method and displaying of the contents is done using Javascript in a different module.

The appengine code contains three classes: one is the database class, another for post method and one for get method. Both post and get are done in different pages. The following are the libraries imported:

  • import os
  • from google.appengine.ext.webapp import template
  • from google.appengine.ext import db
  • from google.appengine.ext import webapp
  • from google.appengine.ext.webapp.util import run_wsgi_app

The datastore contain 3 fields: place(for the location of RFID reader), sequence(for the unique tag id) and the date(for the time of reading).

  • class Store(db.Model):
  • place = db.StringProperty()
  • sequence = db.StringProperty()
  • date = db.DateTimeProperty()

Then we created an object, ‘application’, of the class WSGIApplication. That contain two option. If we select ‘/’ we get the control to the class MainPage which do the data storing job using the post method. If we select ‘/display’, we get the content in the database using get method.

  • application = webapp.WSGIApplication([(‘/’,MainPage),(‘/display’, Display)] )

In the class MainPage we do the storage of all details in the database by creating an instance of the storage class Store. We assign the values coming with the request to the corresponding fields. And store it permanently using the put() method.

  • class MainPage(webapp.RequestHandler):
  • def post(self):
  • store = Store()
  • store.sequence = self.request.get(‘sequence’)
  • store.place = self.request.get(‘place’)
  • store.date = self.request.get(‘time’)
  • store.put()

The class Display does he function of displaying the contents of database using the get() method. We use Store.all() to retrieve all the values stored in the database. Then we use template to call the html function defined in another file, to display the contents on the screen.

  • class Display(webapp.RequestHandler):
  • def get(self):
  • store_query = Store.all()
  • store = store_query.fetch(10)
  • template_values = { ‘store’ : store }
  • path = os.path.join(os.path.dirname(__file__), ‘index.html’)
  • self.response.out.write(template.render(path,template_values))
Advertisements

About Odol Shinu

I've completed my B Tech in Information Technology in 2010 from Government Engineering College Sreekrishnapuram Palakkad under Calicut University.

Posted on September 11, 2010, in Appengine/RFID Reader Project. Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: