Use Eclipse to create mashups on Google App engine, part 3rd

Source: Internet
Author: User
Tags web services advantage

Using social networks makes it easier to get and aggregate data to create innovative new WEB applications. However, you still have to deal with all the common problems of creating a scalable Web application. Now, using the Google App Engine (GAE) can also simplify work. With GAE, you can focus on creating good mashups without having to consider all the transactions that govern the application server pool. This article is the last part of a three-part series, "Creating a mashup on Google App Engine using Eclipse," which will take advantage of and further enhance the applications built in the first two parts of this article. We will add the ability to view other users of the application and subscribe to their aggregate feeds, and then complete the mashup build by exposing the application as a WEB service that can be used by other mashups.

About this series

In this series, you will learn how to get started with the Google App Engine (GAE). In part 1th, you learned how to set up your development environment so that you can start creating applications running on GAE. Also learned how to use Eclipse to simplify development and debugging of your application. In the 2nd part, the application is enhanced by adding some Ajax features. Also learned how to monitor the application after deployment to GAE. This article is the 3rd part, which will be returned to the ecosystem by creating an RESTful Web service for the application so that others can use it to create their own mashups.

GAE is the platform for creating WEB applications. The most important prerequisite for using it is Python knowledge, because Python is used as the programming language (currently Python V2.5.2) in GAE. For this series, it will be helpful to have some typical Web development skills (e.g. HTML, JavaScript, and CSS knowledge). To develop for the app Engine, you need to download the app Engine SDK (see Resources). In this series, you also use the Eclipse V3.3.2 to assist GAE development (see Resources). and requires the PyDev plug-in to convert Eclipse to the Python IDE.

Subscription

So far, our application Aggrogator allows users to aggregate (mash up) a number of common WEB services and create aggregate feeds of these services. Now, to make things interesting, we want to allow users to subscribe to other users ' feeds (where each user's feed may be an aggregation of the feed itself). For example, suppose you need to set up an account to subscribe to your feeds in Twitter, Last.fm, and del.icio.us so that other friends can then subscribe to the Aggrogator feed to see all the activities in those services. To handle this situation, you need to revisit the data model again.

Modeling

To enable subscriptions, you need to allow one user (account) to subscribe to another account list. One approach we can take is to add a list of users to each account. Each user will add a subscription. The code for this operation will resemble listing 1.

Listing 1. Account model with the user list

class Account(db.Model):
   user = db.UserProperty(required=True)
   subscriptions = db.ListProperty(Account)

There are some advantages to this approach. When you retrieve an account, you get all the other accounts that the account subscribes to. This is a common strategy for using non-relational databases such as GAE's Bigtable: Keep all the relevant data together and not worry about things like standardization. However, there is a drawback to this approach. What if you need to show which people are subscribed to by a particular user? The only way to do this is to retrieve all the account models, view all subscriptions, and see if a given user is in the list. In addition, you can save two lists in each account model-one for subscriptions and one for subscribers. Instead of taking this approach, we use a more traditional many-to-many model, as shown in Listing 2.

Listing 2. Subscribe model

class Subscribe(db.Model):
   subscriber = db.ReferenceProperty(Account, required=True,
collection_name='subscriptions')
   subscribee = db.ReferenceProperty(Account, required=True,
collection_name='subscribers')

As you can see, this model is similar to a join table in a relational database. Just because GAE uses a relational database (Bigtable) does not mean that you cannot take advantage of technologies that are used in conjunction with relational databases. Now that the data model is in place, let's look at how to create these many-to-many relationships from the end user perspective.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.