IRC log of #schooltool for Saturday, 2007-02-17

*** kjcole has joined #schooltool00:00
*** kjcole has quit IRC00:31
*** jelkner has joined #schooltool02:00
*** jelkner has quit IRC02:01
*** jelkner has joined #schooltool02:01
*** jelkner has quit IRC02:06
*** wrobel has quit IRC03:53
*** shiny has joined #schooltool06:25
*** shiny has quit IRC07:14
*** shiny has joined #schooltool07:14
*** mgedmin has joined #schooltool11:38
*** Ninno has joined #schooltool15:01
*** shiny has quit IRC15:13
*** Ninno2 has joined #schooltool15:49
*** Ninno has quit IRC15:49
*** Boecki has joined #schooltool16:27
*** Boecki has left #schooltool16:27
*** filip101 has joined #schooltool17:10
*** filip101 has quit IRC17:32
*** masood has joined #schooltool18:05
*** jelkner has joined #schooltool18:18
*** Ninno2 has quit IRC18:30
*** pcardune has joined #schooltool18:41
masoodjust a quick question, before I quickly run away and quickly return for a quick so-say of my name: So, the ftesting.zcml error doesn't really have a solution...? (at least that was mentioned last class)18:45
*** bnguyen has joined #schooltool18:48
*** cpcarey11 has joined #schooltool18:49
*** masood is now known as smalekgh18:51
pcardunesmalekgh, what was the error again? and were you using your own zope setup (not the standard one provided on maddog)?18:52
*** jelkner has quit IRC18:52
*** Mounika has joined #schooltool18:52
*** mlinnell has joined #schooltool18:52
smalekghthe standard one provided by maddog, and it complains about an IOerror with ftesting.zcml18:52
pcardunesmalekgh, can you send me a private message with the error?18:53
*** Makorihi has joined #schooltool18:53
*** tehminkeh has joined #schooltool18:54
*** filip101 has joined #schooltool18:54
filip101I have a little question18:54
* Makorihi is Jama Mohamed18:54
filip101I missed the past few lessons18:54
* smalekgh is Masood Malekghassemi18:55
filip101How can I get the full code that was worked on up on maddog18:55
* filip101 is Filip Sufitchi18:55
smalekghfilip, just read the lessons and the chat logs18:55
smalekghoh, and lose the game18:55
filip101I did both of those18:55
* tehminkeh is Stephen Drodge18:55
* Mounika is Mounika G.18:55
filip101But neither one solves the problem that I don't have the source to what was worked on18:55
smalekghthe lessons have the full source code methinks18:55
filip101yeah, but how do I download that to maddog?18:55
filip101There is no firefox on there to use...18:56
* mlinnell is Mary L18:56
* cpcarey11 is Chris Carey18:57
filip101Ok... but I'm going to need a bit of guidance18:57
filip101I'm a unix noob18:57
filip101First of all, what is the address for sshing to maddog again?18:57
*** Preetam has joined #schooltool18:57
smalekghyou didn't save it?18:57
filip101I reformatted my hard drive18:57
smalekghanyways, it's methinks18:58
filip101ok thank18:58
smalekghI hope. Otherwise I'm SSHing into the totally wrong place and someone is going to come out and just yell 'PUNKED!'18:58
filip101ssh: Name or service not known18:59
*** tdoggette has joined #schooltool18:59
smalekghoh, oops18:59
smalekghdon't forget your port number18:59
filip101that's on a wiki somewhere isn't it?18:59
*** AVN` has joined #schooltool19:00
filip101where can I find it?19:01
smalekghuhhhh....... I... don't remember...19:01
filip101somebody else know?19:01
smalekghwell, if you startup the zope server19:01
smalekghit should say the port it's running on19:01
smalekghand that'd be your port19:01
pcarduneok, well it is 12 noon EST by my clock19:02
pcarduneso let's get started19:02
pcardunefirst thing to do is attendance, so assuming you all got Elkner's email, you know what to do19:02
* Preetam is Preetam D.19:02
* pcardune is Paul C.19:02
* AVN` is Chris B19:02
* smalekgh is Masood Malekghassemi19:02
* filip101 is Filip S.19:02
* tdoggette Thomas D.19:02
* Makorihi is Jama Mohamed19:02
* Mounika is Mounika G.19:02
* bnguyen is Brittney n19:02
* mlinnell is Mary L19:02
* cpcarey11 is Chris C.19:02
pcarduneand try to keep the same screen names as you've had in past weeks19:02
pcarduneSo, today we are going to be doing stuff with containers.19:03
pcarduneYou can see what kind of stuff we are doing each week by checking out the user stories19:03
pcardunelocated here:19:03
smalekghUh, what about ftesting.zcml from the previous class? Is that error ignorable?19:04
*** mattva01 has joined #schooltool19:04
* mattva01 is Matthew Gallagher19:04
pcardunesmalekgh, did other people get the error? and can you private message me what the error was?19:04
smalekghI thought I already private messaged you... anyways, here goes19:05
*** nitromaster has joined #schooltool19:05
pcardunefor those of you just coming in, don't forget to say your name for attendance19:06
* nitromaster is Andrew Rodriguez19:06
pcarduneok, so last week we did some refactoring and test writing19:07
pcardunewe wrote unit tests, and functional tests, and made one small change to make them pass19:07
pcardunethat was the "refactoring" part of the user storeis19:08
pcarduneNow we will be moving on to Iteration 4 of the user stories which specifically says: "By logging into the ZMI, the user should be able to create a container for storing *only* contacts."19:08
pcarduneContainers are among the most frequently used concepts in Zope3 because they allow us to create URL to object mappings in a very intuitive manner. Containers work just like python dictionaries.19:09
pcarduneoh, and just on a side note, i would really like to encourage you to ask lots of questions19:10
pcarduneif we get off track from the material in the class, it's ok because you'll be able to read the lessons19:10
pcarduneat home19:10
*** wjohnsto has joined #schooltool19:10
Makorihiso this specific container will keep track of all our Contacts?19:11
* wjohnsto William J.19:11
pcardunebut let's talk a little bit more about Containers19:11
pcardunea Container in Zope3 maps keys to values, just like dictionaries in python19:12
pcarduneLike with dictionaries, the values can be anything, even other Containers19:12
pcarduneIf you imagined a complicated data structure represented by dictionaries of dictionaries of dictionaries and so on, then you might access an item in the the deepest dictionary like so:19:12
pcardune>>> data['key1']['key2']['key3']19:12
pcardunethis looks a lot like a url: http://dataserver/key1/key2/key319:12
AVN`That sounds like it can get messy19:13
pcardunewell, zope does it all automatically for us19:13
pcardunei'm just illustrating how zope actually does "url traversal" be default19:13
tdoggetteContainers in the code become URLs in the site pretty directly, yes?19:14
pcarduneso, because of this "url to object mapping,"  it is really intuitive to write objects in terms of containers19:14
pcardunemore like URLS become containers pretty directly19:15
pcardunethe other way around doesn't amke as much sense19:15
tdoggetteOkay then.19:16
pcardunethe first thing we are going to do today is write tests19:16
pcardunebecause that should always be the first thing that you do19:16
pcarduneand we always start with unit tests too19:17
pcarduneso quick quiz question, where are the unit tests located?19:18
cpcarey11in README.txt19:18
pcardune(open up the that file for editing)19:18
pcarduneBefore we start adding stuff about containers, I'd like to do a few more things with the Contact class19:18
pcarduneIn your test file, I want you to set some of the attributes on the paul contact19:19
pcarduneI added this to my file:19:21
lisppaste5pcardune pasted "README.txt" at
pcardunepay attention to the last part about programmer representation19:24
pcarduneyou probably have never used this before but it comes in hand when you are writing tests19:24
pcardunethe "programmer representation" is just what gets spit out in a python interpreter when you type the name of a variable19:24
pcardunethe default programmer representation for the contact class is something like: < instance at 0xb745826c>19:25
pcardunewhich is pretty ugly19:25
pcardunewe want to change it to <Contact "Carduner, Paul">19:25
pcarduneNow you should try running the unit tests again19:25
pcarduneand they should fail (because we are not getting the programmer representation we want)19:26
pcarduneprogrammer representation is controled by the __repr__ method in classes19:26
pcardunewe can override the default one by just putting our own into the Contact class19:26
pcarduneI added something like this to my Contact class:19:26
pcardunedef __repr__(self):19:26
pcardune        """Returns programmer representation of Contact."""19:26
pcardune        return '<%s "%s, %s">' % (self.__class__.__name__,19:26
pcardune                                  self.lastName, self.firstName)19:26
pcarduneadding that should make the test pass19:27
mattva01i'll brb19:27
pcardunedoes anyone have any questions about this?19:28
AVN`this goes in, right?19:28
AVN`what do the %s mean>19:29
smalekghit's string formatting19:29
pcardune%s works the same way as it does in C, C++, and Java19:29
smalekghkinda like C's printf19:30
cpcarey11so would this method be called automatically when we need a programmer representation?19:30
pcarduneit is a place holder19:30
pcardunejust like the __init__ method gets called automatically, without explicitly saying SomeClass.__init__()19:30
pcarduneand just like the __int__ method gets called when we say int(someobject)19:30
pcarduneSo now lets go to containers19:31
pcardunego back the the unit test file19:31
pcarduneWhen writing tests we want to think about what we actually want our object to do19:32
pcarduneso we are creating a container object? what should it do?  how should it be created?  what attributes and methods should it have?19:32
pcardunedoes anyone have any thoughts about this?19:33
AVN`uh, it should hold contacts19:33
AVN`allow you to organise them?19:33
AVN`view them in order?19:33
AVN`maybe search them?19:34
Makorihiit should let you add and delete them?19:34
Makorihicopy them19:34
pcardunethese are all good, but lets thing about the  most basic things first19:34
pcardunesuper duper basics19:34
pcardunelike, how do we create a container?  in python19:34
Makorihiit should implement something19:34
pcardunethis isn't a question about zope, it is a question about how we want our program to work19:34
mlinnellsorry....I have to leave early today. I'll catch up later on the logs19:35
cpcarey11we need an interface19:35
*** mlinnell has quit IRC19:35
Makorihiwell, you need a data structure to hold the contacts in19:35
pcarduneok, this all sounds quite good so far19:35
pcardunedo we want any attributes?  what attributes would you recommend?19:35
Makorihisize of container19:36
nitromasterits owner19:36
pcarduneMakorihi, that would probably be a method, because it is dynamic19:36
Makorihitype of container19:36
pcardunewell, i'm going to say a title attribute19:36
pcardunethe container object is also going to act like content19:37
pcarduneand we usually like to title our content with some nice name19:37
pcardunewhich doesn't necessarily correspond to the url19:37
pcarduneFor example, we might title our container of contacts "The Cool People I know"... but the url would just be "coolpeople"19:37
pcardunehere is what I added to my README.txt in this direction:19:38
lisppaste5pcardune annotated #36983 with "README.txt container tests" at
wjohnstoso we need to import ContactContainer from contact?19:38
AVN`should I be getting an error in brower.txt when I run the tests?19:39
pcarduneyeah, the first thing is the super basics, how would we even create the container in a python interpretor19:39
nitromasterso in zope are you always supposed to run tests that don't work, then try and make them work?19:39
pcardunein general, yes - that's not just zope though, that is test driven development19:40
tdoggetteThe making of tests is basically the setting of goals for the program?19:40
nitromasteroh ok19:40
pcarduneso when you write a failing test, you are confirming that the goal has not already been implemented19:40
pcarduneif it has, then you might have messed up in writing your test, and not tested the right thing, or not done it thoroughly enough19:41
pcardunethis happens more when the test cases are more complicated than what we are doing19:41
pcarduneAs I said earlier, Containers are frequently used in Zope3.19:42
pcarduneThis means that Zope3 already defines some useful interfaces and implementations for container objects. We want to harness what Zope already does for us, so we're going to want the IContactContainer interface to extend a Zope defined interface, specifically
pcardunezope's container provides a lot of the stuff all of you were suggesting, like adding and deleting, etc.19:43
*** mattva01 is now known as Mattva01|Breakfa19:43
pcarduneso if containers work just like python dictionaries,19:44
pcardunelets say I had a container called coolpeople (in a python interpretor), how would I access the contact called paul (in python)19:44
nitromastercoolpeople['paul'] ?19:45
pcardunecoolpeople['paul'] is the right answer19:47
pcarduneso we want to include this kind of stuff in our test19:47
lisppaste5pcardune annotated #36983 with "more container tests" at
pcardunehow would we delete the 'paul' contact?19:48
wjohnstodel coolpeople['paul']19:48
cpcarey11del coolpeople[coolpeople.index('paul')]19:49
pcarduneno, this is a dictionary, not a list19:50
pcarduneso, the additional tests that I just posted show how that is done19:51
*** Mattva01|Breakfa is now known as Mattva0119:52
pcarduneNow that we have finished writing the tests for the code we are about to write, lets get to writing the actual code! We will go through the tests and make each test pass one by one.19:53
AVN`wtf... all of my tests passed19:54
pcarduneThe first test asks for the existence of the ContactContainer class and the IContactContainer interface, so let's create those.19:54
pcarduneAVN`, are you sure that you are running any of the tests, make sure it doesn't say "0 tests run, 0 tests failed"19:54
AVN`  Ran 4 tests with 0 failures and 0 errors in 3.915 seconds.19:54
pcardunesee me in cando-help19:56
pcarduneIn add the following:19:58
pcarduneclass IContactContainer(zope.interface.Interface):19:58
pcardune    """The interface for a contact container."""19:58
pcarduneRemember that we are only writing code to make each of the tests pass one by one, so we don't need the full working code yet19:59
pcarduneNext add the following to
pcarduneclass ContactContainer(object):19:59
pcardune    """Implementation of IContactContainer."""19:59
pcardune    zope.interface.implements(interfaces.IContactContainer)19:59
pcardunethis is all the first three lines of our test ask for20:00
pcarduneso run the tests again, and the test should now fail at a later point in README.txt20:00
pcarduneremember to run the tests like so: bin/test -uvvp1 -s zcontact20:00
nitromastershouldn't we at least get the basic container functionality by implementing IContainer ?20:01
pcarduneif you put the 1 (a "one" not an "el") in the options then it will stop running the tests after the first failure20:01
pcardunenitromaster, we are just doing this extra slow for now20:01
pcardunenormally I would just implement the whole right away20:01
nitromasterok, that makes more sense20:01
pcardunebut I want you to understand the process of writing and making tests pass20:01
pcardunethe idea is that you want to do as little as possible to actually make the tests pass20:02
pcardunethat said, let's go ahead and finish the entire interface. Go back to and make the IContactContainer interface look like this20:03
nitromasterwhy is the contactcontainer in shouldn't it be in ?20:03
lisppaste5pcardune pasted "" at
pcardunenitromaster, no... unlike java, it is perfectly normal to put multiple classes in the same python file20:03
pcarduneespecially when they have a lot to do with each other20:03
nitromasterok, but isn't it cleaner to seperate things?20:04
pcardunewe want to put all the stuff realating to contact in the same file20:04
pcardunewhy? if we put them in separate files, we just have more files to deal with20:04
nitromasterthat's true, very true20:05
pcardunethis especially doesn't make sense when the classes are pretty short with few methods20:05
pcarduneDon't forget to import at the top of the file20:06
pcarduneor you'll get an error20:06
pcarduneNow when we jump back to and try to implement this interface, we might notice a problem: what does IContainer require of its implementations?20:07
pcardunei mentioned earlier some stuff about adding and deleting already being defined in the IContainer interface, but what else is defined20:08
filip101a title attribute20:08
pcarduneone way to find out is to actually open up the file that defines the IContainer interface, which on maddog is located here: /usr/local/src/Zope3/src/zope/app/container/
pcardunefilip101, but remember that IContactContainer inherits from IContainer (which defines a bunch of other stuff besides the title attribute)20:08
pcarduneI encourage you to check out that file, so you can see what zope source code actually looks like20:09
pcarduneFortunately though, there is already an implementation of the IContainer interface in zope20:10
pcarduneSo to implement the IContactContainer interface (which extends the IContainer interface), our implementation just has to extend an implementation of IContainer.20:11
pcarduneThe implementation of IContainer I happen to be talking about is There are other implementations of IContainer that we could use, but BTreeContainer is the one most often used.20:11
pcardunenow, i'd like you to implement the IContactContainer interface on your own20:12
pcarduneand then use lisppaste to post what you have written20:12
wjohnstoumm ok20:14
pcardunedoes everyone know how to use lisppaste?20:15
cpcarey11i don't20:15
pcardunego to
Mounikame neither20:15
pcarduneand it is pretty self explanatory20:15
lisppaste5filip101 pasted "IContactContainer implementation" at
lisppaste5wjohnsto pasted "" at
pcardunefilip101, don't forget about the title attribute20:17
lisppaste5wjohnsto annotated #36991 with "" at
pcardunewjohnsto, this is going to fail because you don't have a title attribute, and none of the methods from the IContainer interface are implemented20:18
pcarduneremember that we have to extend an implementation of IContainer (i.e. by making our implementation inherit from a class defined in zope20:19
cpcarey11how can I reach BTreeContainer?20:19
lisppaste5filip101 annotated #36990 with "Correction..." at
pcardunethis is what I have:20:21
lisppaste5pcardune pasted " (my version)" at
pcarduneThe last test to make pass is the one about programmer representation. So add the following method to the ContactContainer class:20:21
lisppaste5pcardune annotated #36992 with "ContactContainer (completed)" at
pcarduneAny questions so far?20:23
AVN`when it goes down the side like that20:23
AVN`for the programmer representation20:23
pcarduneoh yes20:23
AVN`is that just because the line is too long20:23
AVN`or is it supposed to be indented like that20:23
pcarduneyou can make python code span multiple lines as long as it is in parentheses20:24
pcarduneand you should indent it like that (although you don't have to)20:24
AVN`so it will work if its just on one line?20:24
pcarduneYou want to keep your code within 80 characters20:24
cpcarey11did you have to find the source code for BTreeContainer to find out how to implement it? or is there another way?20:25
wjohnstoimport it?20:25
pcardunedo you mean importing it?20:25
cpcarey11never mind, i think i'm fine20:26
pcarduneso now that we have finished with the implementation what is next?20:27
AVN`testing it?20:28
filip101run the test?20:28
pcardunewell yes, by all means run the tests20:28
pcardunebut I mean after that20:28
pcardune(the tests should pass)20:28
pcarduneyou might want to look at the user stories again to refresh your memory20:29
Preetamwe need to create a main page for the container that shows the contacts in alphabetical order20:31
wjohnstowe need to create a container object in the ZMI20:31
pcardunebut of course, before actually making our code do this, we want to write the tests for it20:32
AVN`its 1:3020:32
wjohnstoso browser.txt20:32
AVN`I got to go now,20:32
AVN`see ya20:32
pcarduneAVN`, bye20:32
pcarduneread the lesson20:32
pcarduneyes, browser.txt is right20:33
*** AVN` has quit IRC20:33
pcarduneThe first thing we want to be able to do is create the container object through the ZMI. Naturally, we will write functional tests that describes how this is done. So open up browser.txt20:33
pcarduneYou will want to add a new section for the contact container20:35
pcardunego ahead and start doing this20:35
pcarduneI'll post what I have in a second20:35
pcarduneyou can mostly follow what we already did with the Contact functional tests, just slightly modified for the container20:35
wjohnstoyou mean like "Creating a Contact Container"???20:36
lisppaste5pcardune pasted "browser.txt" at
pcarduneBefore we go on to implement the browser views, we have to set up permissions on the ContactContainer class. You may remember from implementing the Contact class, that we had to edit the configure.zcml file.20:39
wjohnstoso we have to allow for a new class20:39
lisppaste5pcardune pasted "configure.zcml" at
wjohnstoso does that mean we need to add another form for the browser?20:42
wjohnstoand a menuItem?20:42
lisppaste5pcardune annotated #36996 with "more configure.zcml" at
Makorihii have to leave now, i'll make sure to catch up on this later20:45
pcarduneGo ahead and run the tests again just to make sure everything worked. Now we will get back to writing more functional tests.20:45
*** Makorihi has quit IRC20:45
pcarduneSo edit browser.txt to include the following tests:20:46
smalekghwell, I gotta go for lunch, so uhh... bye :-) I'll read the lesson plan20:47
*** smalekgh has left #schooltool20:47
*** bnguyen has quit IRC20:47
lisppaste5pcardune pasted "browser.txt" at
pcarduneNow, if we follow the pattern that we used in writing the Contact object's views, the first thing we would do is right a page template that displays the information we are asking for in the functional test.20:50
wjohnstoso are we going...... nevermind answered my question20:51
pcarduneHowever, containers can work a bit differently because they are so heavily used that Zope already has default views available for them.20:51
pcardunewe need to set permissions on these views so they are available to us. Later we will want to customize these views and will most likely rewrite them, but for now we will just use zope's defaults.20:51
pcarduneSo open up configure.zcml and add the following registration:20:51
pcardune  <browser:containerViews20:51
pcardune      for="zcontact.interfaces.IContactContainer"20:51
pcardune      contents="zope.ManageContent"20:51
pcardune      add="zope.ManageContent"20:51
pcardune      />20:51
wjohnstonice I can add a contact container in the ZMI now20:52
pcarduneThis tag registers two views for the IContactContainer interface: the contents view and the add view.20:52
pcarduneThe contents view is exactly what you see when you first log in to the ZMI: a view that shows you the contents of the root folder in your instance. So here we say that people with the zope.ManageContent permission are aloud to see that view.20:52
pcarduneThe add view gives us the add menu on the left that allows us to add objects to the container. You also see the add view when you first log in to the ZMI.20:53
pcarduneSo, log in to the ZMI and try this stuff out20:53
pcarduneyou'll notice that after you have added the ContactContainer, and then click on it, on the left side where are the add links are, you see *all* the different objects we can add20:54
*** wrobel has joined #schooltool20:54
pcardunebut we only want be able to add ZContact objects to the container20:54
pcardunewhat we need is a constraint on the container that says we can only add the Zcontact object to it20:54
pcarduneopen up the file20:54
pcarduneand you want to add this line to the IContactContainer interface:
pcardunedon't forget to import at the top of the file20:56
pcardunethis says that the IContactContainer interface only allows things that implement IContact interface to be contained in something implementing IContactContainer20:57
pcardunedoes that make sense?20:57
pcarduneit is probably still a little bit complicated to talk about everything in terms of interfaces20:57
pcardunebut this is how zope works20:57
pcarduneIt's nearly 2, so we are going to stop hear20:58
pcardunewe'll do the other stuff in the user stories 2 weeks from now20:58
pcarduneif you have any questions at all, please stick around and ask them20:58
pcarduneremember that we don't have class next week20:58
wjohnstomuch respect for you, pcardune20:58
Mounikathank you!20:59
*** Mounika has quit IRC20:59
pcarduneyour welcome20:59
tdoggetteJolly good show.20:59
*** cpcarey11 has quit IRC21:00
*** nitromaster has left #schooltool21:02
*** tdoggette has quit IRC21:02
*** Preetam has left #schooltool21:03
*** pcardune is now known as pcardune_away21:07
*** filip101 is now known as filip101_at_lunc21:09
*** Mattva01 has left #schooltool21:31
*** filip101_at_lunc is now known as filip10121:32

Generated by 2.15.1 by Marius Gedminas - find it at!