IRC log of #schooltool for Saturday, 2007-03-10

*** didymo has quit IRC00:00
*** jfroche_ has quit IRC01:36
*** filip101 has joined #schooltool02:25
*** filip101 has left #schooltool02:25
*** wrobel has quit IRC03:22
*** wjohnsto has quit IRC05:54
*** wjohnsto has joined #schooltool05:54
*** wjohnsto has quit IRC06:07
*** wjohnsto has joined #schooltool06:08
*** didymo has joined #schooltool08:07
*** Fujitsu has quit IRC11:30
*** Fujitsu has joined #schooltool11:31
*** jinty has joined #schooltool12:53
*** Fujitsu has quit IRC13:20
*** Fujitsu has joined #schooltool13:28
*** wrobel has joined #schooltool14:08
*** pcardune has joined #schooltool16:32
*** filip101 has joined #schooltool16:36
wjohnstopcardune: Are you there?17:22
pcardunewjohnsto: yes17:23
wjohnstoDo we use the rotterdam as our standard skin for the Zope3 class?17:36
wjohnsto** rotterdam skin17:36
*** jinty has quit IRC17:36
*** mlinnell has joined #schooltool18:34
*** filip101 has quit IRC18:35
*** bnguyen has joined #schooltool18:39
*** tehminkeh has joined #schooltool18:48
*** filip101 has joined #schooltool18:50
*** jelkner has joined #schooltool18:52
*** KP202 has joined #schooltool18:52
*** tiredbones has quit IRC18:54
*** KP202 has quit IRC18:55
*** filip101 has left #schooltool18:57
tehminkehis there class today?18:58
jelkneri talked to the teacher yesterday18:59
jelknerand he is planning on class today18:59
*** filip101 has joined #schooltool18:59
jelknerpcardune: morning teach!19:00
* jelkner is Jeff E.19:01
pcardunejelkner: Hi jelkner19:01
pcardunehi everybody19:01
* filip101 is Filip S.19:01
*** Preetam has joined #schooltool19:01
* mlinnell is Mary L19:01
* Preetam is Preetam D.19:02
* bnguyen is Brittney N19:02
* tehminkeh is Stephen Drodge19:02
jelknerhmm... where is everyone else?19:02
jelkneronly five people here so far?19:03
*** AVN` has joined #schooltool19:03
pcardunethere is one more19:03
* AVN` is Chris Beacham19:03
jelknerOK, I'll start with announcements19:03
jelknernext Saturday is the monthy sprint19:04
jelknerseveral folks have said they are coming19:04
jelknerit will be a good opportunity to get internship agreements processed19:04
jelknerif you didn't receive an internship agreement last weekend, and will be home tomorrow afternoon between 4 and 6 pm19:05
jelknersend me an email with your phone number and I'll call you tomorrow.19:05
jelknerThat's all I have to say,19:05
jelknerI'm looking forward to seeing everyone's homework19:06
jelknertake it away, pcardune19:06
pcarduneOk, first thing first, did any of you add any features from what we did last week?19:06
pcarduneif so, start up your server and send us all a link showing what you did19:06
*** smalekgh has joined #schooltool19:07
smalekghsorry I'm late, orthodontist went overtime19:07
* smalekgh is Masood M.19:07
pcarduneorthodontists sure can be a pain19:07
smalekgh<_< not in themselves, but I guess.19:07
jelknerbnguyen: I know you have something to show us, I saw it yesterday ;-)19:07
pcardunesmalekgh: we are just about to look at improvements people made over the week19:08
bnguyenwell we made ours look better19:08
pcardunesmalekgh: if you have something to show, send us a link19:08
smalekghum, what if I don't have much to show? As in, it's just what we've been doing over the lessons and I haven't done much to append to that?19:09
pcardunebnguyen: that looks pretty wild19:09
pcardunesmalekgh: that's fine too19:09
bnguyeni'll take that as a compliment19:09
pcarduneI'm glad you did that because today your are going to learn how to do it the zope3 way19:10
pcardunewell, if that's all people have to show, then we will move on to today's lesson19:11
smalekghuh, I'll send the link privately methinks19:11
smalekghstill waiting for server startup <_<19:11
pcarduneoh ok19:11
pcardunebnguyen: by the way, that was a compliment.  I generally like darker themes.  The default zope one is to corporate looking for my tastes (reminds me too much of microsoft's website)19:13
* wjohnsto is William Johnston19:14
pcarduneOn that note, today we are going to learn how to develop custom skins for our application.19:14
jelknerI was greatly looking forward to this show and tell19:14
jelknerwe will do it each week from now on19:14
wjohnstoSweet he liked our show and tell!19:14
jelknerwe need to find out where you all are at in the learning process19:15
pcarduneSo far we have been using the ZMI to control our application, even though the ZMI provides much more functionality than we want.19:15
pcarduneSo for the sake of our end users, we want to create our own simplified version of the ZMI that only has the functionality we require.19:15
jelknerit is very important that you can demonstrate understanding of the class content19:15
jelknerplease have something to show next week19:16
jelknerif you are stuck, you should be mailing in questions19:16
jelknerok, I'll stop now ;-)19:16
smalekghstuck is a relative term <_<19:16
jelknersmalekgh: meaning?19:16
smalekghdifferent magnitudes of being stuck. There's the stuck that takes two seconds and the stuck that takes 3 days but results in the sense of eureka-ness19:17
jelknersmalekgh: if you only have a limited time to work on this, then get as far as you can, and ask questions freely19:17
jelknerwe are interested in your ability to make things work19:18
smalekghI think I'll be quiet now.19:18
pcarduneanyway... skins can be a somewhat complicated topic because the skinning architecture has several different parts that interact with each other to provide flexible skinning capabilities.19:18
pcarduneThe first and somewhat all-encompassing part of skinning is a layer.19:18
pcarduneI like to think of layers as boxes that can contain a bunch of stuff, including other boxes. Primarily, the boxes/layers hold things we want to display on our web page.19:20
pcarduneThese things or what we might call resources, can be anything from images to stylesheets to files to special views and macros.19:20
*** jelkner has quit IRC19:21
pcarduneAlthough we have not used it yet, the configuration tags used to create pages and resources take an optional layer attribute which can be used to specify which layer they are in (or which box they are in).19:21
pcardunedoes that kind of make sense to people so far?19:21
mlinnellsorta, yeah19:22
pcarduneThe first part of this lesson is going to be some detailed eplanation of the skinning architecture19:22
pcarduneplease ask questions if you have them19:22
pcarduneand wjohnsto has setup a teamspeak server if you are interested in using that to ask questions...19:22
pcarduneto continue, having multiple layers is especially useful when we have things like mutliple skins.19:22
pcarduneImagine having a web application that was used by a bunch of different schools. Each school is going to want their own logo to appear in the application. Since we don't want to worry about all the different logos when writing the application, we simply create new layers for each of the schools. Then we can put a different logo image or stylesheet or anything into each of the schools' layer.19:23
pcarduneThen when the school logs in, zope will look up the logo image in the layer for that school.19:23
mlinnellwhat's the difference between a layer and a skin?19:24
pcardunethat is a good question19:24
pcardunein zope terminology, there is a subtle difference19:25
pcardunebut essentially, a layer is what you might think of as a "skin" in a more generic sense19:25
AVN`so can you have multiple layers?19:25
AVN`at the same time19:25
pcarduneThe really interesting part about layers is that they can inherit from other layers (like having boxes inside boxes). Then if zope doesn't find a logo image in a certain layer, it will look in the parent layers too. This way we could have a default logo if the school did not provide their own.19:25
AVN`oh cool19:26
filip101so they sort of work like Java inheritance19:26
pcardunefortunately though, since we aren't planning on deploying Z Contact with a bunch of different looks, we only need to create one layer.19:26
pcarduneor like python inheritance19:26
filip101where it keeps the old value and overwrites if you mention a new one19:26
filip101oh yeah... >_>19:27
pcarduneThe other part of skinning with Zope3 is an actual skin itself.19:27
pcarduneand this case, i am talking about what is technically a "skin" in zope319:27
pcarduneIn Zope terminology, the skin is what figures out which layer to use.19:27
pcarduneRemember how each school would see a different layer? We have to be able to tell Zope which layer to use and that is done with a skin.19:28
pcarduneThe skin is in fact just a marker that gets attached to the request object (the users HTTP request from their web browser). Then when zope inspects the request object, it sees this special marker and looks for resources or views in one of the layers specified by the skin.19:28
pcardunedoes that sort of make sense to people19:29
smalekgh... like a C pointer?19:29
pcardunenot quite19:29
pcarduneit is actually done using interfaces19:29
smalekghso it's like a pointer to virtual classes?19:29
pcarduneremember how an instace of a class can provide an interface?19:30
pcarduneand how you declare that it provides a given interface in the class definition?19:30
pcarduneAVN`: i'm referring to the implements(zcontact.interfaces.IContact) line from the Contact class19:31
smalekghit's that thing where you say it provides yadda yadda and you can query it with some interface provided by yadayada19:31
pcardunewell you can make an object provide an interface outside of a class definition19:31
pcarduneSo, zope is going to take this request object, and make it provide a certain interface (which defines our skin), and based on that it will be able to do the proper resource lookups19:32
pcarduneIt's like adding a type to an object (except you can't do that in any programming language I'm aware of)19:33
pcarduneYou might think of it as adding inheritance on the fly19:33
pcardunewhich sounds pretty crazy19:33
AVN`so its kinda like casting?19:34
AVN`only permanant19:34
smalekghit's like casting an actual type, not even a reference <_< and without actually copying the item in question19:34
pcardunelike casting, but the request object still maintains it's old types19:34
pcardunebecause with interface, an object can have multiple types19:34
pcardunewe'll look at an example soon enough19:35
pcarduneIn the simplest case (which is our case), we are only going to have one layer and one skin.19:35
pcarduneThe way that skins specify which layers should be looked in for a given resource is by inheritance. That is, if our skin wants to tell zope to look in layers A, B, and C, then the interface defining our skin would inherit layers A, B, and C (just like normal python inheritance).19:36
pcarduneThis means that skins are actually layers too. You might think of them as a grouping of other layers.  (remember the question, "what's the difference between a layer and a skin...")19:36
pcarduneSo enough talk, let's get to creating our skin. As I said earlier, skins are just marker interfaces. So open up the file and create an interface called IZContactSkin.19:37
pcarduneNow, the only layer we want to inherit from is the default layer. The default layer is the layer that things get registered for when you don't specify a layer in the configuration tag.19:38
pcarduneAt the moment, all our pages, and all of zope's views as well, are registered on this default layer.19:38
smalekghso, it's just a regular old interface, no bells and whistles interface inhertance like the container interface?19:40
AVN`What is the name of the default interface?19:40
smalekghzope.interface.Interface methinks19:40
smalekghoh, oops, wrong question19:40
AVN`oh wait, I meant default layer19:41
pcarduneAt the moment, all our pages, and all of zope's views as well, are registered on this default layer. And even though we are writing our own custom skin, we will still want to be able to use a lot of the views zope provides for us (which live in the default layer).19:41
pcardunemy interface definition looks like this: class IZContactSkin(zope.publisher.interfaces.browser.IDefaultBrowserLayer):19:42
pcardune    """The ZContact skin."""19:42
pcarduneThat's it. That is our skin. So any request object that provides the IZContactSkin interface will use our skin.19:42
pcarduneSo how does a request object go about providing this interface? Well, zope has this handy thing called a traversal adapter.19:43
pcarduneI won't explain how those work yet, but essentially it allows us to specify which skin to use through the url.19:43
pcarduneThis is what the url would look like: http://localhost/++skin++ZContact/path/to/whatever.19:43
pcarduneWhen zope traverses this url, that is, when zope looks up the url, it will see the ++skin++ part and know that what follows is the name of the skin to use. It will then lookup the interface for that name, and make the request object provide that interface. Then zope machinery handles the rest.19:44
pcardunedoes that sort of make sense?19:44
pcardunedoes everyone know what I mean by "Traversal"?19:44
Preetamnot exactly...19:45
smalekgha trek up inheritance hill?19:45
pcardunegood pun, but no not quite19:45
pcardunebut think about traversing across the united states19:45
pcarduneyou have a path, or a route, that says all the places you will go to in between19:45
mlinnellit's like when you go over something, you traverse it?19:46
pcardunefirst you go to new york, then chicago, the, Denver, then San Francisco19:46
pcardunethose are all parts of the path19:46
pcardunenow think of a url...19:46
pcardunea url *is* a path19:46
pcarduneand it is traversed in the same way19:46
pcardunefirst it looks at the first part of the url (which is ++skin++ZContact)19:46
pcardunezope says to itself "oh! there they are asking for a custom skin called ZContact"19:47
pcardunezope looks up that skin, applies it to the request object, then continues traversing19:47
smalekghso, can you skin things differently throughout the url?19:48
pcarduneit goes to the next part in the url (in the example above that would be "path") and then tries to look up the "path" object in the root directory19:48
AVN`and if it can't find that skin?19:48
pcarduneif it can't find that skin then you get a page not found error19:48
pcardunejust like if you are traversing the United states, and you cant find New York, you are in big trouble19:48
pcardunethere is no way you will make it to san francisco19:48
AVN`what if the request object isn't able to implement the skin19:49
pcardunebut why wouldn't it be able to do that?19:49
pcarduneour skin interface doesn't ask for any attributes or methods19:49
AVN`oh, ok19:49
pcardune*any* class would succeed in implementing that interface19:49
pcardunethat is why it is called a "marker interface"19:50
smalekghso, can you skin things differently throughout the url?19:50
pcarduneso a traversal adapter is just a customization of the normal way zope traverses a url19:50
pcardunewhich makes url handling *very* *rediculously* flexible19:51
lisppaste5wjohnsto pasted "" at
smalekghyou make it sound almost unfair.19:51
pcardunethink of some of the web applications you use where part of a url is a long alphnumeric string like AEF37E372BDC738....19:52
pcardunethose web applications are not serving up a file with that name... rather they decode that long string and turn it into something useful... then serve up whatever it is you are looking for19:52
smalekghlike logging in to gmail, that uber long php/js/whatever it is thinger at the end?19:52
pcarduneyou can make zope do that too19:53
pcarduneNow that you know what I mean be "traversal", lets add some configuration19:53
pcarduneTo give our skin a name so it can be accessed through the URL, we have to register it in our configure.zcml file. Open up configure.zcml and add the following tag:19:53
pcardune  <interface19:54
pcardune      interface="zcontact.interfaces.IZContactSkin"19:54
pcardune      type="zope.publisher.interfaces.browser.IBrowserSkinType"19:54
pcardune      name="ZContact"19:54
pcardune      />19:54
pcarduneThis tells zope that the skin we made is in fact a skin (that is the IBrowserSkinType part) and that the skin can be looked up using the name ZContact.19:55
pcarduneWith that written, we can access our skin through a url. I would recommend restarting our zope server now and checking it out. Go to any place in the ZMI, then add ++skin++ZContact to the beginning of the url (just after the server:port) and see what the page looks like using our skin.19:56
pcardunesomeone should provide the rest of us with a link using that skin19:57
AVN`won't it look the same as without the skin?19:57
pcardunetry it19:57
AVN`cause we didn;t change anything?19:57
pcarduneyou will see when you try it out...19:58
smalekgh20 imaginary money units on there being nothing on the page19:58
pcarduneyou're on smalekgh19:59
AVN`lol, I think I will side with pcardune19:59
smalekghit appears I owe someone some imaginary money19:59
smalekghdoes the default browser interface actually have an implementation that the skin connects to?20:00
pcardunewhat happened here is that the views providing the look and feel of the normal interface are not registered for the default layer20:01
bnguyen ConfigurationError: ('Invalid value for', 'type', "ImportError: Couldn't import zope.publisher.interfaces.browser.IBrowser, No module named IBrowser")20:02
pcardunethey are registered in the Rotterdam layer (Rotterdam is the name of the default skin in zope... try ++skin++Rotterdam, there is also Basic, ZopeTop20:02
pcarduneand Boston20:02
AVN`why rotterdam?20:02
pcardunebnguyen: you want zope.publisher.interfaces.browser.IDefaultBrowserLayer20:03
smalekghcould you explain the last 23 words of that sentence on the view providing the look and feel not being registered, please?20:03
pcardunei'm not sure... maybe the person who designed the skin is from Rotterdam?20:03
pcardunewhat i mean by look and feel is a macro20:03
pcardunewe will do macros next20:03
AVN`oh zopetop is nice20:03
pcardunebut basically, the macro that gives us the rotterdam skin is in the rotterdam layer,20:04
pcardunesince our skin doesn't inherit from the rotterdam layer, we dont get to use any of rotterdam's macros20:04
pcardunethe default layer has the Basic skin20:05
pcarduneso that is what we see20:05
pcarduneSo now let's talk about macros20:05
pcarduneMacros are what people might normally think of when you say skin because it defines how and what things get layed out on the screen. It is the visual part of a skin.20:06
pcarduneMacros are defined in the same way that we create page templates. In fact, you might think of them as meta templates - templates for templates.20:06
pcarduneRemember in lesson 3 when we had the line <html metal:use-macro="context/@@standard_macros/view">? Most views in Zope use the view macro, which is specified in the standard_macros view.20:07
pcarduneSo if we want our skin to work with existing zope components, we will make our own standard_macros view, with our own view macro.20:09
pcarduneNotice that @@standard_macros is just a view lookup. Remember that a view is a lot like a page with a class and template. The first thing we need to do to create macros is add a standard_macros page to the new layer we created, IZContactSkin. So go back to your configure.zcml file and add the following lines:20:11
pcardune  <browser:page20:11
pcardune      for="*"20:11
pcardune      name="standard_macros"20:11
pcardune      template=""20:11
pcardune      permission="zope.View"20:11
pcardune      layer="zcontact.interfaces.IZContactSkin"20:11
pcardune      />20:11
pcardunedoes anyone have questions about this zcml registration?20:12
smalekgh* = all?20:12
smalekghlike the truncatable replaceable thingy in online databases?20:13
pcardunewe want this page to be available no matter what object we are looking at20:13
pcarduneNow we need to write the actual page template. As we specified in zcml, we need to create a new file called The first macro we want to create should be called view. Start by writing the following:20:15
pcardune<html metal:define-macro="view">20:16
pcarduneHello World For Macros!20:16
AVN`whats the metal for?20:16
pcarduneNotice that for anything involving macros, we use the metal namespace.20:16
pcardunemetal... think meta-tal20:17
*** wjohnsto has left #schooltool20:17
*** wjohnsto has joined #schooltool20:17
pcardunethe tal namespace provides attributes for plugging in bits of content, so the meta-tal namespace provides attribtues for plugging in bits of templates20:17
pcarduneNow restart your server and open up any page using this skin. You should get an empty screen that just says "Hello World For Macros!"20:18
pcarduneIf you look at the other page templates we have created, like, you will see other metal attributes, like metal:fill-slot. In our macro we can define slots where content will go.20:19
pcardunePage templates which use the macro can then fill those slots using the fill-slot attribute. To create a slot we use the define-slot attribute in our macro. So, we might want to add a default header to our macro, then present the information from the body slot.20:19
pcarduneEdit your file to look like this:20:20
pcardune<html metal:define-macro="view">20:20
pcardune  <head><title>ZContact</title></head>20:20
pcardune  <body>20:20
pcardune    <h1>Z Contact</h1>20:20
pcardune    <h4>The Hottest Contact Manager on the Planet</h4>20:20
pcardune    <hr />20:20
pcardune    <div metal:define-slot="body">20:20
pcardune      Hello World For Macros!20:20
pcardune    </div>20:20
pcardune  </body>20:20
pcarduneI'm going to give you all 10 minutes to play around with the macro20:24
pcarduneremember that you can put bits to tal in the amcro to20:24
pcardunetry putting <span tal:content="context" /> somewhere in the macro and see what happens20:25
smalekghyou don't have to restart the zope server after changing the .pts, right?20:26
smalekghis there any way to have a second putty window logged on to maddog while the other window runs zope, so I don't have to close zope in order to access the .pts?20:27
AVN`yes, you can do that20:27
pcardunejust open up another putty window :)20:27
smalekghit complained last time I tried <_<20:28
smalekghoh, wow20:28
AVN` so I tried <span tal thing, and I got a system error20:31
Preetami did the span thing and i got <security proxied instance at 0xf61fba08>20:32
pcardunePreetam: you got what you would should expect20:33
Preetamoh ok20:33
pcarduneAVN`: ask Preetam20:33
smalekghoh yay, more memory addresses20:33
pcardunethat is actually the context of the view20:33
pcardunetry context/__name__20:33
pcarduneor context/__parent__20:34
pcarduneand try looking at the skin from different views20:34
smalekghserver error occured when I tried to get the context/__name__20:34
pcardunetry looking at different views, it may work on other objects20:35
smalekghhow does zope handle a server 'error'? Is it really an 'error' or just something zope notices and decides not to pursue?20:37
pcarduneit is really an error20:37
pcardunei mean, the server wont crash like a normal program, because zope catches the errors, but it is a thrown python exception20:37
pcarduneyou can get the python traceback for the exception by looking at the terminal where zope is running20:38
AVN`yeah its a transversal error20:39
smalekghI'm actually starting to get semi-sick of the word 'traversal'...20:39
pcardunebut traversal is such a cool idea20:40
pcarduneok, well I want to finish one more thing before i let you guys go discover more about macros20:42
pcardunewe are going to want to use some cascading style sheets. Casecading style sheets present an excellent usecase for resources.20:42
pcarduneIn zope, a resource is just a file that lives on the server's file system, and not in Zope's object database. These might include CSS files, images, javascript libraries, and more. Since I generally use quite a number of resources in my web applications, I like to have a folder where I keep all the resources. So go ahead and create a new directory within zcontact called resources. Then we need to register this directory as containing a bu20:42
pcardunench of resources.20:42
smalekghwhat was the unix command for making a folder? mk-dir? dirmk?20:43
AVN`too late20:44
smalekghfinally, a spot of blue in a window of too many gray-text file-names >_<20:44
pcarduneopen up configure.zcml and add the following tag:20:45
pcardune  <browser:resourceDirectory20:45
pcardune      directory="resources"20:45
pcardune      name="zcontact_resources"20:45
pcardune      layer="zcontact.interfaces.IZContactSkin"20:45
pcardune      />20:45
pcarduneNow lets add a link to the css file in our html code:20:47
pcardune<link rel="stylesheet" type="text/css"20:47
pcardune          href="/@@/zcontact_resources/style.css"20:47
pcardune  tal:attributes="href context/++resource++zcontact_resources/style.css"/>20:47
pcardunethis would go in zcontactmacros.pt20:47
pcarduneinside the head tag20:47
pcardunehave all of you used cascading style sheets before?20:47's forum skinning count?20:47
pcarduneis it css?20:48
smalekghit looked big and made me fallover in dread... Yeah I believe so20:48
mlinnellyeah I've used CSS20:49
AVN`I never have20:49
pcardunewell it is a nice thing to learn when you are doing a bit of web development20:51
pcarduneit also isn't that hard at all20:51
pcardunemake your resources/style.css file look like this:20:52
pcardunebody {20:52
pcardune       padding: 1em;20:52
pcarduneh1 {20:52
pcardune    color: #f00;20:52
pcardunehr {20:52
pcardune    border: 1px dotted red;20:52
pcardunethen restart your zope server so the resources get loaded and take a look at the page again20:53
pcardunenow we have some nice colors20:53
smalekghAhhh! My eyes! They burrrnnn! The color hast turned reddened! But uh, where'd the border go?20:57
pcardunethe border is just that horizontal rule20:58
pcarduneso that is pretty much the end of class20:58
pcardunefor next week I want you guys to look into CSS a bit, and look at doing a few more things with macros20:58
filip101so we're getting to the fun visual stuff :)20:59
pcarduneLook at the ZPT reference on the zope website for more information on macros20:59
smalekghvisual? As in...20:59
pcarduneAlso, try adding new features20:59
smalekghMS Visual C++? THE EYES! THEY BURRRNNN20:59
smalekghoh, sorry.20:59
pcarduneShow off what you have learned so far20:59
pcarduneand if you have any questions at all, email me21:00
pcarduneor email the whole class21:00
pcarduneor both is best21:00
pcarduneif you email the class list then I will get the email too21:00
*** bnguyen has left #schooltool21:01
* smalekgh bows out21:01
smalekgh... I'll just clos the window manually then <_<21:01
*** smalekgh has left #schooltool21:01
Preetamalright, thanks!21:02
*** AVN` has left #schooltool21:02
*** Preetam has left #schooltool21:02
*** mlinnell has quit IRC21:02
*** tehminkeh has left #schooltool21:06
*** pcardune has quit IRC21:10
*** filip101 has left #schooltool21:13
*** th1a has quit IRC22:48
*** th1a has joined #schooltool22:50

Generated by 2.15.1 by Marius Gedminas - find it at!