Finished the very minuscule example for entering stocks on a google app engine project. Leave comments if you have questions.
Hope this helps!
Saturday, April 26, 2008
Thursday, April 24, 2008
Google App Engine: Scalable web sites for the masses
The first week of April brought the world another gift from Google, or so Google would like us to think. It is called the Google App Engine, an all inclusive hosted web development package without the user needing to buy any hardware what-so-ever. Oh, and it scales a tad, petty detail. The engine uses Python on the app server, and a datastore, that is transactional but not relational. Seems kind of odd, but the datastore stores and retrieve entities, or python classes, and the data model that google provides in python, called GQL, allows you to create and manipulate these entities that have been created in your program. If you have seen an ORM (Object Relational Mapper), then you would be more familiar with google's query language in python. For more information check out the following links:
For more info on:
The data store
Python on the app engine
It all sounds great up until you ask how much does this all cost to the app developers? Nothing this good grows on trees, and that is definitely the case as shown below here:
Not too bad for a small little site! The only gripe I seem to have involves getting your data out if you want to leave Google. How do you do this?! Well, at the moment you can't, and that means your completely locked in! The pricing structure goes up...too bad! Your screwed. But, it is Beta and I am willing to give them the benefit of the doubt...with dummy applications.
We've heard all about the overview, and the pricing, but what about the freakin code?! You develop these applications with SDK Google provides.
For more info on:
The data store
Python on the app engine
It all sounds great up until you ask how much does this all cost to the app developers? Nothing this good grows on trees, and that is definitely the case as shown below here:
Fixed Quotas
Quota | Limit |
Apps per Developer | 3 |
Storage per App | 500MB |
Quota | Limit |
Emails per Day | 2,000 |
Bandwidth In per Day | 10,000 MB |
Bandwidth Out per Day | 10,000 MB |
CPU Megacycles per Day | 200,000,000 |
HTTP Requests per Day | 650,000 |
Datastore API Calls per Day | 2,500,000 |
URLFetch API Calls per Day | 160,000 |
Not too bad for a small little site! The only gripe I seem to have involves getting your data out if you want to leave Google. How do you do this?! Well, at the moment you can't, and that means your completely locked in! The pricing structure goes up...too bad! Your screwed. But, it is Beta and I am willing to give them the benefit of the doubt...with dummy applications.
We've heard all about the overview, and the pricing, but what about the freakin code?! You develop these applications with SDK Google provides.
class Stock(db.Model):
ticker = db.StringProperty()
name = db.StringProperty()
price = db.FloatProperty()
class MainPage(webapp.RequestHandler):
def get(self):
stocks = Stock.all().order('-name')
if users.get_current_user():
url = users.create_logout_url(self.request.uri)
url_linktext = 'Logout'
else:
url = users.create_login_url(self.request.uri)
url_linktext = 'Login'
template_values = {
'stocks': stocks,
'url': url,
'url_linktext': url_linktext,
}
path = os.path.join(os.path.dirname(__file__), 'index.html')
self.response.out.write(template.render(path, template_values))
class StockTransaction(webapp.RequestHandler):
def post(self):
stock = Stock()
stock.ticker = self.request.get('ticker')
stock.name = self.request.get('companyname')
stock.price = float(self.request.get('price'))
stock.put()
self.redirect('/')
def main():
application = webapp.WSGIApplication(
[('/', MainPage),
('/transaction', StockTransaction)],
debug=True)
wsgiref.handlers.CGIHandler().run(application)
if __name__ == "__main__":
main()
{{ url_linktext }}
<table>
<thead>
<tr>
<td>Ticker</td>
<td>Name</td>
<td>Price</td>
</tr>
</thead>
<tbody>
{% for stock in stocks %}
<tr>
<td>{{stock.ticker}}</td>
<td>{{stock.name}}</td>
<td>{{stock.price}}</td>
</tr>
{% endfor %}
</tbody>
</table>
Subscribe to:
Posts (Atom)