[Zope-dev] ZPatterns example update....

2000-12-28 Thread Steve Spicklemire



Hi Folks,

   The Dumb ZPatterns example is updated. Now there is some more
realistic object referencing going on, borrowing of code snippets
between Specialists and suchlike. There is also more in the way of
reasonable documentation, though everything is in flux, and it still
doesn't resemble a truly completed product. I just feel the need to
get things finished enough that I can stop thinking about them for a
while. ;-) In particular there the ToDos now hold references to Doer
and Deliverable, and no 'lists' are maintained. One thing I need to do
is to have these references automatically 'fixed' when a 'referred to'
entity is removed or modified in such a way that the link should be
broken that's for the next version. If I'm not careful.. it won't
be a 'simple' example anymore. There's got to be a line here somewhere
(in the sand?).

take care,
-steve


___
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] ZPatterns question

2000-12-28 Thread Steve Spicklemire


Hi Christian,

Well, nobody else answered that I saw... so I'll take a crack
at your questions 

 "CS" == Christian Scholz [EMAIL PROTECTED] writes:

CS Hi there!

CS Finally I managed to get a basic understanding of how to do
CS things with ZPatterns ;-) So seems quite cool :) (and
CS hopefully I find some time to write some basic howto about it)

CS But I have some little questions:

CS 1. Is it possible to retrieve the set of known IDs from a
CS specialist?  Or would I need to add my own method to it which
CS does this (and change it accordingly if I switch to another
CS storage method)?

If you store persistently you can use the Rack's method:

"defaultRack.getPersistentItemIDs()"

but a couple of notes: 1) this returns a BTree object, not a simple
list, so you can't iterate through it in DTML. You'll need to copy
it to a simple list for that.. and 2) If you change to a different
storage you'll need to create your own method (ZSQL Method?). What I've
found is that if you have a large number of objects you'll either want
to query a Catalog, or an SQL database to get Ids that match some criteria
that limit the number of hits to something that makes sense to display 
in a browser.

CS 2. Is it planned to provide something like a virtual folder
CS which acts like a normal object manager but is controlled via
CS ZPatterns (so actually something like Folder with Customizer
CS Support just without the "anchor" in ZODB.  (would also
CS require some mechanism asked for in 1.)

Hmmm... I'm not sure what you're after here. Why not just use
a Specialist? In what sense do you want it to be virtual?
(Are you looking for a dynamic traversal interface that 
would allow you to map URLs to objects that are managed by
ZPatterns? Can you give an example?)

CS 3. Is it possible to use ZPatterns also without some exta
CS ZClass defined in a Product? At least if I don't need methods
CS for my objects but simple want to define the attribute they
CS know.  Would be nice as I could then hold everything together
CS in one place (the specialist that is) without requiring to
CS install something also in the Products folder of the Control
CS Panel.

I believe you need to either create a Python subclass, or a ZClass
subclass of DataSkin. "Raw" DataSkins don't have the right permissions
to allow for TTW access. If you're creating a 'product' anyway... just
make a 'dummy' class that you can use for storage.

CS That's it for now, I will keep experimenting then.. :)

Good Luck!
-steve

CS cheers, Christian

CS -- Christian Scholz MrTopf@IRC COM.lounge
CS http://comlounge.net/ communication  design [EMAIL PROTECTED]

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


___
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] ZPatterns question

2000-12-28 Thread Steve Alexander

Steve Spicklemire wrote:

 
 CS 2. Is it planned to provide something like a virtual folder
 CS which acts like a normal object manager but is controlled via
 CS ZPatterns (so actually something like Folder with Customizer
 CS Support just without the "anchor" in ZODB.  (would also
 CS require some mechanism asked for in 1.)
 
 Hmmm... I'm not sure what you're after here. Why not just use
 a Specialist? In what sense do you want it to be virtual?
 (Are you looking for a dynamic traversal interface that 
 would allow you to map URLs to objects that are managed by
 ZPatterns? Can you give an example?)

Reading this just after reading the source to Specialists.py, I had a 
thought; and tried it out; and it works! :-)

You can use SkinScript to define __bobo_traverse__ for a particular kind 
of DataSkin in a Specialist.

For example:

   WITH SELF COMPUTE __bobo_traverse__=traversal_method

Then, define a method in the specialist (or rack) called 
traversal_method. I used a PythonScript, and gave it the parameter list 
"REQUEST, name".
Make your method return the appropriate object to traverse to from your 
DataSkin, depending on the name passed. Something like

   return getattr(container.path.to.somewhere, name)

That's the simple version, and it won't give the traversed-to object the 
correct context most of the time. To do that, I'd need to use an 
external method, and use the __of__ method to give the returned object 
an appropriate context.

However, it is a start, and proves that it can be done.

Take a look in the __bobo_traverse__ method of Specialists.py (from 
ZPatterns) for a good algorithm for traversal. The variable _marker is 
almost always a class attribute initialized to [], to make a unique 
object, as a sentinel.

--
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] ZPatterns question

2000-12-28 Thread Steve Alexander

Steve Alexander wrote:


   return getattr(container.path.to.somewhere, name)
 
 That's the simple version, and it won't give the traversed-to object the 
 correct context most of the time. To do that, I'd need to use an 
 external method, and use the __of__ method to give the returned object 
 an appropriate context.

However, if all you are doing is saying "does this object have the named 
attribute? if not, get it from another specialist", and you're using 
Specialist.getItem() to do the latter part, then the object you want 
comes ready-wrapped in the appropriate context, courtesy of the Rack 
that gives it to you!

-- 

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 )