Commit fffcf9e5 by murtaugh

base new Page Web titles on item titles

parent a65a1cea
......@@ -237,37 +237,38 @@ class SiteWeb (object):
def get_all (cls, wiki):
result = wiki.get("cargoquery",
tables="Site_web",
fields="_pageName=pagename,Feed_url=feed_url,Site_url=site_url,Last_updated=last_updated",
fields="_pageName=pagename,Site_url=site_url,Feed_url=feed_url,Last_updated=last_updated",
where="feed_url<>''",
order_by="pagename")
# print (json.dumps(result, indent=2))
return [cls(wiki=wiki, pagename=r['title']['pagename'], feed_url=r['title']['feed_url'], site_url=r['title']['site_url'], last_updated=cls.parse_dt(r['title']['last_updated'])) for r in result['cargoquery']]
return [cls(wiki=wiki, pagename=r['title']['pagename'], site_url=r['title']['site_url'], feed_url=r['title']['feed_url'], last_updated=cls.parse_dt(r['title']['last_updated'])) for r in result['cargoquery']]
def __init__ (self, wiki, pagename, feed_url=None, site_url=None, last_updated=None):
def __init__ (self, wiki, pagename, site_url=None, feed_url=None, last_updated=None):
self.wiki = wiki
self.pagename = pagename
if feed_url:
self.feed_url = feed_url
self.site_url = site_url
self.feed_url = feed_url
self.last_updated = last_updated
else:
self.feed_url = None
self.site_url = None
self.feed_url = None
self.last_updated = None
self.init()
def init (self):
""" set site_url, feed_url and last_updated from wiki data, if present """
result = self.wiki.get("cargoquery",
tables="Site_web",
fields="_pageID=pageID,_pageTitle=pageTitle,_pageName=pageName,_pageNamespace=pageNamespace,Feed_url,Site_url,Last_updated",
fields="_pageID=pageID,_pageTitle=pageTitle,_pageName=pageName,_pageNamespace=pageNamespace,Site_url,Feed_url,Last_updated",
where="_pageName=\"{0}\"".format(self.pagename),
limit=1)
# NB: pageName is with the namespace (when not Main), pageTitle is without
result = result['cargoquery']
if len(result) > 0:
result = result[0]['title']
self.feed_url = result['Feed url']
self.site_url = result['Site url']
self.feed_url = result['Feed url']
if result['Last updated']:
self.last_updated = self.parse_dt(result['Last updated'])
......@@ -277,8 +278,8 @@ class SiteWeb (object):
|Feed_url={feed_url}
|Last_updated={updated}
}}}}""".format(
feed_url = self.feed_url,
site_url=self.site_url,
feed_url = self.feed_url,
updated=self.last_updated.strftime(DATETIME_STRF))
def save (self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment