Example #1
0
    def get(self):
        uri = self.request.uri
        productsPreFix = 'Products/'
        productName = urllib.unquote(uri[uri.rfind(productsPreFix) +
                                         len(productsPreFix):])
        query = Product.gql('where name = :name', name=productName)
        productEntry = query.get()
        if productEntry == None:
            self.error(404)
            self.response.out.write("Not found")
            return

        template_values = {'productEntry': productEntry}
        self.generate('Products.html', template_values)
 def get_product(self,values,productid,product,price):
   if productid:
     result=Product.gql("where ean=:1 limit 1",productid).get()
     if not result:
       if price and product:
         result=Product()
         result.ean=productid
         result.name=product
         result.price=int(float(price)*100)
         result.put()
     else:
       product=result.name
       price=result.price
   else:
     result=None
   values["productid"]=productid
   values["product"]=product
   values["price"]=price
   return result