Example #1
0
def register_pair_of_links(entry):
    """
    Register a binding of a permalink and a post_id.
    The registration won't change, since the binding must be permanent.
    """
    permalink = entry.get_html_link().href
    blog_id = entry.get_blog_id()
    post_id = entry.get_post_id()
    # save the pair into the memcache, if it hasn't been stored.
    if memcache.get(permalink) is None:
        memcache.add(permalink, (blog_id, post_id))
    # issue a task, if the pair hasn't been stored yet in the data store.
    if model.get_post_id(permalink, blog_id) is None:
        taskqueue.add(url='/store_pol',
                      params={'permalink': permalink, 'blog_id': blog_id})
Example #2
0
def get_post_id(permalink, blog_id):
    post_id = get_post_id_from_memcache(permalink, blog_id)
    # if not exist in the memcache, then check the datastore.
    if not post_id:
        post_id = model.get_post_id(permalink, blog_id)
    return post_id