Wednesday, May 14, 2008

New revision of example codes

It's interesting learning Zope. I should thankful for my mentor Adam Groszer for pointing out me the resources in detailed manner. Else I won't be able to catch them very soon. I here list some important resources.
1. http://wiki.zope.org/zope3/programmers_tutorial.pdf
2. http://www.muthukadan.net/docs/zca.pdf
3. http://www.benjiyork.com/quick_start/
4. http://wiki.zope.org/zope3/book.pdf
5. http://www.diveintopython.org

Release 9 of the learning program http://code.google.com/p/learningzope/source/browse/?r=9 is changed with simplified codings with the guidance of my mentor.

For an example in revision8 I have use following code to print organization, their students and mentors.

object = dbroot[key]
if isinstance(object,Organization):
print 'Organization name: ' + object.name
if (object.projects):
for i in range(0,len(object.projects)):
print '\t Project name: ' + object.projects[i].name
print '\t \t Mentor name: ' + object.projects[i].mentor.name
print '\t \t Student: ' + object.projects[i].student.name

But now same functionality is gain by following simple, nice looking code

for key in dbroot.keys():
object = dbroot[key]
object.printYourself()

with new function, printYourself() in suitable classes. Eg:

def printYourself(self):
print
'\t Project name: ' + self.name
print
'\t Mentor name: ' + self.mentor.name
print '\t Student name: ' + self.student.name

refer the http://code.google.com/p/learningzope/ for further information. Go through the revisions to understand the changes.

Enjoy!!!

No comments: