def set_title(depot, doc, feed, update_ts):
"""This function attaches the necessary RSS/Atom feed elements needed
to provide title, author and contact information to the provided
xmini document object using the provided feed object and update
time.
"""
t = doc.createElement("title")
ti = xmini.Text()
ti.replaceWholeText(depot.cfg.get_property("pkg_bui", "feed_name"))
t.appendChild(ti)
feed.appendChild(t)
l = doc.createElement("link")
l.setAttribute("href", cherrypy.url())
l.setAttribute("rel", "self")
feed.appendChild(l)
# Atom requires each feed to have a permanent, universally unique
# identifier.
i = doc.createElement("id")
it = xmini.Text()
netloc, path = urlparse(cherrypy.url())[1:3]
netloc = netloc.split(":", 1)[0]
tag = "tag:{0},{1}:{2}".format(netloc, update_ts.strftime("%Y-%m-%d"),
path)
it.replaceWholeText(tag)
i.appendChild(it)
feed.appendChild(i)
# Indicate when the feed was last updated.
u = doc.createElement("updated")
ut = xmini.Text()
ut.replaceWholeText(dt_to_rfc3339_str(update_ts))
u.appendChild(ut)
feed.appendChild(u)
# Add our icon.
i = doc.createElement("icon")
it = xmini.Text()
it.replaceWholeText(depot.cfg.get_property("pkg_bui", "feed_icon"))
i.appendChild(it)
feed.appendChild(i)
# Add our logo.
l = doc.createElement("logo")
lt = xmini.Text()
lt.replaceWholeText(depot.cfg.get_property("pkg_bui", "feed_logo"))
l.appendChild(lt)
feed.appendChild(l)
评论列表
文章目录