2012-11-20 45 views
2

对于我的Web应用程序,我编写了本应该访问Google App Engine数据存储区中的数据的cron作业,解析网站,然后通过电子邮件发送结果。Cron作业错误:访问数据存储并通过电子邮件发送

但是,请求cron作业时出现404错误,并且不知道如何解决此问题。这是我访问数据库的方式吗?

感谢

这里是我的update.py

from google.appengine.ext import db 

import urllib2 
import string 

import myWebapp 

## CRON 1:                  
## Check all x in B.db if courses changed         
## Yes:                   
## email x                 
## if x.things all != 'Closed':            
##  remove from db               

boo = myWebapp.B.all() 

if boo.count() >0: 
    for b in boo.run(batch_size=1000): 
     currentThings = b.mThings 
     newThings = myWebapp.updateStatus(b.mThings) 
     if currentThings != newThings: 
      b.mThings = newThings 
      myWebapp.sendTextAndEmail(b.mEmail, b.mPhoneNumMail, 
         b.mThings, "myWebapp Update") 
     numClosed = 0 
     for c in b.mThings:   
      if c[2] == 'Closed': 
       numClosed += 1 
     if numClosed == 0: 
      b.delete() 

这里是我的cron.yaml:

cron: 
- description: check things and email if change 
    url: /.update.py 
    schedule: every 5 minutes 
    timezone: US/Pacific 

回答

0

的文档注:

To test a cron job, sign in as an administrator and visit the URL of the handler in your browser.

Securing URLS for CRON

如果你仍然得到404建议你做一个“正常”的处理程序,并从那里采取。

您访问数据库的方式或其他方式与404(未找到)错误无关。

+0

你是什么意思,使一个正常的处理程序?在update.py中声明一个RequestHandler,以及:app = webapp2.WSGIApplication('/ update.py',update)? –

+0

是的,让一个正常的处理程序,然后去它。如果可行,请将其转换为您的cron处理程序。 –

相关问题