Commits

Jason R. Coombs  committed 9040dab

Removed 'botconf' from cherrypy config. It's already available as a nice package attribute.
Use the canonical Karma and Logger stores for database queries.
"

  • Participants
  • Parent commits 67b7d88
  • Tags 1103.1.3

Comments (0)

Files changed (1)

File pmxbot/web/viewer.py

 random.shuffle(colors)
 
 def get_context():
-	c = cherrypy.request.app.config['botconf']['config']
+	c = pmxbot.web.config
 	d = dict(
 		request = cherrypy.request,
 		name = c.bot_nickname,
 		number = th_it(day),
 	)
 
-def log_db():
-	return pmxbot.logging.Logger.from_URI(
-		cherrypy.request.app.config['botconf']['config'].database)
-
 class ChannelPage(object):
 	month_ordinal = dict(
 		(calendar.month_name[m_ord], m_ord)
 	def default(self, channel):
 		page = jenv.get_template('channel.html')
 
-		db = log_db()
+		db = pmxbot.logging.Logger.store
 		context = get_context()
 		contents = db.get_channel_days(channel)
 		months = {}
 	@cherrypy.expose
 	def default(self, channel, day):
 		page = jenv.get_template('day.html')
-		db = log_db()
+		db = pmxbot.logging.Logger.store
 		context = get_context()
 		day_logs = db.get_day_logs(channel, day)
 		data = [(t, n, make_anchor((t, n)), cgi.escape(m))
 	def default(self, term=""):
 		page = jenv.get_template('karma.html')
 		context = get_context()
-		karma = pmxbot.util.Karma.from_URI(
-			cherrypy.request.app.config['botconf']['config'].database
-		)
+		karma = pmxbot.karma.Karma.store
 		term = term.strip()
 		if term:
 			context['lookup'] = (
 	def default(self, term=''):
 		page = jenv.get_template('search.html')
 		context = get_context()
-		db = log_db()
+		db = pmxbot.logging.Logger.store
 		#db.text_factory = lambda x: unicode(x, "utf-8", "ignore")
 
 		# a hack to enable the database to create anchors when building search
 	@cherrypy.expose
 	def default(self):
 		page = jenv.get_template('index.html')
-		db = log_db()
+		db = pmxbot.logging.Logger.store
 		context = get_context()
 		chans = []
 		for chan in sorted(db.list_channels(), key = string.lower):
 			'tools.staticfile.filename': pkg_resources.resource_filename(
 				'pmxbot.web', 'templates/pmxbot.png'),
 		},
-		b'botconf': {'config': config},
 	}
 
 	cherrypy.quickstart(PmxbotPages(), config.web_base, config=app_conf)