[Zope] ANNOUNCE: An easier way to write products

Luis Cortes ads@conquered.org
Mon, 14 Jan 2002 09:17:54 -0700


I too think that zope needed this class at the beginning.  It has been way
too hard to create products through python and zope for too long.

Can I make a few suggestions:

I am an old hacker ( maybe even unemployable ), but I remember in C we used
to wrap data structures around macros.  Now in python, there aren't really
any macros unless you consider the lamba function a type of one, but maybe
you can add to your class simple methods like the following:


set_meta_type( typename )
set_constructors( ... )
set_properties( name, type, mode )
set_roles( list_roles )
set_users( list_users )


Then a new class definition might look a lot clean and less error prone,
i.e.:

for mxm import mxmSimpleItem

class easyArticle( mxmSimpleItem.mxmSimpleItem ):

  set_meta_type( 'EasyArticle')

  set_property( 'title','string','w' )

# or better yet .....

  set_property( 'summary', mxm.TYPE_TEXT, mxm.PROPERTY_PERMISSION_WRITE )
  set_property( 'content', mxm.TYPE_TEXT, mxm.PROPERTY_PERMISSION_WRITE )
  set_property( 'author', mxm.TYPE_STRING, mxm.PROPERTY_PERMISSION_WRITE )

# and if you want to be really cool .. you can have default values for
properties
# like TYPE_STRING and PERMISSION_WRITE to make things easier for use old
folks ;-).

One more thing, maybe this is obvious -- but a simple example of inheritence
from something like catalog aware base class where of course, the base
catalog class is first.

Thanks for the maxm class,
nice job,
Luis.




----- Original Message -----
From: "maxm" <maxm@mxm.dk>
To: <zope@zope.org>
Sent: Thursday, January 10, 2002 4:13 AM
Subject: [Zope] ANNOUNCE: An easier way to write products


> It has long bothered me to no end that when I write Python based products
> that there was a lot of repeat code. Thus violating the DRY pinciple
(Don't
> Repeat Yourself).
>
> Also it has been to difficult to get started with a new product, with too
> many things that had to be just rigth to get going. So you have had to
take
> one of your old products an do extensive searh and replace to get going.
> Thats a bother.
>
> So I have made two simple classes encapsulating my best practices in
writing
> products. They make it REALLY simple to get a product up and running, and
> has no penalty as such.
>
> One class is for making simple products with content. Like articles, user
> info, Issues, animal info;-) etc.
>
> The other class is for making ObjectManagers. They behave like an item,
but
> can contain other objects. So it's folder like.
>
> I believe that this kind of functionality should have been built into Zope
> to begin with, as it would solve the beginner problems for 90% of the
people
> trying to create Python products.
>
> Thus flattening the "Z" shaped learning curve.
>
> More info here:
>
> http://www.zope.org/Members/maxm/HowTo/easyProduct
>
> regards Max M
>
>
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )
>
>
>