tools (common/data_objects): BlogItem has now a uri property to generate its own XMPP URI
This commit is contained in:
parent
d4cfd510c8
commit
7b833e62a6
1 changed files with 15 additions and 2 deletions
|
|
@ -25,11 +25,14 @@ try:
|
|||
except ImportError:
|
||||
safe = unicode
|
||||
|
||||
from sat.tools.common import uri as xmpp_uri
|
||||
|
||||
|
||||
class BlogItem(object):
|
||||
|
||||
def __init__(self, mb_data):
|
||||
def __init__(self, mb_data, parent):
|
||||
self.mb_data = mb_data
|
||||
self.parent = parent
|
||||
self._tags = None
|
||||
self._groups = None
|
||||
self._comments = None
|
||||
|
|
@ -43,6 +46,16 @@ class BlogItem(object):
|
|||
def atom_id(self):
|
||||
return self.mb_data.get(u'atom_id')
|
||||
|
||||
@property
|
||||
def uri(self):
|
||||
node = self.parent.node
|
||||
service = self.parent.service
|
||||
return xmpp_uri.buildXMPPUri(u'pubsub',
|
||||
subtype=u'microblog',
|
||||
path=service,
|
||||
node=node,
|
||||
item=self.id)
|
||||
|
||||
@property
|
||||
def published(self):
|
||||
return self.mb_data.get(u'published')
|
||||
|
|
@ -133,7 +146,7 @@ class BlogItem(object):
|
|||
class BlogItems(object):
|
||||
|
||||
def __init__(self, mb_data):
|
||||
self.items = [BlogItem(i) for i in mb_data[0]]
|
||||
self.items = [BlogItem(i, self) for i in mb_data[0]]
|
||||
self.metadata = mb_data[1]
|
||||
|
||||
@property
|
||||
|
|
|
|||
Loading…
Reference in a new issue