本文整理汇总了Python中models.Tweet.gql方法的典型用法代码示例。如果您正苦于以下问题:Python Tweet.gql方法的具体用法?Python Tweet.gql怎么用?Python Tweet.gql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Tweet
的用法示例。
在下文中一共展示了Tweet.gql方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models import Tweet [as 别名]
# 或者: from models.Tweet import gql [as 别名]
def get(self):
datatype = self.request.get('datatype')
fortnight_ago = datetime.now() + timedelta(days=-14)
counter = 0
self.response.out.write(
"Looking to delete stuff from before " + str(fortnight_ago) + "<br>"
)
if datatype == "tweet":
old_tweets = Tweet.gql(
'WHERE created_at < :before LIMIT 1000', before=fortnight_ago)
for t in old_tweets:
t.delete()
counter += 1
elif datatype == "analysis":
old_analyses = Analysis.gql(
'WHERE created_at < :before LIMIT 1000', before=fortnight_ago)
for a in old_analyses:
a.delete()
counter += 1
elif datatype == "gdata":
old_gdatas = AnalysisGData.gql(
'WHERE created_at < :before LIMIT 50', before=fortnight_ago)
for g in old_gdatas:
g.delete()
counter += 1
else:
self.response.out.write("Please say what datatype you'd like to tidy up. ")
self.response.out.write(str(counter) + " items deleted")
示例2: get
# 需要导入模块: from models import Tweet [as 别名]
# 或者: from models.Tweet import gql [as 别名]
def get(self):
self.response.headers["Content-Type"] = "text/plain"
myplace = self.request.get('place')
urlbase = 'http://search.twitter.com/search.json'
if myplace == 'Oxford':
search_url = urlbase + '?geocode=51.751944%2C-1.257778%2C10km'
elif myplace == 'London':
search_url = urlbase + '?geocode=51.511676%2C-0.133209%2C10km'
elif myplace == 'York':
search_url = urlbase + '?geocode=53.958333%2C-1.080278%2C10km'
elif myplace == 'Margate':
search_url = urlbase + '?geocode=51.382681%2C1.3664245%2C10km'
elif myplace == 'Bristol':
search_url = urlbase + '?geocode=51.45%2C-2.583333%2C10km'
else:
self.response.out.write(("Please provide a 'place' parameter:"
"Oxford, London, York, Bristol or Margate."))
self.response.out.write('About to access: %s\n\n' % search_url)
f = urlfetch.fetch(url=search_url)
if f.status_code == 200:
j = json.loads(f.content)
for result in j['results']:
self.response.out.write(result)
self.response.out.write('\n')
if (result['id']):
same_id = Tweet.gql('WHERE tweet_id = :1', result['id'])
if (same_id.count() > 0):
self.response.out.write('Tweet id #%s exists in the datastore\n'
% result['id'])
else:
self.response.out.write('Adding tweet id #%s to datastore\n'
% result['id'])
created_at = datetime.fromtimestamp(
mktime_tz(parsedate_tz(result['created_at'])))
tweet = Tweet(
tweet_id=result['id'],
tweet_content=result['text'],
place=myplace,
created_at=created_at
)
tweet.put()
elif f.status_code == 400:
self.response.out.write('UHOH! You have hit the rate limit...')