Example #1
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
Example #2
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
Example #3
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
Example #4
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
Example #5
0
def modify_user(from_key=None, from_user_id=None, **attr_dict):
    _validator = pocket.Validator('vUser')
    _entry = select_user(key=from_key, user_id=from_user_id)
    if _entry:
        _dict = _entry.__dict__
        _from_dict = _entry.properties()
        for _key in _from_dict:
            _from_dict[_key] = _dict['_' + _key]
        _to_dict = dict(_from_dict)
        _to_dict.update(attr_dict)
        return (service.modify_on(service.User, _from_dict, _to_dict)
                if _validator.validate(**_to_dict) else 0)
    return 0
Example #6
0
def modify_tag(from_key=None, from_name=None, **attr_dict):
    _validator = pocket.Validator('vTag')
    _entry = select_tag(key=from_key, name=from_name)
    if _entry:
        _dict = _entry.__dict__
        _from_dict = _entry.properties()
        for _key in _from_dict:
            _from_dict[_key] = _dict['_' + _key]
        _to_dict = dict(_from_dict)
        _to_dict.update(attr_dict)
        return (service.modify_on(service.Tag, _from_dict, _to_dict)
                if _validator.validate(**_to_dict) else 0)
    return 0