*** kjcole has joined #schooltool | 00:00 | |
*** kjcole has quit IRC | 00:31 | |
*** jelkner has joined #schooltool | 02:00 | |
*** jelkner has quit IRC | 02:01 | |
*** jelkner has joined #schooltool | 02:01 | |
*** jelkner has quit IRC | 02:06 | |
*** wrobel has quit IRC | 03:53 | |
*** shiny has joined #schooltool | 06:25 | |
*** shiny has quit IRC | 07:14 | |
*** shiny has joined #schooltool | 07:14 | |
*** mgedmin has joined #schooltool | 11:38 | |
*** Ninno has joined #schooltool | 15:01 | |
*** shiny has quit IRC | 15:13 | |
*** Ninno2 has joined #schooltool | 15:49 | |
*** Ninno has quit IRC | 15:49 | |
*** Boecki has joined #schooltool | 16:27 | |
*** Boecki has left #schooltool | 16:27 | |
*** filip101 has joined #schooltool | 17:10 | |
*** filip101 has quit IRC | 17:32 | |
*** masood has joined #schooltool | 18:05 | |
*** jelkner has joined #schooltool | 18:18 | |
*** Ninno2 has quit IRC | 18:30 | |
*** pcardune has joined #schooltool | 18:41 | |
masood | just 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 #schooltool | 18:48 | |
*** cpcarey11 has joined #schooltool | 18:49 | |
*** masood is now known as smalekgh | 18:51 | |
pcardune | smalekgh, 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 IRC | 18:52 | |
*** Mounika has joined #schooltool | 18:52 | |
*** mlinnell has joined #schooltool | 18:52 | |
smalekgh | the standard one provided by maddog, and it complains about an IOerror with ftesting.zcml | 18:52 |
pcardune | smalekgh, can you send me a private message with the error? | 18:53 |
*** Makorihi has joined #schooltool | 18:53 | |
*** tehminkeh has joined #schooltool | 18:54 | |
*** filip101 has joined #schooltool | 18:54 | |
filip101 | hello | 18:54 |
filip101 | I have a little question | 18:54 |
* Makorihi is Jama Mohamed | 18:54 | |
filip101 | I missed the past few lessons | 18:54 |
* smalekgh is Masood Malekghassemi | 18:55 | |
filip101 | How can I get the full code that was worked on up on maddog | 18:55 |
* filip101 is Filip Sufitchi | 18:55 | |
smalekgh | filip, just read the lessons and the chat logs | 18:55 |
smalekgh | oh, and lose the game | 18:55 |
filip101 | I did both of those | 18:55 |
* tehminkeh is Stephen Drodge | 18:55 | |
* Mounika is Mounika G. | 18:55 | |
filip101 | But neither one solves the problem that I don't have the source to what was worked on | 18:55 |
smalekgh | the lessons have the full source code methinks | 18:55 |
filip101 | yeah, but how do I download that to maddog? | 18:55 |
filip101 | There is no firefox on there to use... | 18:56 |
* mlinnell is Mary L | 18:56 | |
tehminkeh | scp | 18:57 |
* cpcarey11 is Chris Carey | 18:57 | |
filip101 | Ok... but I'm going to need a bit of guidance | 18:57 |
filip101 | I'm a unix noob | 18:57 |
filip101 | First of all, what is the address for sshing to maddog again? | 18:57 |
*** Preetam has joined #schooltool | 18:57 | |
smalekgh | you didn't save it? | 18:57 |
filip101 | I reformatted my hard drive | 18:57 |
smalekgh | ow | 18:57 |
smalekgh | anyways, it's maddog.yhspatriot.org methinks | 18:58 |
filip101 | ok thank | 18:58 |
smalekgh | I hope. Otherwise I'm SSHing into the totally wrong place and someone is going to come out and just yell 'PUNKED!' | 18:58 |
filip101 | hmm | 18:58 |
filip101 | ssh: maddog.yhspatriot.org: Name or service not known | 18:59 |
Makorihi | .net | 18:59 |
*** tdoggette has joined #schooltool | 18:59 | |
smalekgh | maddog.yhspatriot.net | 18:59 |
filip101 | ok | 18:59 |
smalekgh | oh, oops | 18:59 |
smalekgh | don't forget your port number | 18:59 |
filip101 | that's on a wiki somewhere isn't it? | 18:59 |
*** AVN` has joined #schooltool | 19:00 | |
filip101 | where can I find it? | 19:01 |
smalekgh | uhhhh....... I... don't remember... | 19:01 |
filip101 | somebody else know? | 19:01 |
smalekgh | well, if you startup the zope server | 19:01 |
smalekgh | it should say the port it's running on | 19:01 |
smalekgh | and that'd be your port | 19:01 |
filip101 | ok | 19:01 |
pcardune | ok, well it is 12 noon EST by my clock | 19:02 |
pcardune | so let's get started | 19:02 |
pcardune | first thing to do is attendance, so assuming you all got Elkner's email, you know what to do | 19:02 |
* Preetam is Preetam D. | 19:02 | |
* pcardune is Paul C. | 19:02 | |
* AVN` is Chris B | 19:02 | |
* smalekgh is Masood Malekghassemi | 19:02 | |
* filip101 is Filip S. | 19:02 | |
* tdoggette Thomas D. | 19:02 | |
* Makorihi is Jama Mohamed | 19:02 | |
* Mounika is Mounika G. | 19:02 | |
* bnguyen is Brittney n | 19:02 | |
* mlinnell is Mary L | 19:02 | |
* cpcarey11 is Chris C. | 19:02 | |
pcardune | and try to keep the same screen names as you've had in past weeks | 19:02 |
pcardune | So, today we are going to be doing stuff with containers. | 19:03 |
pcardune | You can see what kind of stuff we are doing each week by checking out the user stories | 19:03 |
pcardune | located here: | 19:03 |
pcardune | http://svn.schooltool.org/trac/cando/wiki/ZContact | 19:03 |
smalekgh | Uh, what about ftesting.zcml from the previous class? Is that error ignorable? | 19:04 |
*** mattva01 has joined #schooltool | 19:04 | |
* mattva01 is Matthew Gallagher | 19:04 | |
pcardune | smalekgh, did other people get the error? and can you private message me what the error was? | 19:04 |
mattva01 | sorry | 19:04 |
smalekgh | I thought I already private messaged you... anyways, here goes | 19:05 |
*** nitromaster has joined #schooltool | 19:05 | |
pcardune | for those of you just coming in, don't forget to say your name for attendance | 19:06 |
* nitromaster is Andrew Rodriguez | 19:06 | |
pcardune | ok, so last week we did some refactoring and test writing | 19:07 |
pcardune | we wrote unit tests, and functional tests, and made one small change to make them pass | 19:07 |
pcardune | that was the "refactoring" part of the user storeis | 19:08 |
pcardune | Now 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 |
pcardune | Containers 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 |
pcardune | oh, and just on a side note, i would really like to encourage you to ask lots of questions | 19:10 |
pcardune | if we get off track from the material in the class, it's ok because you'll be able to read the lessons | 19:10 |
pcardune | at home | 19:10 |
*** wjohnsto has joined #schooltool | 19:10 | |
Makorihi | so this specific container will keep track of all our Contacts? | 19:11 |
* wjohnsto William J. | 19:11 | |
pcardune | yes | 19:11 |
pcardune | but let's talk a little bit more about Containers | 19:11 |
pcardune | a Container in Zope3 maps keys to values, just like dictionaries in python | 19:12 |
pcardune | Like with dictionaries, the values can be anything, even other Containers | 19:12 |
pcardune | If 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 |
pcardune | this looks a lot like a url: http://dataserver/key1/key2/key3 | 19:12 |
AVN` | That sounds like it can get messy | 19:13 |
pcardune | well, zope does it all automatically for us | 19:13 |
pcardune | i'm just illustrating how zope actually does "url traversal" be default | 19:13 |
tdoggette | Containers in the code become URLs in the site pretty directly, yes? | 19:14 |
pcardune | so, because of this "url to object mapping," it is really intuitive to write objects in terms of containers | 19:14 |
pcardune | more like URLS become containers pretty directly | 19:15 |
pcardune | the other way around doesn't amke as much sense | 19:15 |
tdoggette | Okay then. | 19:16 |
pcardune | the first thing we are going to do today is write tests | 19:16 |
pcardune | because that should always be the first thing that you do | 19:16 |
pcardune | and we always start with unit tests too | 19:17 |
pcardune | so quick quiz question, where are the unit tests located? | 19:18 |
cpcarey11 | in README.txt | 19:18 |
pcardune | (open up the that file for editing) | 19:18 |
pcardune | Before we start adding stuff about containers, I'd like to do a few more things with the Contact class | 19:18 |
pcardune | In your test file, I want you to set some of the attributes on the paul contact | 19:19 |
pcardune | I added this to my file: | 19:21 |
lisppaste5 | pcardune pasted "README.txt" at http://paste.lisp.org/display/36983 | 19:21 |
pcardune | pay attention to the last part about programmer representation | 19:24 |
pcardune | you probably have never used this before but it comes in hand when you are writing tests | 19:24 |
pcardune | the "programmer representation" is just what gets spit out in a python interpreter when you type the name of a variable | 19:24 |
pcardune | the default programmer representation for the contact class is something like: <zcontact.contact.Contact instance at 0xb745826c> | 19:25 |
pcardune | which is pretty ugly | 19:25 |
pcardune | we want to change it to <Contact "Carduner, Paul"> | 19:25 |
pcardune | Now you should try running the unit tests again | 19:25 |
pcardune | and they should fail (because we are not getting the programmer representation we want) | 19:26 |
pcardune | programmer representation is controled by the __repr__ method in classes | 19:26 |
pcardune | we can override the default one by just putting our own into the Contact class | 19:26 |
pcardune | I added something like this to my Contact class: | 19:26 |
pcardune | def __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 |
pcardune | adding that should make the test pass | 19:27 |
mattva01 | i'll brb | 19:27 |
pcardune | does anyone have any questions about this? | 19:28 |
AVN` | this goes in contact.py, right? | 19:28 |
pcardune | yes | 19:28 |
AVN` | what do the %s mean> | 19:29 |
wjohnsto | string | 19:29 |
smalekgh | it's string formatting | 19:29 |
pcardune | %s works the same way as it does in C, C++, and Java | 19:29 |
smalekgh | kinda like C's printf | 19:30 |
cpcarey11 | so would this method be called automatically when we need a programmer representation? | 19:30 |
pcardune | it is a place holder | 19:30 |
pcardune | right | 19:30 |
pcardune | just like the __init__ method gets called automatically, without explicitly saying SomeClass.__init__() | 19:30 |
pcardune | and just like the __int__ method gets called when we say int(someobject) | 19:30 |
pcardune | So now lets go to containers | 19:31 |
pcardune | go back the the unit test file | 19:31 |
pcardune | When writing tests we want to think about what we actually want our object to do | 19:32 |
pcardune | so we are creating a container object? what should it do? how should it be created? what attributes and methods should it have? | 19:32 |
pcardune | does anyone have any thoughts about this? | 19:33 |
AVN` | uh, it should hold contacts | 19:33 |
AVN` | allow you to organise them? | 19:33 |
AVN` | view them in order? | 19:33 |
AVN` | maybe search them? | 19:34 |
Makorihi | it should let you add and delete them? | 19:34 |
Makorihi | copy them | 19:34 |
pcardune | these are all good, but lets thing about the most basic things first | 19:34 |
pcardune | super duper basics | 19:34 |
pcardune | like, how do we create a container? in python | 19:34 |
Makorihi | it should implement something | 19:34 |
pcardune | this isn't a question about zope, it is a question about how we want our program to work | 19:34 |
mlinnell | sorry....I have to leave early today. I'll catch up later on the logs | 19:35 |
cpcarey11 | we need an interface | 19:35 |
*** mlinnell has quit IRC | 19:35 | |
Makorihi | well, you need a data structure to hold the contacts in | 19:35 |
pcardune | ok, this all sounds quite good so far | 19:35 |
pcardune | do we want any attributes? what attributes would you recommend? | 19:35 |
Makorihi | size of container | 19:36 |
nitromaster | its owner | 19:36 |
pcardune | Makorihi, that would probably be a method, because it is dynamic | 19:36 |
Makorihi | type of container | 19:36 |
pcardune | well, i'm going to say a title attribute | 19:36 |
pcardune | the container object is also going to act like content | 19:37 |
pcardune | and we usually like to title our content with some nice name | 19:37 |
pcardune | which doesn't necessarily correspond to the url | 19:37 |
pcardune | For example, we might title our container of contacts "The Cool People I know"... but the url would just be "coolpeople" | 19:37 |
pcardune | here is what I added to my README.txt in this direction: | 19:38 |
lisppaste5 | pcardune annotated #36983 with "README.txt container tests" at http://paste.lisp.org/display/36983#1 | 19:38 |
wjohnsto | so we need to import ContactContainer from contact? | 19:38 |
wjohnsto | oh... | 19:38 |
AVN` | should I be getting an error in brower.txt when I run the tests? | 19:39 |
pcardune | yeah, the first thing is the super basics, how would we even create the container in a python interpretor | 19:39 |
nitromaster | so in zope are you always supposed to run tests that don't work, then try and make them work? | 19:39 |
pcardune | in general, yes - that's not just zope though, that is test driven development | 19:40 |
tdoggette | The making of tests is basically the setting of goals for the program? | 19:40 |
pcardune | yes | 19:40 |
nitromaster | oh ok | 19:40 |
pcardune | so when you write a failing test, you are confirming that the goal has not already been implemented | 19:40 |
pcardune | if it has, then you might have messed up in writing your test, and not tested the right thing, or not done it thoroughly enough | 19:41 |
pcardune | this happens more when the test cases are more complicated than what we are doing | 19:41 |
pcardune | As I said earlier, Containers are frequently used in Zope3. | 19:42 |
pcardune | This 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 zope.app.container.interfaces.IContainer. | 19:42 |
pcardune | zope'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|Breakfa | 19:43 | |
pcardune | so if containers work just like python dictionaries, | 19:44 |
pcardune | lets say I had a container called coolpeople (in a python interpretor), how would I access the contact called paul (in python) | 19:44 |
pcardune | ?? | 19:45 |
nitromaster | coolpeople['paul'] ? | 19:45 |
wjohnsto | container['paul']? | 19:45 |
cpcarey11 | coolpeople.get_key(paul)? | 19:45 |
Preetam | coolpeople['paul'] | 19:45 |
pcardune | coolpeople['paul'] is the right answer | 19:47 |
pcardune | so we want to include this kind of stuff in our test | 19:47 |
lisppaste5 | pcardune annotated #36983 with "more container tests" at http://paste.lisp.org/display/36983#2 | 19:47 |
pcardune | how would we delete the 'paul' contact? | 19:48 |
wjohnsto | del coolpeople['paul'] | 19:48 |
wjohnsto | ? | 19:49 |
pcardune | yep | 19:49 |
cpcarey11 | del coolpeople[coolpeople.index('paul')] | 19:49 |
pcardune | no, this is a dictionary, not a list | 19:50 |
pcardune | so, the additional tests that I just posted show how that is done | 19:51 |
*** Mattva01|Breakfa is now known as Mattva01 | 19:52 | |
pcardune | Now 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 passed | 19:54 |
pcardune | The first test asks for the existence of the ContactContainer class and the IContactContainer interface, so let's create those. | 19:54 |
pcardune | AVN`, 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 |
pcardune | see me in cando-help | 19:56 |
pcardune | In interfaces.py add the following: | 19:58 |
pcardune | class IContactContainer(zope.interface.Interface): | 19:58 |
pcardune | """The interface for a contact container.""" | 19:58 |
pcardune | Remember 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 yet | 19:59 |
pcardune | Next add the following to contact.py: | 19:59 |
pcardune | class ContactContainer(object): | 19:59 |
pcardune | """Implementation of IContactContainer.""" | 19:59 |
pcardune | zope.interface.implements(interfaces.IContactContainer) | 19:59 |
pcardune | this is all the first three lines of our test ask for | 20:00 |
pcardune | so run the tests again, and the test should now fail at a later point in README.txt | 20:00 |
pcardune | remember to run the tests like so: bin/test -uvvp1 -s zcontact | 20:00 |
nitromaster | shouldn't we at least get the basic container functionality by implementing IContainer ? | 20:01 |
pcardune | if you put the 1 (a "one" not an "el") in the options then it will stop running the tests after the first failure | 20:01 |
pcardune | nitromaster, we are just doing this extra slow for now | 20:01 |
pcardune | normally I would just implement the whole right away | 20:01 |
nitromaster | ok, that makes more sense | 20:01 |
pcardune | but I want you to understand the process of writing and making tests pass | 20:01 |
pcardune | the idea is that you want to do as little as possible to actually make the tests pass | 20:02 |
pcardune | that said, let's go ahead and finish the entire interface. Go back to interfaces.py and make the IContactContainer interface look like this | 20:03 |
nitromaster | why is the contactcontainer in contact.py? shouldn't it be in contactcontainer.py ? | 20:03 |
lisppaste5 | pcardune pasted "interfaces.py" at http://paste.lisp.org/display/36987 | 20:03 |
pcardune | nitromaster, no... unlike java, it is perfectly normal to put multiple classes in the same python file | 20:03 |
pcardune | especially when they have a lot to do with each other | 20:03 |
nitromaster | ok, but isn't it cleaner to seperate things? | 20:04 |
pcardune | we want to put all the stuff realating to contact in the same file | 20:04 |
pcardune | why? if we put them in separate files, we just have more files to deal with | 20:04 |
nitromaster | that's true, very true | 20:05 |
pcardune | this especially doesn't make sense when the classes are pretty short with few methods | 20:05 |
pcardune | Don't forget to import zope.app.container.interfaces at the top of the file | 20:06 |
pcardune | or you'll get an error | 20:06 |
pcardune | Now when we jump back to contact.py and try to implement this interface, we might notice a problem: what does IContainer require of its implementations? | 20:07 |
pcardune | i mentioned earlier some stuff about adding and deleting already being defined in the IContainer interface, but what else is defined | 20:08 |
filip101 | a title attribute | 20:08 |
pcardune | one 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/interfaces.py. | 20:08 |
pcardune | filip101, but remember that IContactContainer inherits from IContainer (which defines a bunch of other stuff besides the title attribute) | 20:08 |
filip101 | right | 20:08 |
pcardune | I encourage you to check out that file, so you can see what zope source code actually looks like | 20:09 |
pcardune | Fortunately though, there is already an implementation of the IContainer interface in zope | 20:10 |
pcardune | So to implement the IContactContainer interface (which extends the IContainer interface), our implementation just has to extend an implementation of IContainer. | 20:11 |
pcardune | The implementation of IContainer I happen to be talking about is zope.app.container.btree.BTreeContainer. There are other implementations of IContainer that we could use, but BTreeContainer is the one most often used. | 20:11 |
pcardune | now, i'd like you to implement the IContactContainer interface on your own | 20:12 |
pcardune | and then use lisppaste to post what you have written | 20:12 |
wjohnsto | umm ok | 20:14 |
pcardune | does everyone know how to use lisppaste? | 20:15 |
cpcarey11 | i don't | 20:15 |
pcardune | go to http://paste.lisp.org/new/schooltool | 20:15 |
Mounika | me neither | 20:15 |
pcardune | and it is pretty self explanatory | 20:15 |
lisppaste5 | filip101 pasted "IContactContainer implementation" at http://paste.lisp.org/display/36990 | 20:16 |
lisppaste5 | wjohnsto pasted "contact.py" at http://paste.lisp.org/display/36991 | 20:17 |
pcardune | filip101, don't forget about the title attribute | 20:17 |
filip101 | oh | 20:17 |
lisppaste5 | wjohnsto annotated #36991 with "contact.py" at http://paste.lisp.org/display/36991#1 | 20:18 |
pcardune | wjohnsto, this is going to fail because you don't have a title attribute, and none of the methods from the IContainer interface are implemented | 20:18 |
pcardune | remember that we have to extend an implementation of IContainer (i.e. by making our implementation inherit from a class defined in zope | 20:19 |
cpcarey11 | how can I reach BTreeContainer? | 20:19 |
lisppaste5 | filip101 annotated #36990 with "Correction..." at http://paste.lisp.org/display/36990#1 | 20:19 |
wjohnsto | import zope.app.container.btree | 20:19 |
filip101 | oh | 20:20 |
pcardune | this is what I have: | 20:21 |
lisppaste5 | pcardune pasted "contact.py (my version)" at http://paste.lisp.org/display/36992 | 20:21 |
pcardune | The last test to make pass is the one about programmer representation. So add the following method to the ContactContainer class: | 20:21 |
lisppaste5 | pcardune annotated #36992 with "ContactContainer (completed)" at http://paste.lisp.org/display/36992#1 | 20:22 |
pcardune | Any questions so far? | 20:23 |
AVN` | yeah | 20:23 |
AVN` | when it goes down the side like that | 20:23 |
AVN` | for the programmer representation | 20:23 |
pcardune | oh yes | 20:23 |
AVN` | is that just because the line is too long | 20:23 |
AVN` | or is it supposed to be indented like that | 20:23 |
pcardune | you can make python code span multiple lines as long as it is in parentheses | 20:24 |
pcardune | and 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 |
pcardune | You want to keep your code within 80 characters | 20:24 |
pcardune | yes | 20:24 |
cpcarey11 | did you have to find the source code for BTreeContainer to find out how to implement it? or is there another way? | 20:25 |
wjohnsto | import it? | 20:25 |
pcardune | do you mean importing it? | 20:25 |
cpcarey11 | no | 20:25 |
cpcarey11 | never mind, i think i'm fine | 20:26 |
pcardune | so now that we have finished with the implementation what is next? | 20:27 |
AVN` | testing it? | 20:28 |
filip101 | run the test? | 20:28 |
pcardune | well yes, by all means run the tests | 20:28 |
pcardune | but I mean after that | 20:28 |
pcardune | (the tests should pass) | 20:28 |
pcardune | you might want to look at the user stories again to refresh your memory | 20:29 |
pcardune | https://svn.schooltool.org/trac/cando/wiki/ZContact | 20:29 |
wjohnsto | browser | 20:30 |
Preetam | we need to create a main page for the container that shows the contacts in alphabetical order | 20:31 |
wjohnsto | we need to create a container object in the ZMI | 20:31 |
pcardune | yeah | 20:32 |
pcardune | but of course, before actually making our code do this, we want to write the tests for it | 20:32 |
AVN` | its 1:30 | 20:32 |
wjohnsto | so browser.txt | 20:32 |
pcardune | yeah | 20:32 |
AVN` | I got to go now, | 20:32 |
AVN` | see ya | 20:32 |
pcardune | AVN`, bye | 20:32 |
pcardune | read the lesson | 20:32 |
AVN` | ok | 20:32 |
pcardune | yes, browser.txt is right | 20:33 |
*** AVN` has quit IRC | 20:33 | |
pcardune | The 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.txt | 20:33 |
pcardune | You will want to add a new section for the contact container | 20:35 |
pcardune | go ahead and start doing this | 20:35 |
pcardune | I'll post what I have in a second | 20:35 |
pcardune | you can mostly follow what we already did with the Contact functional tests, just slightly modified for the container | 20:35 |
wjohnsto | you mean like "Creating a Contact Container"??? | 20:36 |
pcardune | yeah | 20:36 |
lisppaste5 | pcardune pasted "browser.txt" at http://paste.lisp.org/display/36994 | 20:38 |
pcardune | Before 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 |
wjohnsto | so we have to allow for a new class | 20:39 |
pcardune | yeah | 20:40 |
lisppaste5 | pcardune pasted "configure.zcml" at http://paste.lisp.org/display/36996 | 20:40 |
wjohnsto | so does that mean we need to add another form for the browser? | 20:42 |
wjohnsto | and a menuItem? | 20:42 |
pcardune | yep | 20:42 |
lisppaste5 | pcardune annotated #36996 with "more configure.zcml" at http://paste.lisp.org/display/36996#1 | 20:43 |
Makorihi | i have to leave now, i'll make sure to catch up on this later | 20:45 |
pcardune | Go ahead and run the tests again just to make sure everything worked. Now we will get back to writing more functional tests. | 20:45 |
pcardune | ok | 20:45 |
*** Makorihi has quit IRC | 20:45 | |
pcardune | So edit browser.txt to include the following tests: | 20:46 |
smalekgh | well, I gotta go for lunch, so uhh... bye :-) I'll read the lesson plan | 20:47 |
*** smalekgh has left #schooltool | 20:47 | |
*** bnguyen has quit IRC | 20:47 | |
wjohnsto | sweet | 20:47 |
lisppaste5 | pcardune pasted "browser.txt" at http://paste.lisp.org/display/36997 | 20:48 |
pcardune | Now, 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 |
wjohnsto | so are we going...... nevermind answered my question | 20:51 |
pcardune | However, containers can work a bit differently because they are so heavily used that Zope already has default views available for them. | 20:51 |
pcardune | we 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 |
pcardune | So open up configure.zcml and add the following registration: | 20:51 |
pcardune | <browser:containerViews | 20:51 |
pcardune | for="zcontact.interfaces.IContactContainer" | 20:51 |
pcardune | contents="zope.ManageContent" | 20:51 |
pcardune | add="zope.ManageContent" | 20:51 |
pcardune | /> | 20:51 |
wjohnsto | nice I can add a contact container in the ZMI now | 20:52 |
pcardune | This tag registers two views for the IContactContainer interface: the contents view and the add view. | 20:52 |
pcardune | The 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 |
pcardune | The 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 |
pcardune | So, log in to the ZMI and try this stuff out | 20:53 |
pcardune | you'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 add | 20:54 |
*** wrobel has joined #schooltool | 20:54 | |
pcardune | but we only want be able to add ZContact objects to the container | 20:54 |
pcardune | what we need is a constraint on the container that says we can only add the Zcontact object to it | 20:54 |
pcardune | open up the interfaces.py file | 20:54 |
pcardune | and you want to add this line to the IContactContainer interface: zope.app.container.constraints.contains(IContact) | 20:55 |
pcardune | don't forget to import zope.app.container.constraints at the top of the file | 20:56 |
pcardune | this says that the IContactContainer interface only allows things that implement IContact interface to be contained in something implementing IContactContainer | 20:57 |
pcardune | does that make sense? | 20:57 |
pcardune | it is probably still a little bit complicated to talk about everything in terms of interfaces | 20:57 |
pcardune | but this is how zope works | 20:57 |
pcardune | It's nearly 2, so we are going to stop hear | 20:58 |
pcardune | we'll do the other stuff in the user stories 2 weeks from now | 20:58 |
pcardune | if you have any questions at all, please stick around and ask them | 20:58 |
pcardune | remember that we don't have class next week | 20:58 |
wjohnsto | much respect for you, pcardune | 20:58 |
Mounika | thank you! | 20:59 |
filip101 | thanks | 20:59 |
*** Mounika has quit IRC | 20:59 | |
pcardune | your welcome | 20:59 |
Mattva01 | thanks | 20:59 |
tdoggette | Awesome. | 20:59 |
tdoggette | Jolly good show. | 20:59 |
*** cpcarey11 has quit IRC | 21:00 | |
*** nitromaster has left #schooltool | 21:02 | |
*** tdoggette has quit IRC | 21:02 | |
*** Preetam has left #schooltool | 21:03 | |
*** pcardune is now known as pcardune_away | 21:07 | |
*** filip101 is now known as filip101_at_lunc | 21:09 | |
*** Mattva01 has left #schooltool | 21:31 | |
*** filip101_at_lunc is now known as filip101 | 21:32 |
Generated by irclog2html.py 2.15.1 by Marius Gedminas - find it at mg.pov.lt!