71 |
71 |
72 |
72 |
73 class XMLItemView(EntityView): |
73 class XMLItemView(EntityView): |
74 __regid__ = 'xmlitem' |
74 __regid__ = 'xmlitem' |
75 |
75 |
76 def cell_call(self, row, col): |
76 def entity_call(self, entity): |
77 """ element as an item for an xml feed """ |
77 """element as an item for an xml feed""" |
78 entity = self.cw_rset.complete_entity(row, col) |
78 entity.complete() |
79 source = entity.cw_metainformation()['source']['uri'] |
79 source = entity.cw_metainformation()['source']['uri'] |
80 self.w(u'<%s eid="%s" cwuri="%s" cwsource="%s">\n' |
80 self.w(u'<%s eid="%s" cwuri="%s" cwsource="%s">\n' |
81 % (entity.__regid__, entity.eid, xml_escape(entity.cwuri), |
81 % (entity.__regid__, entity.eid, xml_escape(entity.cwuri), |
82 xml_escape(source))) |
82 xml_escape(source))) |
83 for rschema, attrschema in entity.e_schema.attribute_definitions(): |
83 for rschema, attrschema in entity.e_schema.attribute_definitions(): |
114 if not rtype in getrschema: |
114 if not rtype in getrschema: |
115 self.error('unexisting relation %r', relstr) |
115 self.error('unexisting relation %r', relstr) |
116 continue |
116 continue |
117 self.w(u' <%s role="%s">\n' % (rtype, role)) |
117 self.w(u' <%s role="%s">\n' % (rtype, role)) |
118 for related in entity.related(rtype, role, entities=True): |
118 for related in entity.related(rtype, role, entities=True): |
119 # XXX put unique attributes as xml attribute, they are much |
119 related.view('xmlrelateditem', w=self.w) |
120 # probably used to search existing entities in client data feed, |
|
121 # and putting it here may avoid an extra request to get those |
|
122 # attributes values |
|
123 self.w(u' <%s eid="%s" cwuri="%s"/>\n' |
|
124 % (related.e_schema, related.eid, |
|
125 xml_escape(related.cwuri))) |
|
126 self.w(u' </%s>\n' % rtype) |
120 self.w(u' </%s>\n' % rtype) |
127 self.w(u'</%s>\n' % (entity.e_schema)) |
121 self.w(u'</%s>\n' % (entity.e_schema)) |
|
122 |
|
123 |
|
124 class XMLRelatedItemView(EntityView): |
|
125 __regid__ = 'xmlrelateditem' |
|
126 |
|
127 def entity_call(self, entity): |
|
128 # XXX put unique attributes as xml attribute, they are much probably |
|
129 # used to search existing entities in client data feed, and putting it |
|
130 # here may avoid an extra request to get those attributes values |
|
131 self.w(u' <%s eid="%s" cwuri="%s"/>\n' |
|
132 % (entity.e_schema, entity.eid, xml_escape(entity.cwuri))) |
|
133 |
|
134 |
|
135 class XMLRelatedItemStateView(XMLRelatedItemView): |
|
136 __select__ = is_instance('State') |
|
137 |
|
138 def entity_call(self, entity): |
|
139 self.w(u' <%s eid="%s" cwuri="%s" name="%s"/>\n' |
|
140 % (entity.e_schema, entity.eid, xml_escape(entity.cwuri), |
|
141 xml_escape(entity.name))) |
128 |
142 |
129 |
143 |
130 class XMLRsetView(AnyRsetView): |
144 class XMLRsetView(AnyRsetView): |
131 """dumps raw rset as xml""" |
145 """dumps raw rset as xml""" |
132 __regid__ = 'rsetxml' |
146 __regid__ = 'rsetxml' |