本文整理汇总了Python中resource.Resource.put方法的典型用法代码示例。如果您正苦于以下问题:Python Resource.put方法的具体用法?Python Resource.put怎么用?Python Resource.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类resource.Resource
的用法示例。
在下文中一共展示了Resource.put方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: put_resource
# 需要导入模块: from resource import Resource [as 别名]
# 或者: from resource.Resource import put [as 别名]
def put_resource(data):
rsrc = Resource(True)
if 'resourceid' in data:
rsrcid = data['resourceid']
else:
rsrcid = str(time.time())
# the last param None is the photo data which we will fill in later
rsrc.put(data['user'], data['collectionid'], data['description'], rsrcid, None)
return rsrcid
示例2: ResourceTest
# 需要导入模块: from resource import Resource [as 别名]
# 或者: from resource.Resource import put [as 别名]
class ResourceTest(object):
def __init__(self):
self.photostore_resource = Resource(True)
self.photostore_resource.create()
def test_resource(self):
curtime = str(time.time())
self.photostore_resource.put('gopa', 1, '[%s]: test put' % curtime,
curtime)
data = self.photostore_resource.get('gopa', 1, curtime)
for d in data:
print 'GET: data cltnid %s, uid %s, description %s\n' % \
(d['g_rsrc_collectionid'], d['g_uid'], \
d['description'])
data = self.photostore_resource.get('gopa', 1, None)
for d in data:
print 'QUERY: data cltnid %s, uid %s, description %s\n' % \
(d['g_rsrc_collectionid'], d['g_uid'], d['description'])
示例3: build
# 需要导入模块: from resource import Resource [as 别名]
# 或者: from resource.Resource import put [as 别名]
def build(cls):
#Need admin acc to import
url = "https://spreadsheets.google.com/feeds/list/0ApN6pOTp7qkZdDVDMW1YSEZUelV2TFUwcFpzblM4cnc/od6/public/values?alt=json"
result = urlfetch.fetch(url)
if result.status_code == 200:
feed_obj = simplejson.loads(result.content)
if "feed" in feed_obj:
entries = feed_obj["feed"]["entry"]
# Make an application entity for each entry in feed
last = {}
# cls.response.out.write('<html><body>')
for entry in entries:
name = entry["gsx$name"]['$t']
# self.response.out.write("<p>" + name + "</p>");
note = entry["gsx$notes"]['$t']
# If new name
if not name in last.keys():
res = Resource()
res.name = name
res.note = []
logging.debug("Resource repeated %s", name)
res.website = entry["gsx$website"]['$t']
res.overview = entry["gsx$overview"]['$t']
res.audience = entry["gsx$audience"]['$t']
content = entry["gsx$content"]['$t']
if len(content) == 0:
res.content = 0
else:
res.content = int(content)
presentation = entry["gsx$presentation"]['$t']
if len(presentation) == 0:
res.presentation = 0
else:
res.presentation = int(presentation)
spanish = entry["gsx$spanish"]['$t']
if spanish == "No":
res.spanish = False
else :
res.spanish = True
res.license = entry["gsx$license"]['$t']
res.grade = entry["gsx$grade"]['$t']
else:
res = last[name] # Resource
res.notes.append(note)
logging.debug("New resource found %s", name)
res.put()
last[name] = res
resources = Resource.getResources()
i = 0
for res in resources:
# self.response.out.write("<p>" + str(res.name) + "</p>");
i = i + 1
#print ("<p>" + str(res) + "</p>")
# cls.response.out.write('Num Resources ' + str(i))
# cls.response.out.write('</body></html>')
# self.response.headers['Content-Type'] = 'text/plain'
# self.response.out.write('<html><body>')
# self.response.out.write("<p>" + " " + name + website + overview + audience + content + presentation + spanish + notes + link_license + grade)
# self.response.out.write('</body></html>')
# application = webapp.WSGIApplication([('/', MainPage)], debug=True)
#
# def main():
# run_wsgi_app(application)
#
# if __name__ == "__main__":
# main()