Blog updates for App Engine, Caching data and non-normalized database work.
I made a number of improvements to this blog engine over the last couple of weeks. Most note-able was performance improvements to pre-render and cache HTML. There has been a lot of discussion and movement in the web architecture community towards not-traditional Database designs, not normalizing data, and storing caclulated info, and even moving to non-relational database designs. All because Internet scale data-bases built on transactional systems just seem fraught with problems and forces you to build around the db instead of around the needs of the web apps. The Google App Engine article on High Scalability gives a lot of great insight into App Engine which i had been discovering separately.
In order to incorporate a lot of the improvements possible out of Google App Engine Datastore, you have to start to do things different, here are what i did to help build a better google app engine based app:
- OnChange Handler: Since we are often pre-rendering, and caching html, we need to get hooked into the events which signify when we need to make a change. Digging into the Google Datastore API, i did some reverse engineering to try to figure out how I can figure out when something is changing. What i came up with is to provide a Base model which i inherit from which allows me to write OnChange methods per attribute.
from google.appengine.ext.db import Model as DBModel class BaseModel(db.Model): def __init__(self, parent=None, key_name=None, _app=None, **kwds): self.__isdirty = False DBModel.__init__(self, parent=None, key_name=None, _app=None, **kwds) def __setattr__(self,attrname,value): """ DataStore api stores all prop values say "email" is stored in "_email" so we intercept the set attribute, see if it has changed, then check for an onchanged method for that property to call """ if (attrname.find('_') != 0): if hasattr(self,'_' + attrname): curval = getattr(self,'_' + attrname) if curval != value: self.__isdirty = True if hasattr(self,attrname + '_onchange'): getattr(self,attrname + '_onchange')(curval,value) DBModel.__setattr__(self,attrname,value)Then, on my Entry class (blog entry), i implemented a method whenever an entry changes from published to draft and back, and updated the archive.class Entry(BaseModel): author = db.UserProperty() blog = db.ReferenceProperty(Blog) published = db.BooleanProperty(default=False) content = db.TextProperty(default='') # more cut out def published_onchange(self,curval,newval): """ Gets called every time published status changes """ if self.entrytype == 'post': my = self.date.strftime('%b-%Y') # May-2008 archive = Archive.all().filter('monthyear',my).fetch(10) if curval == False and newval == True: # add to archive if archive == []: # new month archive = Archive(blog=self.blog,monthyear=my) else: archive = archive[0] archive.entrycount += 1 archive.put() self.blog.entrycount += 1 else: # remove from archive if archive and archive[0]: archive = archive[0] archive.entrycount -= 1 if archive.entrycount == 0: archive.delete() else: archive.put() self.blog.entrycount -= 1 self.blog.save() - Pre-Render HTML: On the previous entry, we are storing some tables (Archive) which are purely used for convenience. They are never called at runtime, and in fact the Archive table is then rendered into html and stored again. Here is an admin entry "POST" update that then calls to update the cache. The Cache is actually a Blog entity which is used on every single request. It is half way between a Cache, configuration and context in normal web apps.
class AdminEntry(BaseController): def post(self,entrytype='post',key=None): #update entry from form post entry.save() rebuild_cache(self.blog) def rebuild_cache(blog): """ Pre-Render's and cache's html in blog object. Everything in here doesn't change very often, so we can update it at point of change """ pages = Entry.all().filter("entrytype =", "page").filter("published =", True).fetch(20) archives = Archive.all().order('-date').fetch(10) recententries = Entry.all().filter('entrytype =','post').filter("published", True).order('-date').fetch(10) links = Link.all().filter('linktype =','blogroll') template_vals = {'recententries':recententries,'pages':pages, 'links':links,'archives':archives} path = os.path.join(os.path.dirname(__file__), 'views/sidebar.html') blog.sidebar = template.render(path, template_vals) path = os.path.join(os.path.dirname(__file__), 'views/topmenu.html') blog.topmenu = template.render(path, template_vals) blog.save()
These tricks helped make writing App engine even easier, moving more to an event driven model that updates the cache. You can find all the code from this app at the Github code repository.
14 Comments
HEPEWY tthkboideyhm, [url=http://eljowtbqclbz.com/]eljowtbqclbz[/url], [link=http://ovpkpkyvtdhf.com/]ovpkpkyvtdhf[/link], http://fbqzjgusdaaw.com/
This blog Is very informative , I am really pleased to post my comment on this blog . It helped me with ocean of knowledge so I really believe you will do much better in the future . Good job web master .
CHARMINGIRL is a conspicuous rank and Sexy Lingerie wholesale specialized producer of dirty clothing in China. We purveying the ecumenical demand with stylish seductive lingerie and erotic costumes since 2002. With advanced technology,all our effects are of grand quality. Now we be subjected to clients all on all sides of the give birth to. Lingerie Wholesale and OEM are received!
Our works located in Foshan Guangdong, Sexy Lingerie wholesale where there is one of the in generalst directedgarment manufacturing miserable in China. Charmingirl has footing workshop and drama tailback, master designers and capable workers. After years' increment, we be subjected to craggy cap faculty on drama, scrutinize and technology, advanced facilities that is imported fromGermany and Japan, now our monthly crop is 100000 pcs.
Sexy Lingerie wholesale
is one of the in generalst wholesale and retail distributors of Sexy Lingerie wholesale lingerie in the USA less than one roof. Since 1997, we be subjected to sold tens of 1,000's of consumers for everyone the time wholesale and retail lingerie. Our Atlanta store is unreserved to the encyclopaedic dick diurnal Tuesday - Saturday.
Sexy Lingerie wholesale
LingerieMart.com ? - is a greatwide distributor of Sexy Lingerie wholesale wholesale lingerie and sexual clothing at off-assay and here wholesale assays. We pass round globally all types of lingerie including seductive lingerie, bras A-J cups, panties, thongs, sleepwear to 6XL, fajas, shapewear to evaluate 50" waist, costumes, erotic clubwear / dancewear and more. In adding, our group includes the big-heartedst discrepancy of wholesale rank marque bonus measure assess bras, bonus evaluate thongs and panties, bonus volume bra sets, wholesale corsets, girdles, integument attention effects and more.
Sexy Lingerie wholesale
At Lingerie Mart ? - not simply Sexy Lingerie wholesale sells wholesale to the prevalent following, but also supplies a sort of transaction venues including boutiques, retail stores, take outlets, domestic parties, EBay re-sellers, flea vends, lingerie websites and more. We admire our clients and orders of all measure assess. Whether your effect necessity's are in general or modest, we receive all orders and buyers from all countries. Our maven, convivial and prepared consumer benefit band is on the verge of to assistance you, and our immovably shipping hang on allows your orders to be shipped most of the time within 24 hours.
Hey everyone. I'm hoping to meet new friends here so drop me a note when you
get a chance.
I hope to make some quality posts soon but first I have to look around the forum and
familiarize myself with everyone and the forum.
Bye for now. lol
***************************************************
Biggest Loser of All Time
DALLAS, TX - Her name: the bra whisperer Sexy Lingerie. Her commission: to get women into well-advised b wealthier comme il faut bras.
She's been featured on countless TV shows, including Oprah, for her acquaintance on all things braziers. And in the present climate Susan Nethero is bringing her expertise to Dallas at her contemporary Intimacy store in Northpark Center.
I went driving everywhere with her as she hunted an eye to bra violations. She says, "Ooh my, this woman needs some help! Hindrance's do a small bra intervention."
After assessing everything wrong with this runner's sports bra, "It's riding up the uncivilized and causing the boob to support down in the cover-up, so that's really damaging the tissue at the base of the mamma," she begins the ambush makeover. She says to the dispatch-rider, "Can I carry out you to Intimacy? We're bra seizure specialists!"
We've all seen the ads and commercials where runway models are wearing skimpy inviting lingerie that just doesn't furnish that much coverage.
But at Intimacy the struggle is around helping Sexy Lingerie real women with material curves find the perfect fit with a dirty edge.
Susan says, "It renews your confidence, gives you uplift, and makes every helpmate be sorry for more beautiful."
That's why Intimacy offers over 100 different styles and believes every fellow should be Sexy Lingerie custom-made to finger her ideal bigness and shape. Angela's new sports bra has underwire, thicker straps and she went from a size 36D to a 32E.
Angela says, "I was shocked because in behalf of so fancy I've gone in and bought bras or bought them online, and thought I had the sound size. And undeviating reasonably that's why they've been so uncomfortable."
And in return an unexciting bra, she picked a glassy forefront tatting that's strapping and sassy. "I feel really passable, I air like I could harass it subservient to a Tshirt," she says.
It's transformed the way Angela thinks back her lingerie and the behaviour pattern she feels in them. She says, "In the presence of my bras would move out a lot and on the brink of look at clich?up and down. Contemporarily I have the impression very immune and it's not going Sexy Lingerie anywhere."
The post really nice , i like it ,thanks for sharing,thanks for your post, i will keep read your blog everyday
Ok, when i start the game up, it works just fine. But then, about 20 minutes into the game, It starts lagging really bad, and the only way to get it to stop, is to restart my computer. Any help here as to how to stop the lag?
________________
unlock iphone 3gs
My t60 think pad has been ravaged by a virus and now a bunch of the drivers are screwed up so I have decided to just reinstall windows because there is no fixing this any other way. I don't have the boot disk for the laptop, so is there anywhere I can get a boot disk besides the ibm website because they just have a bunch of downloads and I don?t know which ones to choose.
________________
how to unlock iphone 3g
i have an ide 133 hdd and i cant get xp to install onto it with my dell optiplex gx260 which has an ide 100 mobo. is this y windows wont install
________________
unlock iphone
every dofuser needs dofus kamas, but most of them can't find a good cheap dofus kamas provider, so it's a problem is they want to buy dofus kamas.now bawwgt will be your best choice on dofus
every dofuser needs dofus kamas, but most of them can't find a good cheap dofus kamas provider, so it's a problem is they want to buy dofus kamas.now bawwgt will be your best choice on dofus
I have the original iphone, and it's unlocked so I dont want to update it or it will brick, but some games require at least version 2.0, so how do I find out if I have that or not? Thanks.
________________
buy unlock iphone
I can't figure out how to do it with my yahoo profile. I can't upload with just my iPhone and my laptop Does not have Internet.
________________
unlock iphone 3g unlock iphone 3gs 3.1 unlock iphone 3gs 3.0 unlock iphone 3gs unlock iphone 3g 3.0 unlock iphone 3g 3.1
who loves sports [url=http://www.ghdokay.com ]ghd hair[/url]shoes will remember Nike's Air Using your MSN buy jordan shoes or your E-m Send mail annexed to cooperate with us. If you post orders.buy jordan shoes You can through the global Internet,hair straighteners,[url=http://www.ghdhairtop.com]hair straighteners[/url]ghd hair,[url=http://www.ghdokay.com ]ghd hair[/url]Send your own way site. Postal code and telephone number.[url=http://www.ajkey.com]gucci shoes[/url] Canadians might have to issue a few I.O.U.