Re: [Zope3-Users] PyWebOff

2006-03-20 Thread Stephan Richter
On Friday 03 March 2006 02:27, Shane Hathaway wrote:
 I've been assigned to present Zope in a local upcoming Python user group
 meeting.  As part of the assignment, I'm supposed to solve the PyWebOff
 challenge using Zope:

 http://pyre.third-bit.com/pyweb/challenge.html

 I'd like to do this using Zope 3.  However, I'm really struggling.  I
 feel like I must be using Zope 3 in a really dumb way, because the code
 so far is highly repetitive, completely dependent on Zope, and more XML
 than Python.  This is not going to go over well in the presentation.

 Can anyone tell me how to do this better with Zope 3?  Maybe my Zope 2
 experience is preventing me from seeing something obvious.  I've
 attached the __init__.py and configure.zcml that I created in a package
 called challenge.

The problem here is that this challenge does some very standard things. It 
does not require real programming. Thus you end up with more ZCML than you 
might think. In my experience with SchoolTool, I learned that I spend for 
more time developing Python (and developing doctests for that code) than 
writing ZCML.

As you have probably seen from the recent discussions, Zope 3 does not scale 
down well. I think once the new AGX is done (which will support Zope 3), then 
this task will be a matter of developing a UML model.

Sorry, but I do not have a better answer.

Regards,
Stephan
-- 
Stephan Richter
CBU Physics  Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] PyWebOff

2006-03-20 Thread Bernd Dorn


On 03.03.2006, at 08:27, Shane Hathaway wrote:


Hello,

I've been assigned to present Zope in a local upcoming Python user  
group meeting.  As part of the assignment, I'm supposed to solve  
the PyWebOff challenge using Zope:


http://pyre.third-bit.com/pyweb/challenge.html

I'd like to do this using Zope 3.  However, I'm really struggling.   
I feel like I must be using Zope 3 in a really dumb way, because  
the code so far is highly repetitive, completely dependent on Zope,  
and more XML than Python.  This is not going to go over well in the  
presentation.


Can anyone tell me how to do this better with Zope 3?  Maybe my  
Zope 2 experience is preventing me from seeing something obvious.   
I've attached the __init__.py and configure.zcml that I created in  
a package called challenge.


Shane

from zope.interface import Interface, implements
from zope.schema import Field, TextLine, Int, Date
from zope.app.container.interfaces import IContained, IContainer
from zope.app.container.constraints import ItemTypePrecondition
from zope.app.container.constraints import ContainerTypesConstraint
from zope.app.container.btree import BTreeContainer


class IBook(Interface):
title = TextLine(title=u'title')
year = Int(title=u'year')
authors = TextLine(title=u'authors')

class ILoan(Interface):
username = TextLine(title=u'username')
day = Date(title=u'day')

class ILibrary(IContainer):
def __setitem__(name, object):
pass
__setitem__.precondition = ItemTypePrecondition(IBook, ILoan)

class IBookContained(IContained):
__parent__ = Field(
constraint = ContainerTypesConstraint(ILibrary))

class ILoanContained(IContained):
__parent__ = Field(
constraint = ContainerTypesConstraint(ILibrary))

class Book(object):
implements(IBook, IBookContained)

class Loan(object):
implements(ILoan, ILoanContained)

class Library(BTreeContainer):
implements(ILibrary)



if you use v 3.2 then you should use
from zope.app.container.constraints import contains, containers  
instead of the precondition stuff, so you don't need  
that ...Contained interfaces, because you can define the interfaces  
as strings


well, this just reduces the python code, but looks much cleaner

e.g.

class IBook(IContained):

title = TextLine(title=u'title')
year = Int(title=u'year')
authors = TextLine(title=u'authors')

containers('challange.interfaces.ILibrary')













___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] PyWebOff

2006-03-20 Thread Jeff Shell
Argh. Darn that user group meeting being down in Utah Valley. Don't
they consider the fact that there may be Utahn's who still try to
cling to a car-free urban lifestyle notion (especially when they live
and work on the same block)? :) Tell them to come up by my house.
Terrific restaurants, delis, italian markets, etc. Some of the best
Thai food in the city...

Anyways, it's too late to help you for the user group meeting in
question, but I'd like to take this on as a personal little challenge,
seeing if I can come up with a more interesting and pleasing to the
Python developer solution. Maybe you can show it next month as an
alternate option?

On 3/3/06, Shane Hathaway [EMAIL PROTECTED] wrote:
 Hello,

 I've been assigned to present Zope in a local upcoming Python user group
 meeting.  As part of the assignment, I'm supposed to solve the PyWebOff
 challenge using Zope:

 http://pyre.third-bit.com/pyweb/challenge.html

 I'd like to do this using Zope 3.  However, I'm really struggling.  I
 feel like I must be using Zope 3 in a really dumb way, because the code
 so far is highly repetitive, completely dependent on Zope, and more XML
 than Python.  This is not going to go over well in the presentation.

 Can anyone tell me how to do this better with Zope 3?  Maybe my Zope 2
 experience is preventing me from seeing something obvious.  I've
 attached the __init__.py and configure.zcml that I created in a package
 called challenge.

 Shane


 configure xmlns=http://namespaces.zope.org/zope;
   xmlns:browser=http://namespaces.zope.org/browser;

 content class=.Book
 require
   permission=zope.View
   interface=.IBook
   /
 require
   permission=zope.ManageContent
   set_schema=.IBook
   /
 /content

 content class=.Loan
 require
   permission=zope.ManageContent
   interface=.ILoan
   /
 require
   permission=zope.ManageContent
   set_schema=.ILoan
   /
 /content

 content class=.Library
 require
   permission=zope.ManageContent
   interface=.ILibrary
   /
 require
   permission=zope.ManageContent
   set_schema=.ILibrary
   /
 /content

 browser:addform
   name=addlibrary
   schema=.ILibrary
   content_factory=.Library
   permission=zope.ManageContent
   /

 browser:addMenuItem
   class=.Library
   permission=zope.ManageContent
   view=addlibrary
   title=Library
   /

 browser:containerViews
   for=.ILibrary
   index=zope.View
   contents=zope.View
   add=zope.ManageContent
   /

 browser:addform
   name=addbook
   schema=.IBook
   content_factory=.Book
   permission=zope.ManageContent
   /

 browser:addMenuItem
   class=.Book
   permission=zope.ManageContent
   view=addbook
   title=Book
   /

 browser:editform
   schema=.IBook
   permission=zope.ManageContent
   menu=zmi_views
   title=Edit
   name=edit
   /

 browser:addform
   name=addloan
   schema=.ILoan
   content_factory=.Loan
   permission=zope.ManageContent
   /

 browser:addMenuItem
   class=.Loan
   permission=zope.ManageContent
   view=addloan
   title=Loan
   /

 browser:editform
   schema=.ILoan
   permission=zope.ManageContent
   menu=zmi_views
   title=Edit
   name=edit
   /

 /configure


 ___
 Zope3-users mailing list
 Zope3-users@zope.org
 http://mail.zope.org/mailman/listinfo/zope3-users






--
Jeff Shell
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] PyWebOff

2006-03-20 Thread Shane Hathaway

Jeff Shell wrote:

Argh. Darn that user group meeting being down in Utah Valley. Don't
they consider the fact that there may be Utahn's who still try to
cling to a car-free urban lifestyle notion (especially when they live
and work on the same block)? :) Tell them to come up by my house.
Terrific restaurants, delis, italian markets, etc. Some of the best
Thai food in the city...


Well, as for me and a couple other regular attendees, the meeting is 
about 50 feet away from work. ;-)



Anyways, it's too late to help you for the user group meeting in
question, but I'd like to take this on as a personal little challenge,
seeing if I can come up with a more interesting and pleasing to the
Python developer solution. Maybe you can show it next month as an
alternate option?


I would be happy to present your solution.  I think they'd be happy to 
see it, too.


Shane
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] PyWebOff

2006-03-03 Thread Tom Dossis

Shane Hathaway wrote:

Hello,

I've been assigned to present Zope in a local upcoming Python user group 
meeting.  As part of the assignment, I'm supposed to solve the PyWebOff 
challenge using Zope:


http://pyre.third-bit.com/pyweb/challenge.html

I'd like to do this using Zope 3.  However, I'm really struggling.  I 
feel like I must be using Zope 3 in a really dumb way, because the code 
so far is highly repetitive, completely dependent on Zope, and more XML 
than Python.  This is not going to go over well in the presentation.


Can anyone tell me how to do this better with Zope 3?  Maybe my Zope 2 
experience is preventing me from seeing something obvious.  I've 
attached the __init__.py and configure.zcml that I created in a package 
called challenge.



I agree, the __init__.py and configure.zcml are pretty dry reading.

I reckon you could start your PUG presentation from the end (so to 
speak) by presenting one (or more) doctests.


One you have your captive audience, then go the the start.

Take a Test-Driven-Development approach.
It's easy to disgest an application (and zope) in test case sizes.
And as each need arise, bring in the appropriate ZCML to showcase it value.

This may help distill the python, zope and zcml.

-Tom
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] PyWebOff

2006-03-02 Thread Shane Hathaway

Hello,

I've been assigned to present Zope in a local upcoming Python user group 
meeting.  As part of the assignment, I'm supposed to solve the PyWebOff 
challenge using Zope:


http://pyre.third-bit.com/pyweb/challenge.html

I'd like to do this using Zope 3.  However, I'm really struggling.  I 
feel like I must be using Zope 3 in a really dumb way, because the code 
so far is highly repetitive, completely dependent on Zope, and more XML 
than Python.  This is not going to go over well in the presentation.


Can anyone tell me how to do this better with Zope 3?  Maybe my Zope 2 
experience is preventing me from seeing something obvious.  I've 
attached the __init__.py and configure.zcml that I created in a package 
called challenge.


Shane

from zope.interface import Interface, implements
from zope.schema import Field, TextLine, Int, Date
from zope.app.container.interfaces import IContained, IContainer
from zope.app.container.constraints import ItemTypePrecondition
from zope.app.container.constraints import ContainerTypesConstraint
from zope.app.container.btree import BTreeContainer


class IBook(Interface):
title = TextLine(title=u'title')
year = Int(title=u'year')
authors = TextLine(title=u'authors')

class ILoan(Interface):
username = TextLine(title=u'username')
day = Date(title=u'day')

class ILibrary(IContainer):
def __setitem__(name, object):
pass
__setitem__.precondition = ItemTypePrecondition(IBook, ILoan)

class IBookContained(IContained):
__parent__ = Field(
constraint = ContainerTypesConstraint(ILibrary))

class ILoanContained(IContained):
__parent__ = Field(
constraint = ContainerTypesConstraint(ILibrary))

class Book(object):
implements(IBook, IBookContained)

class Loan(object):
implements(ILoan, ILoanContained)

class Library(BTreeContainer):
implements(ILibrary)
configure xmlns=http://namespaces.zope.org/zope;
  xmlns:browser=http://namespaces.zope.org/browser;

content class=.Book
require
  permission=zope.View
  interface=.IBook
  /
require
  permission=zope.ManageContent
  set_schema=.IBook
  /
/content

content class=.Loan
require
  permission=zope.ManageContent
  interface=.ILoan
  /
require
  permission=zope.ManageContent
  set_schema=.ILoan
  /
/content

content class=.Library
require
  permission=zope.ManageContent
  interface=.ILibrary
  /
require
  permission=zope.ManageContent
  set_schema=.ILibrary
  /
/content

browser:addform
  name=addlibrary
  schema=.ILibrary
  content_factory=.Library
  permission=zope.ManageContent
  /

browser:addMenuItem
  class=.Library
  permission=zope.ManageContent
  view=addlibrary
  title=Library
  /

browser:containerViews
  for=.ILibrary
  index=zope.View
  contents=zope.View
  add=zope.ManageContent
  /

browser:addform
  name=addbook
  schema=.IBook
  content_factory=.Book
  permission=zope.ManageContent
  /

browser:addMenuItem
  class=.Book
  permission=zope.ManageContent
  view=addbook
  title=Book
  /

browser:editform
  schema=.IBook
  permission=zope.ManageContent
  menu=zmi_views
  title=Edit
  name=edit
  /

browser:addform
  name=addloan
  schema=.ILoan
  content_factory=.Loan
  permission=zope.ManageContent
  /

browser:addMenuItem
  class=.Loan
  permission=zope.ManageContent
  view=addloan
  title=Loan
  /

browser:editform
  schema=.ILoan
  permission=zope.ManageContent
  menu=zmi_views
  title=Edit
  name=edit
  /

/configure
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users