相关疑难解决方法(0)

如何优化此Google App Engine代码?

我对蟒蛇世界比较陌生,但这似乎很直接.

谷歌对我大吼大叫这个代码需要优化:

class AddLinks(webapp.RequestHandler):
     def post(self):
          # Hash the textarea input to generate pseudo-unique value
          hash = md5.new(self.request.get('links')).hexdigest()

          # Seperate the input by line
          allLinks = self.request.get('links').splitlines()

          # For each line in the input, add to the database
          for x in allLinks:
               newGroup = LinkGrouping()
               newGroup.reference = hash
               newGroup.link = x
               newGroup.put()

          # testing vs live
          #baseURL = 'http://localhost:8080'
          baseURL = 'http://linkabyss.appspot.com'

          # Build template parameters
          template_values = {
               'all_links': allLinks,
               'base_url': baseURL,
               'reference': hash,
          }

          # Output the template …
Run Code Online (Sandbox Code Playgroud)

python optimization google-app-engine

5
推荐指数
1
解决办法
1087
查看次数

标签 统计

google-app-engine ×1

optimization ×1

python ×1