我正在尝试使用commonjs-utils中的node.js + json-schema.js来验证我的JSON API.只需单个验证就很容易,但无法找到正确的方法来管理多个模式文件以实现相互引用.
假设我有两个模型和两个API.
// book
{
"type": "object",
"properties": {
"title": { "type": "string" },
"author": { "type": "string" }
}
}
// author
{
"type": "object",
"properties": {
"first_name": { "type": "string" },
"last_name": { "type": "string" }
}
}
// authors API
{
"type": "array",
"items": { "$ref": "author" }
}
// books API: list of books written by same author
{
"type": "object",
"properties": {
"author": { "$ref": "author" }
"books": { "type": "array", "items": …Run Code Online (Sandbox Code Playgroud) 我将使用其他jQuery工具提示插件而不是Google Maps API的默认信息窗口.所以我需要得到标记的DIV及其像素位置.
但无法得到它,因为某些标记没有id或class.只有我可以从标记对象和未记录的pixelBounds对象访问地图画布div.
==追加:
我也试过下面的代码,但滚动地图时它没有改变.
var marker = new google.maps.Marker({...});
google.maps.event.addListener(marker, 'click', function() {
var px = this.getMap().getProjection().fromLatLngToPoint(this.getPosition());
console.log("(" + px.x + "," + px.y + ")");
});
Run Code Online (Sandbox Code Playgroud) 今天我正在尝试使用jquery-tmpl {{if}}和{{else}}语句.
<script id="mission-dialog" type="text/x-jquery-tmpl">
<h3>${name}</h3>
<p>${description}</p>
<ul>
{{each(i,cond) conditions.data}}
<li>
<img src="${cond.image}"/>
<h4>${cond.name}</h4>
<p class="status">${cond.status.value}/${cond.status.max}</p>
</li>
{{/each}}
</ul>
</script>
Run Code Online (Sandbox Code Playgroud)
但正如您所知,{{}}也为django模板保留.所以django会发出无法解析它的TemplateSyntaxError.
我怎么解决这个问题?
更新:
我从这里找到了一个有效的<%raw>自定义标签(GPL)实现.
http://www.holovaty.com/writing/django-two-phased-rendering/
要将Google电子表格的单个工作表导出为CSV,需要传递整数工作表索引(GID).
https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key=%s&gid=%d&exportFormat=csv
但是,那些信息在哪里?使用gdata.spreadsheets.client,我可以找到工作表的一些字符串id,如"oc6,ocv,odf".
client = gdata.spreadsheets.client.SpreadsheetsClient()
feed = client.GetWorksheets(spreadsheet, auth_token=auth_token)
Run Code Online (Sandbox Code Playgroud)
它返回原子XML下面.(一部分)
<entry gd:etag=""URJFCB1NQSt7ImBoXhU."">
<id>https://spreadsheets.google.com/feeds/worksheets/0AvhN_YU3r5e9dGpTWGx3UVU3MTczaXJuNEFKQjMwN2c/ocw</id>
<updated>2012-06-21T08:19:46.587Z</updated>
<app:edited xmlns:app="http://www.w3.org/2007/app">2012-06-21T08:19:46.587Z</app:edited>
<category scheme="http://schemas.google.com/spreadsheets/2006" term="http://schemas.google.com/spreadsheets/2006#worksheet"/>
<title>AchievementType</title>
<content type="application/atom+xml;type=feed" src="https://spreadsheets.google.com/feeds/list/0AvhN_YU3r5e9dGpTWGx3UVU3MTczaXJuNEFKQjMwN2c/ocw/private/full"/>
<link rel="http://schemas.google.com/spreadsheets/2006#cellsfeed" type="application/atom+xml" href="https://spreadsheets.google.com/feeds/cells/0AvhN_YU3r5e9dGpTWGx3UVU3MTczaXJuNEFKQjMwN2c/ocw/private/full"/>
<link rel="http://schemas.google.com/visualization/2008#visualizationApi" type="application/atom+xml" href="https://spreadsheets.google.com/tq?key=0AvhN_YU3r5e9dGpTWGx3UVU3MTczaXJuNEFKQjMwN2c&sheet=ocw"/>
<link rel="self" type="application/atom+xml" href="https://spreadsheets.google.com/feeds/worksheets/0AvhN_YU3r5e9dGpTWGx3UVU3MTczaXJuNEFKQjMwN2c/private/full/ocw"/>
<link rel="edit" type="application/atom+xml" href="https://spreadsheets.google.com/feeds/worksheets/0AvhN_YU3r5e9dGpTWGx3UVU3MTczaXJuNEFKQjMwN2c/private/full/ocw"/>
<gs:rowCount>280</gs:rowCount>
<gs:colCount>28</gs:colCount>
</entry>
Run Code Online (Sandbox Code Playgroud)
我也尝试使用sheet参数但是因"Invalid Sheet"错误而失败.
https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key=%s&sheet=XXX&exportFormat=csv
我想应该有一些神奇的功能,但找不到它.我怎样才能将它们转换为整数id?或者我可以导出带有字符串ID的工作表吗?
编辑:我刚刚用python制作了转换表.很脏但工作:-(
GID_TABLE = {
'od6': 0,
'od7': 1,
'od4': 2,
'od5': 3,
'oda': 4,
'odb': 5,
'od8': 6,
'od9': 7,
'ocy': 8,
'ocz': 9,
'ocw': 10,
'ocx': 11,
'od2': 12,
'od3': 13,
'od0': …Run Code Online (Sandbox Code Playgroud) gdata-api google-sheets gdata-python-client google-spreadsheet-api
从寻找想法/替代方案到提供与GAE数据存储区查询匹配的项目的页面/项目计数/导航,我可以通过REVERSING ORDER找到如何使用单个光标向后页面导航的提示.
class CursorTests(test_utils.NDBTest):
def testFirst(self):
class Bar(model.Model):
value = model.IntegerProperty()
self.entities = []
for i in range(10):
e = Bar(value=i)
e.put()
self.entities.append(e)
q = Bar.query()
bars, next_cursor, more = q.order(Bar.key).fetch_page(3)
barz, another_cursor, more2 = q.order(-Bar.key).fetch_page(3, start_cursor=next_cursor)
self.assertEqual(len(bars), len(barz))
Run Code Online (Sandbox Code Playgroud)
不幸的是,它失败了这个错误.
回溯(最近一次调用最后一次):文件"/Users/reiot/Documents/Works/appengine-ndb-experiment/ndb/query_test.py",第32行,在testFirst中self.assertEqual(len(bars),len(baz) )AssertionError:3!= 2
是的,反向查询中缺少边界中的项目.
bars = [Bar(key=Key('Bar', 1), value=0), Bar(key=Key('Bar', 2), value=1), Bar(key=Key('Bar', 3), value=2)]
bars = [Bar(key=Key('Bar', 2), value=1), Bar(key=Key('Bar', 1), value=0)]
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?