Appengine 批量下载器未下载列表属性
这与我之前的问题相关,但包含新信息。
我正在尝试将bulkdownloader 配置为从我的Java appengine 应用程序下载数据,将拥有的对象列表转换为每个父对象内的嵌套XML 路径。我一直在使用导出转换transform.child_node_from_list
。然而,列表属性实际上从未被下载并传递给该转换!
这看起来与您在 appengine 数据存储区查看器中查看实体时获得的效果类似 - 父实体根本不显示列表属性。您必须通过代码访问它。
那么,我的问题是:如何使用批量下载器访问此列表属性?如果我使用 --kind=ParentEntity
下载,您认为这会阻止它下载 ChildEntity
的任何内容吗? (有没有办法指定“所有种类”或其他什么?)
在 python 下载配置中,模型实际上直接引用到配置文件中。我是否需要模拟一个模仿 JDO 模型的 Python 模型并使用该引用?
作为参考,我的每个文件的缩写版本如下:
downloadconfig.yaml:
transformers:
- kind: ParentEntity
connector: simplexml
connector_options:
xpath_to_nodes: /Parents/Parent
style: element_centric
property_map:
- property: __key__
external_name: key
export_transform: transform.key_id_or_name_as_string
- property: name
external_name: name
# Type: String Stats: 30 properties of this type in this kind.
- property: children
external_name: Children
import_transform:
transform.list_from_child_node('Children/Child')
export_transform:
transform.empty_if_none(transform.child_node_from_list('Child'))
ParentEntity.java:
package experiment.dataexport;
import java.util.List;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import com.google.appengine.api.datastore.Key;
@PersistenceCapable
public class ParentEntity
{
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
public Key key;
@Persistent
public String name;
@Persistent(defaultFetchGroup = "true")
public List<ChildEntity> children;
}
示例 XML 输出:(
<Parents>
<Parent>
<name>Parent 5613</name>
<key>72001</key>
<Children></Children>
</Parent>
<Parent>
<name>Parent 1237</name>
<key>73001</key>
<Children></Children>
</Parent>
</Parents>
每个
节点,但下载器正在检索
元素)None
而不是正确的子节点列表)
This is related to a previous question of mine, but with new information.
I'm trying to configure the bulkdownloader to download data from my Java appengine app in such a way that a list of owned objects is transformed into a nested XML path inside each parent object. I have been using the export transform transform.child_node_from_list
. However, the list property is never actually being downloaded and passed to that transform!
This seems similar to the effect you get when looking at an entity in the appengine datastore viewer - the parent entity just doesn't show the list property at all. You have to access it through code.
My question, then, is this: how can I access this list property with the bulk downloader? If I am downloading with --kind=ParentEntity
, do you think that is stopping it from downloading anything that is a ChildEntity
? (Is there a way to specify "all kinds" or anything?)
In a python download config, the model is actually directly referenced in to the config file. Do I need to mock up a python model that mimics my JDO model and use that reference?
For reference, abbreviated versions of each of my files follow:
downloadconfig.yaml:
transformers:
- kind: ParentEntity
connector: simplexml
connector_options:
xpath_to_nodes: /Parents/Parent
style: element_centric
property_map:
- property: __key__
external_name: key
export_transform: transform.key_id_or_name_as_string
- property: name
external_name: name
# Type: String Stats: 30 properties of this type in this kind.
- property: children
external_name: Children
import_transform:
transform.list_from_child_node('Children/Child')
export_transform:
transform.empty_if_none(transform.child_node_from_list('Child'))
ParentEntity.java:
package experiment.dataexport;
import java.util.List;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import com.google.appengine.api.datastore.Key;
@PersistenceCapable
public class ParentEntity
{
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
public Key key;
@Persistent
public String name;
@Persistent(defaultFetchGroup = "true")
public List<ChildEntity> children;
}
Sample XML output:
<Parents>
<Parent>
<name>Parent 5613</name>
<key>72001</key>
<Children></Children>
</Parent>
<Parent>
<name>Parent 1237</name>
<key>73001</key>
<Children></Children>
</Parent>
</Parents>
(There should be several <Child>
elements in each <Children>
node, but the downloader is retrieving None
instead of the proper list of children)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论