| | 274 | elif i.xml_ns == XMPP_CLIENT_NS and i.xml_name == 'error': |
|---|
| | 275 | node.error = Error.from_element(i) |
|---|
| | 276 | |
|---|
| | 277 | return node |
|---|
| | 278 | |
|---|
| | 279 | @staticmethod |
|---|
| | 280 | def to_request_item(e): |
|---|
| | 281 | iq = Entity.to_element(e) |
|---|
| | 282 | pubsub = E(u'pubsub', namespace=XMPP_PUBSUB_NS, parent=iq) |
|---|
| | 283 | attrs = {u'node': e.node_name} |
|---|
| | 284 | items = E(u'items', attributes=attrs, namespace=XMPP_PUBSUB_NS, parent=pubsub) |
|---|
| | 285 | attrs = {u'id': e.item.id} |
|---|
| | 286 | item = E(u'item', attributes=attrs, namespace=XMPP_PUBSUB_NS, parent=items) |
|---|
| | 287 | |
|---|
| | 288 | return iq |
|---|
| | 289 | |
|---|
| | 290 | @staticmethod |
|---|
| | 291 | def from_request_item(e): |
|---|
| | 292 | node = Node(JID.parse(e.get_attribute_value('from')), |
|---|
| | 293 | JID.parse(e.get_attribute_value('to')), |
|---|
| | 294 | type=e.get_attribute_value('type'), |
|---|
| | 295 | stanza_id=e.get_attribute_value('id')) |
|---|
| | 296 | |
|---|
| | 297 | for i in e.xml_children: |
|---|
| | 298 | if i.xml_ns in [XMPP_PUBSUB_NS]: |
|---|
| | 299 | for p in i.xml_children: |
|---|
| | 300 | if p.xml_ns in [XMPP_PUBSUB_NS]: |
|---|
| | 301 | if p.xml_name == 'items': |
|---|
| | 302 | node.node_name = p.get_attribute_value('node') |
|---|
| | 303 | for q in p.xml_children: |
|---|
| | 304 | if q.xml_name == 'item': |
|---|
| | 305 | payload = None |
|---|
| | 306 | if q.xml_children: payload = q.xml_children |
|---|
| | 307 | node.item = Item(q.get_attribute_value('id'), |
|---|
| | 308 | payload=payload) |
|---|