From 82be7b102098e1ed788eb40318b48d238e4f70f5 Mon Sep 17 00:00:00 2001 From: Nick Guenther Date: Wed, 4 Jun 2008 05:24:00 -0400 Subject: [PATCH 1/3] abstracting BookPage -> BookPageBase --- ceo/urwid/library.py | 46 +++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/ceo/urwid/library.py b/ceo/urwid/library.py index 0ecbe7c..3ccc609 100644 --- a/ceo/urwid/library.py +++ b/ceo/urwid/library.py @@ -213,30 +213,25 @@ def do_delete(book): if Confirm("Do you wish to delete %r?" % book): lib.delete(book) -class BookPage(urwid.WidgetWrap): - def __init__(self, book): - self._book = book +class BookPageBase(urwid.WidgetWrap): + def __init__(self): self.author = SingleEdit("Author: ") self.title = SingleEdit("Title: ") self.year = SingleIntEdit("Year: ") self.ISBN = urwid.Text("ISBN: ") self.description = urwid.Edit("Description: ", multiline=True) - self.checkout_label = urwid.Text("") - - save = urwid.Button("Save", self.save) - self.checkout_button = urwid.Button("", self.checkout) - back = urwid.Button("Back", raise_back) - remove = urwid.Button("Delete", self.delete) - - buttons = urwid.GridFlow([back, self.checkout_button, save, remove], 13, 2, 1, 'center') - display = urwid.Pile([self.author, self.title, self.year, self.ISBN, - self.description, - urwid.Divider(), buttons]) + + buttons = urwid.GridFlow(self._init_buttons(), 13, 2, 1, 'center') + display = urwid.Pile([self.author, self.title, self.year, self.ISBN, self.description,] + + self._init_widgets() + + [urwid.Divider(), buttons]) urwid.WidgetWrap.__init__(self, display) - self.refresh() - #all these *senders are to allow these to be used as event handlers or just on their own + def _init_widgets(self): + return [] + def _init_buttons(self): + return [] def refresh(self, *sender): """update the widgets from the data model""" self.author.set_edit_text(self._book.author) @@ -244,6 +239,25 @@ class BookPage(urwid.WidgetWrap): self.year.set_edit_text(str(self._book.year)) self.ISBN.set_text("ISBN: " + self._book.ISBN) self.description.set_edit_text(self._book.description) + + +class BookPage(BookPageBase): + def __init__(self, book): + self._book = book + BookPageBase.__init__(self) + def _init_widgets(self): + self.checkout_label = urwid.Text("") + return [self.checkout_label] + def _init_buttons(self): + save = urwid.Button("Save", self.save) + self.checkout_button = urwid.Button("", self.checkout) + back = urwid.Button("Back", raise_back) + remove = urwid.Button("Delete", self.delete) + return [back, self.checkout_button, save, remove] + + #all these *senders are to allow these to be used as event handlers or just on their own + def refresh(self, *sender): + BookPageBase.refresh(self, *sender) if self._book.signout is None: self.checkout_label.set_text("Checked In") self.checkout_button.set_label("Check Out") From 2890a04f71917100eaeaabbe1a23751750802f4c Mon Sep 17 00:00:00 2001 From: Nick Guenther Date: Thu, 5 Jun 2008 09:03:45 -0400 Subject: [PATCH 2/3] Made configuring slightly saner (it's now called directly from main, instead of surprisingly via connect()) --- ceo/main.py | 9 +++++++-- ceo/members.py | 1 - 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ceo/main.py b/ceo/main.py index 57d4e2a..821915e 100644 --- a/ceo/main.py +++ b/ceo/main.py @@ -6,10 +6,15 @@ from ceo import ldapi, members, library def start(): try: + print "Reading config file...", + #XXX this should really all be done through one big config file + members.configure() + library.configure() + print "read." + print "Connecting to LDAP...", - library.configure() members.connect(AuthCallback()) - print "connected" + print "connected." if len(sys.argv) == 1: ceo.urwid.main.start() diff --git a/ceo/members.py b/ceo/members.py index ac81f14..0bf20c2 100644 --- a/ceo/members.py +++ b/ceo/members.py @@ -87,7 +87,6 @@ ld = None def connect(auth_callback): """Connect to LDAP.""" - configure() global ld password = None From c7f9893fd4636c3342d1ad845728f67bc36e2b57 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Fri, 6 Jun 2008 23:32:47 -0400 Subject: [PATCH 3/3] Set $MAINTAINER to Systems Committee --- debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/control b/debian/control index 390767a..3661733 100644 --- a/debian/control +++ b/debian/control @@ -1,7 +1,7 @@ Source: ceo Section: admin Priority: optional -Maintainer: Michael Spang +Maintainer: Systems Committee Build-Depends: debhelper (>= 5.0.0), python-dev (>= 2.4), python-support (>= 0.3), libkrb5-dev, libldap2-dev, libsasl2-dev Standards-Version: 3.7.2