#!/usr/bin/env python2
import MySQLdb
import time
import auth

def entit(costam):
        nowystring = costam.replace("&","&amp;")
        return nowystring

x=auth.PyRssConf()
dbhost=x.dbhost()
dbuser=x.dbuser()
database=x.database()
dbpassword=x.dbpassword()
db=MySQLdb.connect(host=dbhost,user=dbuser,passwd=dbpassword,db=database)

c=db.cursor()
c.execute("select * from addressess order by id desc ;")
lista=c.fetchall()
plik = """
<rss version="2.0">

	<channel>
	<title>Available feeds at JabberPL.org</title>
	<link>http://jabberpl.org/pyrss/rss.xml</link>
	<description>Recent PyRSS channels</description>"""
	#<pubDate>"""+str(time.asctime())+"""</pubDate>
for i in lista:
	plik += """
	<item>
		<title>"""+entit(i[1])+"""@rss.jabberpl.org</title>
		<link>"""+entit(i[2])+"""</link>
		<description>
			To subscribe this rss (called """+entit(i[1])+"""), just add """+entit(i[1])+"""@rss.jabberpl.org contact to your roster, or use disco browser in your jabber client.
		</description>
	</item>"""

plik+="""
	</channel>
</rss>"""
	
print plik

