This looks like a database driven application.<br>When you send a package you must save the event on a database.<br>When a HomeWork is submited it must be entered in the database.<br>When you need to see what&#39;s the situation of any one student or all students you just query teh database.<br>
so you would be better off designing a database (do you like mysql ?) &amp; a python front end to it (web ?).<br>this database would be something like : students_table, courses_table, teachers_table, homework_table<br>homework table would be like : idx, student_id, homework_id, statut where statut is sent, finished, submited ... <br>
<br>the front end python program would be composed of a class&nbsp; to load data into database, and another to query it.<br><br>import MySQLdb<br><br>class NewEvent(object):<br><br>&nbsp;&nbsp;&nbsp; ___init__(self, s = &#39;dbserv&#39;, u = &#39;username&#39;, p = &#39;password&#39;, dbn = &#39;database_name&#39; ):<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.s = s<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.u = u<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.p = p <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.dbn = dbn<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.con = MySQLdb.connect(host = self.s,&nbsp; user&nbsp; =&nbsp; self.u ,&nbsp; passwd = self.p, db = self.dbn)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.cur = self.con.cursor()<br>
<br><br>&nbsp; def NewStudent(self, Name, Age, Sex, Address):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmd_NewStud = &#39;insert into student_table (Name, Age, Sex, Address) values (%s, %d, %s, %s)&#39; % (Name, Age, Sex, Address)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.cur.execute(cmd_NewStud)<br>
<br><br>&nbsp;def NewHW(self, student_id, HW_id):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmd_NewHW = &#39;insert into homework_table (student_id, homework_id) values (%s, %s)&#39; % (student_id, HW_id)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.cur.execute(cmd_NewHW)<br><br><br>
I hope this helps<br><br><br><br>About the code below : <br><br><br><div class="gmail_quote">2008/7/6  &lt;<a href="mailto:tpc247@gmail.com">tpc247@gmail.com</a>&gt;:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Dear fellow Python enthusiasts:<br><br>I want to run an idea by you to see if I understand modeling objects adequately, after reading Alan Gauld&#39;s excellent tutorial and two brief articles about interfaces in Python, here:<br>

<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://www.freenetpages.co.uk/hp/alan.gauld/tutclass.htm" target="_blank">http://www.freenetpages.co.uk/hp/alan.gauld/tutclass.htm</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://dirtsimple.org/2004/12/python-interfaces-are-not-java.html" target="_blank">http://dirtsimple.org/2004/12/python-interfaces-are-not-java.html</a><br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://nedbatchelder.com/text/pythonic-interfaces.html" target="_blank">http://nedbatchelder.com/text/pythonic-interfaces.html</a><br><br>I am attempting to model the following:<br>a correspondence school has asked me to help them solve a problem.&nbsp; When the school sends a student by mail a package containing several courses, each course having several pieces of gradable homework, when a specific threshold of homework completed and submitted by the student is met or exceeded, another package is sent to the student by mail.&nbsp; Now, this aforementioned threshold, i.e., an integer indicating percentage, can vary, and is not just for the totality of homework in the package, but also for certain courses with many pieces of homework.&nbsp; For example, say the school sends student Joe a package (package_1) containing courses A, B and C_sub1.&nbsp; A, B &amp; C_sub1 have 10 pieces of gradable homework, and the school wants that we can set a threshold for the totality of homework for package1, as well as a threshold for C_sub1 alone.&nbsp; When the thresholds are met or exceeded, independently, then we send package_2 and C_sub2, respectively.&nbsp; I envisioned a nascent object model and noted the following observations:<br>

<br>- a Watchable interface that, when implemented, signifies that the implementing object has a threshold and associated package.<br>- a Package class, that can be seen as a container for courses and/or one part of a course<br>

- a Course class, that can be seen as a container for gradable homework<br>- a Homework class, that has a flag to indicated whether it has been received by the school<br>- most Packages are Watchable (except the last Package object), and only one or two Courses in a Package need to be Watchable<br>

<br>Two questions: <br>1) Should I create a first-class Watchable interface object, and then have my Package and Course objects implement it if they need to ?&nbsp; If I start with a Watchable interface, do I handle the name-space conflict, i.e., Package(object) vs Package(Watchable), by defining a Package class, and a W_Package class that implements Watchable, and likewise for Course ?<br>

2) am I even thinking the right way about attacking this problem ?&nbsp; I am curious what your experience in writing easy to maintain software might tell you about my nascent object model. &nbsp;<br><br>class Watchable(object):<br>

&nbsp;&nbsp;&nbsp; def set_threshold(self, an_int):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; raise NotImplemented<br>&nbsp;&nbsp;&nbsp; def get_threshold(self):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; raise NotImplemented<br>&nbsp;&nbsp;&nbsp; def set_associated_load(self, a_load):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; raise NotImplemented<br>&nbsp;&nbsp;&nbsp; def get_associated_load(self):<br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; raise NotImplemented<br><br>class Package(object):<br>&nbsp;&nbsp;&nbsp; def __init__(self, courses):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.set_courses(courses)<br>&nbsp;&nbsp;&nbsp; def set_courses(self, courses):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.courses = courses<br>&nbsp;&nbsp;&nbsp; def get_courses(self):<br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return self.courses<br><br>class Course(Watchable):<br>&nbsp;&nbsp;&nbsp; def __init__(self, name, homework):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://self.name" target="_blank">self.name</a> = name<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.homework = homework<br>&nbsp;&nbsp;&nbsp; def get_name(self):<br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return <a href="http://self.name" target="_blank">self.name</a><br>&nbsp;&nbsp;&nbsp; def get_homework(self):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return self.homework<br><br>class Homework(object):<br>&nbsp;&nbsp;&nbsp; def __init__(self, name):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://self.name" target="_blank">self.name</a> = name<br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.academically_received = False<br>&nbsp;&nbsp;&nbsp; def set_academically_received(self):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.academically_received = True<br>
<br>_______________________________________________<br>
Tutor maillist &nbsp;- &nbsp;<a href="mailto:Tutor@python.org">Tutor@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br>
<br></blockquote></div><br>