# HG changeset patch # User Paul Boddie # Date 1445203477 -7200 # Node ID fc2d5f82623677d6183fb8f621b9dcbf74c0a91c # Parent ad1bb10e0e30468eda62dfae19c840aa095de1d6 Support links to the main resource in the link_to method. diff -r ad1bb10e0e30 -r fc2d5f826236 imipweb/resource.py --- a/imipweb/resource.py Sun Oct 18 19:33:04 2015 +0200 +++ b/imipweb/resource.py Sun Oct 18 23:24:37 2015 +0200 @@ -83,16 +83,20 @@ self.new_page(title="Redirect") self.page.p("Redirecting to: %s" % url) - def link_to(self, uid, recurrenceid=None, args=None): + def link_to(self, uid=None, recurrenceid=None, args=None): """ - Return a link to an object with the given 'uid' and 'recurrenceid'. + Return a link to a resource, being an object with any given 'uid' and + 'recurrenceid', or the main resource otherwise. + See get_identifiers for the decoding of such links. If 'args' is specified, the given dictionary is encoded and included. """ - path = [uid] + path = [] + if uid: + path.append(uid) if recurrenceid: path.append(recurrenceid) return "%s%s" % (self.env.new_url("/".join(path)), args and ("?%s" % urlencode(args)) or "")