示例#1
0
def add_user(**attr_dict):
    _validator = pocket.Validator("vUser")
    _dict = _validator.validate(**attr_dict)
    if _dict:
        service.add_to(service.User, **_dict)
        return True
    return False
示例#2
0
def add_tag(**attr_dict):
    _validator = pocket.Validator("vTag")
    _dict = _validator.validate(**attr_dict)
    if _dict:
        service.add_to(service.Tag, **_dict)
        return True
    return False
示例#3
0
def add_latestarticle(**attr_dict):
    _validator1 = pocket.Validator("vBaseArticle")
    _validator2 = pocket.Validator("vFormalArticle")
    _validator3 = pocket.Validator("vLatestArticle")
    if _validator1.validate(**attr_dict) and _validator2.validate(**attr_dict) and _validator3.validate(**attr_dict):
        service.add_to(service.LatestArticle, **attr_dict)
        return True
    return False
示例#4
0
def add_comment(ancestor_key, **attr_dict):
    _validator = pocket.Validator("vBaseArticle")
    if _validator.validate(**attr_dict):
        _validator = pocket.Validator("vComment")
        if _validator.validate(ancestor_key=ancestor_key, **attr_dict):
            _self_key = service.add_to(service.Comment, ancestor_key=ancestor_key, **attr_dict)
            if _self_key:
                _entry = select_basearticle(key=_self_key)
                _entry.comment_list.append(_self_key)
                _entry.put()
                return True
    return False