def _interval_get(*args): result = [] for i in range(20): d = localtime(self._min + (((self._max-self._min)/20)*(i+1))) res = DateTime(d.year, d.month, d.day).ticks() if (not result) or result[-1]<>res: result.append(res) return result
def _save_to_db (self, session): """ Save a given session to the database. """ #conn = self.get_conn() #cursor = conn.cursor() cursor = self.context.get_cursor() # ORIGINAL: save a db-thrash by checking for update possibility # instead of the following, which always does an extra delete- # and-insert: # # don't allow multiple session IDs; this also removes it from # the uncommitted dictionary. del self[session.id] #if self.uncommitted.has_key(session.id): # del self.uncommitted[session.id] #if self.has_key(session.id): # cursor.execute(""" # UPDATE sessions # SET access_time = %s, messages = %s # WHERE session_id = %s # """, (str(localtime(session.get_access_time())), session.messages, # session.id)) #else: cursor.execute(""" INSERT INTO sessions (session_id, user_id, remote_addr, creation_time, access_time, messages, form_tokens) VALUES (%s, %s, %s, %s, %s, %s, %s) """, (session.id, session.user.id, session.get_remote_address(), str(localtime(session.get_creation_time())), str(localtime(session.get_access_time())), str(session.messages), str('~~'.join(session._form_tokens))))
x_range = (self._min,self._max), x_axis=axis.X(label="Date", format=self._conv[1]), y_axis=axis.Y(label="Tasks"), legend = legend.T(), size = (680,450)) for user in self._datas: chart_object.set_defaults(interval_bar_plot.T, direction="horizontal", data=self._datas[user]) f = fill_style.Plain() f.bgcolor = user_color[user] ar.add_plot(interval_bar_plot.T(fill_styles = [f, None], label=user, cluster=(0,1))) ar.draw(self._canvas) def close(self): self._canvas.close() if __name__ == '__main__': date_to_int = lambda x: int(x.ticks()) int_to_date = lambda x: '/a60{}'+localtime(x).strftime('%d %m %Y') gt = GanttCanvas('test.pdf', convertors=(date_to_int, int_to_date)) gt.add('nicoe', 'Graphe de gantt', [(DateTime(2005,6,12), DateTime(2005,6,13))]) gt.add('nicoe', 'Tarifs', [(DateTime(2005,6,19), DateTime(2005,6,21))]) gt.add('gaetan', 'Calcul des prix', [(DateTime(2005,6,12), DateTime(2005,6,13))]) gt.add('nico', 'Mise a jour du site', [(DateTime(2005,6,13), DateTime(2005,6,16))]) gt.add('tom', 'Coucou', [(DateTime(2005,6,11), DateTime(2005,6,12))]) gt.draw() gt.close() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: