def post(self): t_values = {} current_link_id = self.request.POST['current_link_id'] link_title = self.request.POST['link_title'] link_target = self.request.POST['link_target'] link_sequence = self.request.POST['link_sequence'] logging.info("LinkManager post: current_link_id = %s, link_title = %s, link_target = %s, link_sequence = %s" % (current_link_id, link_title, 'link_target', 'link_sequence')) if current_link_id: # edit existed link link = Link.get_by_id(long(current_link_id)) link.title = link_title link.target = link_target link.sequence = long(link_sequence) link.put() t_values['alert_message'] = "link %s has been updated" % (link.title) else: # create new link link = Link(title=link_title, target=link_target, sequence=long(link_sequence)) link.put() t_values['alert_message'] = "link %s has been added" % (link.title) # find all links links = Link.all().order("-date") t_values["links"] = links return self.response.out.write(render_template("links.html", t_values, "", True))
def post(self): action = self.param('action') name,url = (self.request.get(item) for item in ('linkName', 'linkURL')) if(action == 'edit'): key = self.param('id') link = Link.get_by_id(int(key)) link.linkName = name link.linkURL = url else: link = Link(linkName=name,linkURL=url) link.put() self.redirect('/admin/links') return
def post(self): action = self.param('action') name, url = (self.request.get(item) for item in ('linkName', 'linkURL')) if (action == 'edit'): key = self.param('id') link = Link.get_by_id(int(key)) link.linkName = name link.linkURL = url else: link = Link(linkName=name, linkURL=url) link.put() self.redirect('/admin/links') return
def save_link(cls, title, url, body="", tags=[], clicks=0, unread=True): url = norm(url) id = mmh3.hash(url) key = ndb.Key(LinkModel, id) domain = urlparse(url).netloc if len(domain)>4 and domain.startswith('www.'): domain = domain[4:] link = LinkModel( key = key, title = title, url = url, domain = domain, body = body, tags = tags, clicks = clicks, unread = unread ) link.put() id = str(link.id) doc = cls._buildDoc(id, title, body, domain, tags) cls.add(doc) return cls(doc, link)
def save_link(cls, title, url, body="", tags=[], clicks=0, unread=True): url = norm(url) id = mmh3.hash(url) key = ndb.Key(LinkModel, id) domain = urlparse(url).netloc if len(domain) > 4 and domain.startswith('www.'): domain = domain[4:] link = LinkModel(key=key, title=title, url=url, domain=domain, body=body, tags=tags, clicks=clicks, unread=unread) link.put() id = str(link.id) doc = cls._buildDoc(id, title, body, domain, tags) cls.add(doc) return cls(doc, link)
def get(self): link = Link(title="linkx1", target="http://baidu.com", sequence=9) link.put() link = Link(title="linkx2", target="http://baidu.com", sequence=9) link.put() link = Link(title="linkx3", target="http://baidu.com", sequence=9) link.put() return self.response.out.write(render_template("index.html", {}, "basic", False))