Re: [Zope-dev] Quickie on ZPatterns ... I promise :)

2000-07-27 Thread Phillip J. Eby

At 09:15 AM 7/27/00 +0100, Steve Alexander wrote:
>Bill Anderson wrote:
>> 
>> Let's say I have an object I will store in a rack. Let us say I want
this object to be
>> cataloged in a ZCatalog. Any caveats I need to know about
>> ..such as "Don't do that!" ?
>> ?;^)=
>
>Make one of the object's base-classes DataSkin.
>
>Don't make it CatalogAware.
>
>Use triggers to index and unindex the object from a catalog. You'll
>probably want to store the catalog in Specialist.
>
>By the way, Phillip Eby has released a new development snapshot:
>
> 
>http://www.zope.org/Members/pje/ZPatterns/ZPatterns-0-4-1snap1.tgz/view
>
>I'll be trying it later today.
>

FYI, the snapshot really only adds proxy roles support for generic
providers/triggers, and adds a first-cut version of SkinScript.  If you're
adventurous, you can look at SkinScript/Compiler.py and have a look at the
grammar in order to figure out what the language does.  So far I've
successfully tested a SkinScript method that does the work of four
GenericAttributeProviders and two GenericTriggers, just by using the
appropriate statements.  Here's a SkinScript snippet you might use for
CatalogAwareness:

WHEN OBJECT ADDED 
CALL somecatalog.catalog_object(self)

WHEN OBJECT CHANGED
CALL somecatalog.recatalog_object(self)

WHEN OBJECT DELETED
CALL somecatalog.uncatalog_object(self)

(Replace the incorrect catalog API calls with ones that are correct...  I'm
sure I'm missing some parameters and probably getting the names wrong...)

Note that "somecatalog" must be in the acquisition context of the
SkinScript method itself.  If you want to use a catalog in the context of
the DataSkin, you need to say "self.somecatalog...".

Some other SkinScript snippets:

# Store attribs persistently - replaces 
# Persistent Internal Attribute Provider
STORE attrib1,attrib2 IN SELF

# Computed attributes
WITH SELF COMPUTE 
  attrib1=attrib2+attrib3,
  attrib4=attrib6*10

# Generic attrib provider
WITH (SomeSQLMethod(key=self.id) or [NOT_FOUND])[0] COMPUTE
  field1, field2, somefield=field3+field4,
  fancy_id = '*(%s%s)%' % (otherfield,self.id)

# Generic trigger
WHEN OBJECT ADDED,CHANGED,DELETED
CALL someexpr(self.id)
SAVING foo,bar, baz=spam, widget=diddly+id

# Attribute provider
STORE attr1,attr2
USING somefunc(self)
SAVING attr1,attr2

# Conditional attrib provider
WHEN OBJECT ADDED
STORE attr2
USING otherfunc(self)

That about covers it for what's implemented so far.  The goal is to
ultimately replace the majority of providers and triggers with SkinScript.
But it will still be possible to write and use custom plug-ins that provide
attributes or handle events in other ways.  But SkinScript will be quite
handy for most things.


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] Quickie on ZPatterns ... I promise :)

2000-07-27 Thread Bill Anderson

Itamar Shtull-Trauring wrote:
> 
> Bill Anderson wrote:
> >
> > Let's say I have an object I will store in a rack. Let us say I want this object 
>to be
> > cataloged in a ZCatalog. Any caveats I need to know about
> > ..such as "Don't do that!" ?
> > ?;^)=
> 
> You can't have them inherit from CatalogAware, you'll need to use a trigger
> that does this for you.  I'm uploading a Product that gives this capability
> - and unlike CatalogAware, it recatalogs *automatically* whenever the object
> changes.  No more object_reindex! (I only tested extensively with DataSkins,
> though).
> 
> http://www.zope.org/Members/itamar/ZPAddons

Cool! I'll check it out today/tomorrow.



Now if only I could figure out how to change user.__roles in Membership, I'd have a 
really
cool Memebrship Release ready :-)

--
Do not meddle in the affairs of sysadmins, for they are easy to annoy,
and have the root password.

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] Quickie on ZPatterns ... I promise :)

2000-07-27 Thread Bill Anderson

Steve Alexander wrote:
> 
> Bill Anderson wrote:
> >
> > Let's say I have an object I will store in a rack. Let us say I want this object 
>to be
> > cataloged in a ZCatalog. Any caveats I need to know about
> > ..such as "Don't do that!" ?
> > ?;^)=
> 
> Make one of the object's base-classes DataSkin.
> 
> Don't make it CatalogAware.

that was my hunch ...

> 
> Use triggers to index and unindex the object from a catalog. You'll
> probably want to store the catalog in Specialist.

OK, guess it's sime to learn triggers ;-)

> 
> By the way, Phillip Eby has released a new development snapshot:
> 
> 
> http://www.zope.org/Members/pje/ZPatterns/ZPatterns-0-4-1snap1.tgz/view
> 
> I'll be trying it later today.

Likewise.

Gotta see how/if it works with membership.

> 
> --
> Steve Alexander
> Software Engineer
> Cat-Box limited
> http://www.cat-box.net

--
Do not meddle in the affairs of sysadmins, for they are easy to annoy,
and have the root password.

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] Quickie on ZPatterns ... I promise :)

2000-07-27 Thread Steve Alexander

Bill Anderson wrote:
> 
> Let's say I have an object I will store in a rack. Let us say I want this object to 
>be
> cataloged in a ZCatalog. Any caveats I need to know about
> ..such as "Don't do that!" ?
> ?;^)=

Make one of the object's base-classes DataSkin.

Don't make it CatalogAware.

Use triggers to index and unindex the object from a catalog. You'll
probably want to store the catalog in Specialist.

By the way, Phillip Eby has released a new development snapshot:

 
http://www.zope.org/Members/pje/ZPatterns/ZPatterns-0-4-1snap1.tgz/view

I'll be trying it later today.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] Quickie on ZPatterns ... I promise :)

2000-07-27 Thread Itamar Shtull-Trauring

Bill Anderson wrote:
> 
> Let's say I have an object I will store in a rack. Let us say I want this object to 
>be
> cataloged in a ZCatalog. Any caveats I need to know about
> ..such as "Don't do that!" ?
> ?;^)=

You can't have them inherit from CatalogAware, you'll need to use a trigger
that does this for you.  I'm uploading a Product that gives this capability
- and unlike CatalogAware, it recatalogs *automatically* whenever the object
changes.  No more object_reindex! (I only tested extensively with DataSkins,
though).

http://www.zope.org/Members/itamar/ZPAddons

-- 
Itamar S.T.  [EMAIL PROTECTED]
Fingerprint = D365 7BE8 B81E 2B18 6534  025E D0E7 92DB E441 411C

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




[Zope-dev] Quickie on ZPatterns ... I promise :)

2000-07-27 Thread Bill Anderson

Let's say I have an object I will store in a rack. Let us say I want this object to be
cataloged in a ZCatalog. Any caveats I need to know about
..such as "Don't do that!" ? 
?;^)=


Bill

--
Do not meddle in the affairs of sysadmins, for they are easy to annoy,
and have the root password.

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )