Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 74 lines (59 sloc) 1.84 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
#!/usr/bin/env python
"""PostgreSQL Planet Aggregator

This file contains helper classes used to store the data when
"communicating" with the templates to generate HTML output.

Copyright (C) 2008 PostgreSQL Global Development Group
"""

import datetime
import urllib

# Yes, a global function (!)
# Hmm. We only quote the ampersand here, since it's a HTML escape that
# shows up in URLs quote often.
def quoteurl(str):
return str.replace('&','&')

class PlanetPost:
def __init__(self, guid,link,dat,title,author,blogurl,txt,teamname,teamurl):
self.guid = guid
self.link = link
self.dat = dat
self.posttitle = title
self.author = author
self._blogurl = blogurl
self.txt = txt
self.teamname = teamname
self._teamurl = teamurl


def _get_blogurl(self):
return quoteurl(self._blogurl)
blogurl = property(_get_blogurl)

def _get_teamurl(self):
return quoteurl(self._teamurl)
teamurl = property(_get_teamurl)

def _get_datetime(self):
return self.dat.strftime("%Y-%m-%d at %H:%M:%S")
datetime = property(_get_datetime)

def _get_contents(self):
if self.txt.endswith("[...]"):
self.txt = '%s<p>[<a href="%s">continue reading</a>]</p>' % (self.txt[:len(self.txt)-5], self.link)
return self.txt
contents = property(_get_contents)

def _get_title(self):
return self.posttitle
title = property(_get_title)

class PlanetFeed:
def __init__(self,row):
self.name = row[0]
self._blogurl = row[1]
self._feedurl = row[2]
self.numposts = row[3]
self.teamname = row[4]
self._teamurl = row[5]
self.teamcount = row[6]

def _get_blogurl(self):
return quoteurl(self._blogurl)
blogurl = property(_get_blogurl)

def _get_feedurl(self):
return quoteurl(self._feedurl)
feedurl = property(_get_feedurl)

def _get_teamurl(self):
return quoteurl(self._teamurl)
teamurl = property(_get_teamurl)
Something went wrong with that request. Please try again.