我试图根据状态更改"显示更多"文本.这不起作用:
<div id="description">
text goes here
</div>
<div id="more-less-container">
<a href="#" id="more-less">expand / collapse</a>
</div>
<script>
var open = false;
$('#more-less').click(function() {
if (open) {
$('#description').animate({height:'10em'});
$('#more-less').innerHTML ='show less';
}
else {
$('#description').animate({height:'100%'});
$('#more-less').innerHTML ='show more';
}
open = !open;
});
</script>
Run Code Online (Sandbox Code Playgroud) 假设我有一个for循环,它列出了一堆用户.循环中可能有0-n个用户.我想在每个用户名后添加逗号,除了最后一个.
因此对于:
<p>
{% for u in users %}
{{u.name}},
{% endfor }
</p>
Run Code Online (Sandbox Code Playgroud)
我明白了:
Sam, Neil, Bob,
Run Code Online (Sandbox Code Playgroud)
我想要:
Sam, Neil, Bob
Run Code Online (Sandbox Code Playgroud) 我正在尝试将表单中的多个文件上传到BlobStore.
形成:
<form action="{{upload_url}}" method="POST" enctype="multipart/form-data">
<label>Key Name</label><input type="text" name="key_name" size="50"><br/>
<label>name</label><input type="text" name="name" size="50"><br/>
<label>image</label><input type="file" name="image" size="50"><br/>
<label>thumb</label><input type="file" name="thumb" size="50"><br/>
<input type="submit" name="submit" value="Submit">
</form>
Run Code Online (Sandbox Code Playgroud)
我正在尝试为上传的每个文件获取BlobInfo对象:
def post(self):
image_upload_files = self.get_uploads('image')
thumb_upload_files = self.get_uploads('thumb')
image_blob_info = image_upload_files[0]
thumb_blob_info = thumb_upload_files[0]
Run Code Online (Sandbox Code Playgroud)
我看到一些奇怪的行为.这两个文件都进入了BlobStore,但是我无法弄清楚如何获取密钥以便我可以将它们存储在另一个实体上.上面的代码设法获取image_blob_info的密钥,但不是thumb_blob_info.我不明白如何使用get_uploads.我想通过表单传递多个文件,然后按名称获取它们,以便我可以将它们存储在另一个实体上的相应BlobReferenceProperties中.
python forms google-app-engine blobstore google-cloud-datastore
如果blobstore blob,Google App Engine文件API现在支持编程创建.
我试图通过http获取图像并将其存储到blobstore来尝试这个:
file_name = files.blobstore.create(mime_type='image/jpeg')
image = urllib2.urlopen(url)
with files.open(file_name, 'a') as f:
f.write(image) # LINE 142
files.finalize(file_name)
blob_key = files.blobstore.get_blob_key(file_name)
Run Code Online (Sandbox Code Playgroud)
此代码抛出错误:
File "/Users/willmerydith/repos/spam/admin.py", line 142, in post
f.write(image)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/files/file.py", line 364, in write
self._make_rpc_call_with_retry('Append', request, response)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/files/file.py", line 472, in _make_rpc_call_with_retry
_make_call(method, request, response)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/files/file.py", line 229, in _make_call
rpc.check_success()
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/apiproxy_stub_map.py", line 558, in check_success
self.__rpc.CheckSuccess()
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/apiproxy_rpc.py", line 156, in _WaitImpl
self.request, self.response)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/apiproxy_stub.py", line 80, in MakeSyncCall
if request.ByteSize() …Run Code Online (Sandbox Code Playgroud) 我已经完成了Octopress设置和部署指令,我在Github上运行了Octopress:http://wmerydith.github.com
我的repo设置为Master的默认分支.
我现在想把更改推送到配置文件,比如更改url:,title:和subtitle:.我做了这些更改,提交了它们,然后进行了rake部署,但更改没有显示出来.
我不清楚的是推动配置更改,内容更改以及在某些时候推出Octopress博客的新更新的过程中的差异.
例如,我是否会使用rake deploy来推送配置和内容更改?
我是否需要再次运行rake generate或rake deploy?Octopress更新时如何推送源更改?
我正在尝试将json结果存储在GAE数据存储区中,以便我以后可以读取它.我将它转储到String,然后存储它,然后读取它并将其加载回dict.但是在装载之后我再也不能把它看成dict了.
result = freebase.mqlready(query)
Run Code Online (Sandbox Code Playgroud)
打印结果:
[{u'mid': u'/m/095hd',
u'name': u'Settlers of Catan',
u'type': u'/games/game'},
{u'mid': u'/m/025sm93',
u'name': u'The Game of Life',
u'type': u'/games/game'}]
Run Code Online (Sandbox Code Playgroud)
for r in result:
name = r.name # works, I can get the name and other values.
json_dump = simplejson.dumps(result)
text = db.Text(json_dump)
fbresult = model.FB(text=text)
fbresult.put()
####
stored_text = fbresult.text
json = simplejson.loads(stored_text)
Run Code Online (Sandbox Code Playgroud)
打印json:
[{u'mid': u'/m/095hd',
u'name': u'Settlers of Catan',
u'type': u'/games/game'},
{u'mid': u'/m/025sm93',
u'name': u'The Game of Life',
u'type': u'/games/game'}]
Run Code Online (Sandbox Code Playgroud)
for j in json: …Run Code Online (Sandbox Code Playgroud) 使用Facebook Graph API我想获取位置数据.
{
"name": "Joe Smith",
"link": "http://www.facebook.com/joey",
"location": {
"id": "105590706140862",
"name": "Fairfield, Iowa"
}
}
Run Code Online (Sandbox Code Playgroud)
我可以拿这个对象做一些事情,比如object["name"]得到乔史密斯这个名字.但我如何得到"爱荷华州费尔菲尔德"的名字?
我正在使用JQuery来发布表单.我无法从此字段中获取正确的值:
<input type="checkbox" name="facebook" value="true" checked="checked" id="facebook"/>
Run Code Online (Sandbox Code Playgroud)
我的JQuery:
var facebook = $("input#facebook").val();
Run Code Online (Sandbox Code Playgroud)
我现在意识到,无论被检查与否,我所获得的价值总是"真实".那么我如何得到它是否被检查?
Python习语和语法的新手.我有一个数据存储StringListProperty,用于保存用户密钥.对于大多数实体,此属性将具有0-10个键,有时甚至更多.我需要检查属性是否有密钥,最常见的是没有匹配.
if entity.string_list.index(user_key) is not None:
# ....
Run Code Online (Sandbox Code Playgroud)
当没有匹配的密钥时,这会抛出错误.我可以捕获异常,但我怀疑我没有正确理解如何检查列表中的匹配.
python ×7
blobstore ×2
css ×2
forms ×2
html ×2
jquery ×2
json ×2
dictionary ×1
django ×1
exception ×1
file-upload ×1
github-pages ×1
input ×1
javascript ×1
list ×1
octopress ×1
ruby ×1
simplejson ×1