Re: [Zope-dev] Specialists and __bobo_traverse__

2001-01-17 Thread Steve Alexander

Phillip J. Eby wrote:

   I'm pretty sure DTML methods *won't* work.  "Python Methods"
 might.  I don't know about external methods, python scripts, etc.


I have successfully used PythonScripts for this.


--
Steve Alexander


___
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] recent DynPersist.dll for windows

2001-01-17 Thread Steve Alexander

Hi Folks,

Does anyone have a recently compiled DynPersist.dll from ZPatterns, 
compiled for Windows ?

Thanks.

--
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] manage_changeProperties in a loop

2001-01-16 Thread Steve Alexander

Arno Gross wrote:

 Suppose I have a list of existing folder objects and depending
 on their index in the list I want to set a property called 'rang'.
 
 I assumed you could something like this:
 
 
 dtml-call "REQUEST.set('rangList','folder1;folder2;folder2')" 
 (normally the list comes from outside)
 
 dtml-in " _.string.split(rangList,';')"   
   dtml-with "_.getitem('sequence-item')"   

Here, you're getting an item with the literal id 'sequence-item'.

What you mean is to get the item with the id described by the variable 
sequence-item. So, use:

 dtml-with "_.getitem(_['sequence-item'])"

Hope that helps.


This really is a [EMAIL PROTECTED] question, not a [EMAIL PROTECTED] 
question. Please do try to choose the appropriate list for the question. 
Thanks.

--
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] Specialists and __bobo_traverse__

2001-01-15 Thread Steve Alexander

Roch'e Compaan wrote:

 Recent sightings of the use of __bobo_traverse__ in SkinScript gave me hope
 of giving users a more useable breadcrumbs trail in the case where I have
 nested specialists.
 
 My TaskTemplates specialist is nested inside my RequestTypes specialist.
 When I retrieve a dataskin from the RequestTypes specialist I have a tab
 that lists TaskTemplates for that RequestType specialist.  Following a link
 from the TaskTemplate list takes you to that instance.
 
 Thus results in a url like this:
   /RequestTypes/request type instance/Task Templates/task template
 instance,
 and what I ideally want is:
   /RequestTypes/request type instance/task template instance.
 
 I read all the comments about __bobo_traverse__ and created a python method,
 "traversal_method" inside the "RequestTypes" specialists.  I must admit that
 I don't really understand Zope's traversal machinery yet and would
 appreciate some guidance.

With your code below, and with a concrete example, can you say what you 
want to happen, and what actually does happen?

 My SkinScript for RequestTypes:
 
 WITH SELF COMPUTE __bobo_traverse_=traversal_method

You'll want another underscore in there: __bobo_traverse__

 My traversal_method:
 
 ob = getattr(self, name)
 if ob is not None:
return ob

If ob is not found, you'll get an error raised. You need to have some 
sort of marker for the default value.

marker=[]
ob=getattr(self, name, marker)
if ob is not marker:
   return ob
# continue your method

Of course, you only need one marker in your class. You can do that if 
you implement your method as an external method, or perhaps with a 
default value for an argument on you python method.

Or, you could not worry about creating a new empty list on each request.

--
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] Massive scalability

2001-01-14 Thread Steve Alexander

Michael Bernstein wrote:

 I am currently planning two separate 'Archive' type
 projects/Products. In both cases, I need to make sure that
 my implementation will scale to hundreds of thousands or
 even millions of objects.
 

 In one project the objects are very simple ZClasses with a
 few attributes, in the other project, the objects will be
 instances of the Photo Product, and considerably larger.

Do you mean "instances of the Photo Product" or "instances of class 
FooBar from the Photo Product" ?

 One implementation I'm considering is a simple Specialist
 with a Rack. Does anyone know if there are any inherent
 limitations on the number of objects that can be stored in a
 Rack? are there any performance limitations at the scale
 that I'm talking about?

Seeing as a Rack can provide data from absolutely anywhere, I can't see 
a problem with this.
If you're talking about the BTree implementation that Racks use when 
they store data in the ZODB, well, I've never stored more than a few 
thousand objects in one of those. There certainly aren't the same 
limitations that you get with the default ObjectManager, as that uses a 
python dict to hold its sub-objects.

The performance limitations will more likely be to do with searching and 
indexing the data, adding the data in bulk (if you need to do this), and 
retrieving the data if you have a vast number of clients wanting it all 
at once.

 The other implementation I'm considering is to create a
 ZClass that inherits from ZCatalog and Btree Folder.

I can't think why you'd want to do that. What role would instances of 
this class play in your application?

 Would
 this approach run into any scalability problems with the
 number and type of objects I'm talking about?

I think other aspects of your application will determine whether it will 
scale. Scalabillity is an emergent property of a system. You only get to 
know about it when you consider the system holisticly.

With Zope, where you store objects and how you plan to find objects, is 
more significant than what the objects you're storing are.

--
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 )




[Zope-dev] Tip: Skinscript Debugging

2001-01-14 Thread Steve Alexander

When debugging skinscript, especially tricky dependencies between what 
gets computed when during state changes, do the following:

1: Run zope in debug mode (-D)

2: Put an external method called print_ in the root of your ZODB, with 
the code:

   def print_(s):
 print s

3: In your SkinScript, if you want to know when a trigger is called, or 
when a set of attributes get computed, use this kind of thing:

WITH QUERY foo(id=some_id) COMPUTE
   thing=RESULT,
   bar=baz,
   _printout_foo=self.print_('query foo called, id=%s' % some_id)
OTHERWISE LET
   thing=_.None,
   bar='no bar',
   _printout_foo=self.print_('query foo called, otherwise clause')


WHEN OBJECT CHANGED CALL
print_('CHANGED start'),
Catalog
.uncatalog_object(_.string.join(self.getPhysicalPath(),'/')),
print_('CHANGED middle'),
Catalog
.catalog_object(self, _.string.join(self.getPhysicalPath(),'/')),
print_('CHANGED end')


4: Read the debug printout, and work out that you're computing 
attributes for cataloging before changing the attributes they depend on.

5: Amend code and skinscript, test, document code, sleep.

--
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 )




[Zope-dev] SkinScript enhancement

2001-01-14 Thread Steve Alexander

While debugging some dependencies in some of my SkinScript, I had an idea.

SkinScript could be extended so that COMPUTE statements can have a 
RECOMPUTE FOR clause. This clause would tell a dataskin to invalidate 
its cache for the attributes in the COMPUTE statement if any of the 
attributes in the RECOMPUTE FOR clause changed.

So,

WITH QUERY some_method(primary_key=ms_vars_id) COMPUTE
   foo,bar,baz
OTHERWISE LET
   foo='no foo',
   bar='no bar',
   baz='no baz'
RECOMPUTE FOR
   ms_vars_id

This is equivalent to the above statement, without the RECOMPUTE FOR 
clause, followed by a trigger:

WHEN OBJECT ADDED, CHANGED CALL
   HAS_CHANGED('ms_vars_id')
 and self._uncache_attrs(['foo', 'bar', 'baz'])

This assumes a method of DataSkins.DataSkin _uncache_attrs:

def _uncache_attrs(self, names):
 v=self._v_attrCache
 for name in names:
   del v[name]


I haven't tested any of this yet.

--
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 )




[Zope-dev] Re: SkinScript enhancement

2001-01-14 Thread Steve Alexander

Steve Alexander wrote:


 This assumes a method of DataSkins.DataSkin _uncache_attrs:
 
 def _uncache_attrs(self, names):
 v=self._v_attrCache
 for name in names:
   del v[name]
  
 I haven't tested any of this yet.

And I realized just after I sent it that the method should be more like:

  def _uncache_attrs(self, names):
  v=self._v_attrCache
  for name in names:
  if v.has_key(name): del v[name]

-- 
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 implementation question: images attributes?

2001-01-13 Thread Steve Alexander

Zope mailing lists wrote:

 I have a specialist (actually, EMarket has a specialist grin) that
 manages objects that from a design point of view I think should have
 a couple of Images as attributes (thumbnail and fullsized images of
 the product).  The question is, how do I implement this using
 ZPatterns?  Currently all of the other object data is pulled from an SQL
 database.  I don't mind storing the Images in the ZODB, but I'm having
 a hard time finguring out how I would implement that.  Pointers or
 alternate design suggestions welcome.

Here's the simplest approach that I can think of.

Stick all your images in a BTree Folder somewhere convenientm like 
/Images. Name all the images "image-NN" where NN is a unique number.

Make a couple of columns in your database (or whatever) for thumbnail_id 
and large_image_id. You'll store the image ids in these.

Use some SkinScript in that Specialist you mentioned that gets the 
thumbnail_id and large_image_id for a particular object, and also makes 
available the thumbnail and large_image.

WITH QUERY get_thumbnail_for_object_SQL(primary_key=self.id) COMPUTE
   thumbnail_id=thumbnail_id,
   thumbnail=Images[thumbnail_id]
OTHERWISE LET
   thumbnail_id='',
   thumbnail=Images.missing_thumbnail

Note here that I could have had just "thumbnail_id," at line 2.
Also, note that I'm assuming you have an image called missing_thumbnail 
in the Images folder.

Do likewise for large images.

This approach assumes that you're not considering images or thumbnails 
to be first-class domain objects in your system, but just attributes of 
your main objects. Thus, you won't be wanting to store other data that 
is pertinent to images. If you do want to do this, you should use a more 
complex design where Images have their own specialist.

--
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 )




[Zope-dev] updated main.dtml for PlugIns product for Zope 2.3

2001-01-12 Thread Steve Alexander

I've put up a new main.dtml file for the PlugIns product (related to 
ZPatterns), for use with Zope 2.3. This replaces the previous file 
posted at the same URL.

   http://www.cat-box.net/steve/main.dtml

The change makes the odd-even table row styles work consistently even 
when there are plug-ins in the plug-in container.

--
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] updated main.dtml for PlugIns product for Zope 2.3

2001-01-12 Thread Steve Alexander

Steve Alexander wrote:

 I've put up a new main.dtml file for the PlugIns product (related to 
 ZPatterns), for use with Zope 2.3. This replaces the previous file 
 posted at the same URL.
 
   http://www.cat-box.net/steve/main.dtml
 
 The change makes the odd-even table row styles work consistently even 
 when there are plug-ins in the plug-in container.
 
And just updated again, to keep pace with the changes in CVS.

I'll be keeping the file at that URL generally up to date with the 
changes to main.dtml in CVS, at least until 2.3 beta is released.

I won't bother announcing more changes to this list, unless they are 
large and significant.

-- 
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] Re: ComputedAttribute

2001-01-11 Thread Steve Alexander

Martijn Pieters wrote:

 
 But because _v_* variables don't get pickled, another thread will never
 see them. If you want non-persisting (volatile) variables shared between
 threads, you'll have to devise your own mechanism for assuring the
 thread-safety of those variables.

Or, instead of devising your own mechanism, you can borrow someone else's:

   http://www.handshake.de/~dieter/pyprojects/zope/SharedResource.html


Thanks Dieter!

--
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] Zope-2.3a2 and Loginmanager

2001-01-11 Thread Steve Alexander

Ulrich Eck wrote:

 hi out there,
  
 i just setup a box with Zope-2.3a2 and Loginmanager.
 
 didn't work because of Changes  in AccessControl.User:
 
 - Super doesn't exist anymore (is emergency_user the replacement ??)
 
 - Zope-2.3a2 installs itself with a file "inituser" as access-file,
 
  AccessControl.User.py refers to "access" in
 
 line 372: info = readUserAccessFile('access')  --- is this a bug ???

See the message Bill Anderson sent to this list last month:

http://lists.zope.org/pipermail/zope-dev/2000-December/008334.html


Also, in future, please do not send html mail to this mailing list; send 
it in plain text.

--
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 )




[Zope-dev] patch to bring ZPatterns UI in line with 2.3 from CVS

2001-01-10 Thread Steve Alexander

If you're using ZPatterns or PlugIns with Zope 2.3 from CVS, you can 
update most of the ZPatterns user-interface to the new style be 
replacing lib/python/Products/PlugIns/www/main.dtml with this file:

   http://www.cat-box.net/steve/main.dtml

--
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 )




[Zope-dev] New UI for 2.3

2001-01-10 Thread Steve Alexander

I think the new UI for 2.3 is great improvement over 2.2.

I'm already finding the sorted tables of folder contents useful, and 
having the add new items select at the top saves time.


However, I do not like the 3-frame interface. I feel that the top frame 
is wasted space. The Zope logo and "Logged in as username | Logout" 
could as easily go at the bottom of the tree-view frame on the left. 
This would leave extra screen space for doing work.

I realize that I can make the frame smaller by dragging it with my 
mouse. I do a lot of TTW development, and I think I might find that 
cumbersome, so I guess I'll be hacking the top frame out of my 
management interface :-)

I also much prefer blue to black as a background colour for the tabs and 
the "Root Folder" link. The black seems a bit overbearing.

--
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] When to use Rack , Folders w/Customize, etc.

2001-01-09 Thread Steve Alexander

Johan Carlsson wrote:

 Hi,
 Reading up on ZPatterns I'm still confused about some thing's (sometimes more, 
sometimes less).
 
 I wonder:
 When to use Rack, Folders w/Customize, attribute provider, sheetproviders etc.
 
 In which solution do I get ZODB dependens.

Folder w/ Customizer support. When you use this, the DataSkin instances 
appear in the ZODB, and look like normal ZClass (or whatever) instances.

 
 One important aspect for some of my applications are to be as "virtual" as possible.


Use Specialists. Specialists contain Racks. Each Rack manages a 
particular class of objects. You can store objects in the ZODB inside 
the Rack, or alternamtively, you can get the data from external sources. 
You can also combine both kinds of data to provide the attributes for a 
single object.

I've just completed a fairly complex ZPatterns project, designed broadly 
according to Coad / ZPatterns / wisdom from PJE . I used both 
approaches, and, based on that experience, I suggest you use the 
Specialists approach unless you have a pressing need to have your 
dataskin instances "rooted" in the ZODB. In the latter case only, use 
Folder w/ Customizer support.

Other the other hand, if you want to design a "normal" Zope application, 
but just get the flexibility of using Attribute Providers and Skinscript 
to coordinate your dataskin instances, then use Folder w/ Customizer 
support.

--
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] ZCatalog and 'fuzzy logic'

2001-01-09 Thread Steve Alexander

Morten W. Petersen wrote:

 Is there anyone who could try to give an estimate of how long it would
 take to add fuzzy logic (regexp-like) searching capability to the
 ZCatalog?
 
 And reasoning as to why would be appreciated. ;)


Right now, you could use an External Method to apply a regex match to 
each unique value in a field index in a Catalog, and return the 
appropriate Catalog Brains for each match.

This is as easy as called uniqueValues() on the catalog, iterating 
through the unique values to filter them, and then searching the catalog 
with the results of the filter as the constraint for that fieldindex. 
This would minutes and hours to implement and test, and would execute in 
O(number of unique field values) time,  for many values of the 
fieldindex, which should remain acceptably fast where you have a catalog 
with many items, most of which have fields drawn from the same (small) set.

If you want to search a TextIndex using a regex, or you want to search 
for a pattern among a number of fields of the same item, then you're 
into an algorithm that would execute in O(number of cataloged items) 
time. That could get very slow for any sizable catalog.

The other option for searching a TextIndex is to use extensions to the 
NEAR and AND and OR operators that are currently supported. I guess it 
all depends what you mean by "fuzzy matching".

--
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] Zope from CVS for Windows

2001-01-08 Thread Steve Alexander

Toby Dickenson wrote:

 On Sun, 07 Jan 2001 10:39:45 +, Steve Alexander
 [EMAIL PROTECTED] wrote:
 
 
 Is anyone regularly building Zope from CVS for Windows?
 
 I want to try something out on a Zope 2.3 build on windows, but I don't 
 have easy access to windows development tools.
 
 I think you may be out of luck, unless you can get hold of Microsoft
 Visual Studio 6.0

Thanks. I can borrow a machine with VS 6 on it.

However, I've never used visual studio before. Are there any 
instructions available for how to build zope using visual studio 6?

Tnanks.

--
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] Easy SQL question

2001-01-08 Thread Steve Alexander

[EMAIL PROTECTED] wrote:

 
 I believe that this is close
 
 dtml-call "REQUEST.set('phrase_id', foo)"
 
dtml-in expr="langtest()"
   dtml-var expr="_['sequence-item'].renderText"
/dtml-in
 
 but is foo supposed to be my var of whatever I want passed ?
 
  how do I pass the variable for phrase ID ( via a variable and changed per
 request ) to the language test and display the results so the user never
 knows .
 
 I think I am close just missing the obvious I think anyhelp ?

You need to explicitly pass in arguments to a ZSQL Method as keyword 
arguments. So, the following will probably work.

  dtml-in expr="langtest(phrase_id=phrase_id)"
dtml-var expr="_['sequence-item'].renderText"
  /dtml-in

--
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 )




[Zope-dev] Zope from CVS for Windows

2001-01-07 Thread Steve Alexander

Is anyone regularly building Zope from CVS for Windows?

I want to try something out on a Zope 2.3 build on windows, but I don't 
have easy access to windows development tools.

If you can help, please get in touch.

--
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] __bobo_traverse__, new ZCatalog and ZClasses

2001-01-07 Thread Steve Alexander

Steve Alexander wrote:

 Zope 2.3, from cvs on 2000-12-24, patched with Chris P's latest ZCatalog 
 stuff.
 
 I'm getting a bad interaction between ZClasses, ZCatalog and 
 __bobo_traverse__.
 
 I have some ZClasses that are accessed via a container that implements 
 __bobo_traverse__. The problem is that, although I can get to the ZClass 
 instances by typing a URL into by browser, I get a security error when I 
 try to get to them using restrictedTraverse.
 
 This causes a problem, as it means these instances cannot be catalogued 
 in a ZCatalog, because ZCatalog now uses restrictedTraverse to get an 
 object for indexing.
 
 The zope security validation gets stuck between not knowing for sure 
 what the object's container is (according to comments from 
 Traversable.py), and ZClasses not returning anything for __roles__.
 
 ZPatterns jargon paragraph:
 All this causes a problem if you want to use the ZPatterns idiom of 
 ZClass DataSkins in a Specialist, catalogued using a ZCatalog. You can 
 get around it by providing a __roles__ attribute using SkinScript.

In the latest ZCatalog product from CVS, this workaround is no longer 
needed.

When a ZCatalog tries to catalog an object, it first tries to get to it 
using restrictedTraverse, and if that fails, it uses REQUEST.resolve_url 
as a fallback.

REQUEST.resolve_url gets to the DataSkin in the Specialist without 
raising a security error.


 Is there some bug in the ZClasses __roles__ machinery?
 
 When does __roles__ get set on objects or classes anyway? I've found the 
 description of what __roles__ are used for in the old Trinkets tutorial 
 document. I think things have moved on a bit since then, though.

I'd still like to know the answer to these two questions.

-- 
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 )




[Zope-dev] ZPatterns: patch for OLD['name'] for Zope 2.3

2001-01-06 Thread Steve Alexander

Something has changed in the way Zope 2.3 handles the __getitem__ protocol.

This breaks SkinScript's use of OLD.

The fix is to patch Agents.py so that the class _memento explicitly 
provides a __getitem__ method.

ZPatterns may need similar fixes elsewhere. See my message to zope-dev 
earlier this week about the difference in using __getitem__ on Dataskins 
from a Specialist and in the ZODB.

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


*** Agents.py.original
--- Agents.py
***
*** 326,332 
  'memento_exprs': 'Keeping:', 'handle_set_for':'Setnbsp;Attrs:'
  }
  
! class _memento: pass
  _emptyMemento=_memento()
  
  
--- 326,336 
  'memento_exprs': 'Keeping:', 'handle_set_for':'Setnbsp;Attrs:'
  }
  
! class _memento: 
!   __allow_access_to_unprotected_subobjects__=1
!   def __getitem__(self, name):
! return self.__dict__[name]
! 
  _emptyMemento=_memento()
  
  



[Zope-dev] ZPatterns: SAVING doesn't tolerate missing attributes

2001-01-06 Thread Steve Alexander

In SkinScript such as

   WHEN eventspec CALL expression SAVING mementolist

if any of the mementos in mementolist are not found, the script raises a 
KeyError.

I'd like a way of saving a memento if it exists, or NOT_FOUND otherwise.

For example, an Executive might have a CompanyCar.

WITH CompanyCars.getCar(self.car_id) or NOT_FOUND COMPUTE
   car=RESULT,
   car_registration=registration
OTHERWISE LET
   car=NOT_FOUND,
   car_registration="no car"

When an Executive changes her car for a different one, I want to perform 
certain actions on the old car, and certain on the new car:

WHEN OBJECT CHANGED CALL
   HAS_CHANGED('car_id') and
   (self.car_id and CompanyCars.getItem(self.car_id).decommission(),
ORIGINAL['car_id'] and OLD['car'].commission())
SAVING car

However, I can't do this if the executive is being assigned a car from a 
state of having no car. It fails with a KeyError because the ZPatterns 
machinery can't save "car".

--
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: SAVING doesn't tolerate missing attributes

2001-01-06 Thread Steve Alexander

Steve Spicklemire wrote:

 Hi Steve,
 
Could you let some other value represent no car? (e.g., _.None?).
 
 untested... 
 
 WITH CompanyCars.getCar(self.car_id) or NOT_FOUND COMPUTE
car=RESULT,
car_registration=registration
 OTHERWISE LET
car=_.None
car_registration="no car"
 
 WHEN OBJECT CHANGED CALL
HAS_CHANGED('car_id') and
(self.car_id and CompanyCars.getItem(self.car_id).decommission(),
 ORIGINAL['car_id'] and (OLD['car'] and OLD['car'].commission()))
 SAVING car
 
 Would that work?

Sure, that would work.

The workaround I've chosen is to use
   CompanyCars.getItem(ORIGINAL['car_id']).commission()
in place of
   OLD['car'].commission()

Oh, and I jsut noticed, I had commission and decommission the wrong way 
around in the example :-)

I'd still prefer SAVING to tolerate not-found attributes, though.

--
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 )




[Zope-dev] RFE: Make PythonScripts.standard available from DTML _.standard

2001-01-05 Thread Steve Alexander

This is an RFE for Zope 2.3.

I'm posting it here for discussion, rather than in the Collector.


In the new PythonScripts product (that is a standard part of Zope 2.3) 
there is a standard utility module that can be imported into a Python 
Script with

   import Products.PythonScripts.standard

or

   from Products.PythonScripts.standard import *

It contains useful functions such as those for text formatting 
(html_quote, url_quote_plus, and so on). It also contains the DTML class 
for creating temporary chunks of restricted DTML.

These functions would be really useful as part of the DTML _ namespace 
variable. I sometimes find myself wanting to use html_quote in a DTML 
expression. I'd also be able to use these functions from ZPatterns 
SkinScript.

The PythonScripts product could add these functions to the _ namespace 
variable at product init time, so there would be no need to change the 
DocumentTemplate modules.

--
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] RFE: Make PythonScripts.standard available from DTML _.standard

2001-01-05 Thread Steve Alexander

Steve Alexander wrote:

 
 The PythonScripts product could add these functions to the _ namespace 
 variable at product init time, so there would be no need to change the 
 DocumentTemplate modules.

And here's a patch:
Just add these lines at the end of
   lib/python/Products/PythonScripts/standard.py

from DocumentTemplate.DT_Util import d
import standard
d['standard']=standard
del standard

Of course, you could add similar lines to PythonScripts/__init__.py, or 
in a completely new "enable python scripts standard module with dtml" 
product.

-- 
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] RFE: Make PythonScripts.standard available from DTML _.standard

2001-01-05 Thread Steve Alexander

Chris Withers wrote:


 If you have something like that, wouldn't it be better, more readable,
 etc, for it to be moved intop a python script, even if that script was
 only 1 line long?
 
 eg:
 dtml-if
 "mysomething(_['title_or_id'],_.standard.html_quote(absolute_url()+_[id]))"

You are being deliberately Byzantine there!

Not to mention that _['title_or_id'] is equivalent to just title_or_id.

However, I agree with you in principle.
I've had other, much simpler, cases where I want to html_quote just a 
part of something. I can't put my finger on an example right now, so 
that does weaken my case a little :-)

--
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] BTree Folders

2001-01-05 Thread Steve Alexander

Chris Withers wrote:


 Right, BTree folders wise, what I'm looking for is to have, in effect
 two Contents tabs for one BTree folder object, one showing all contained
 items of a particular meta_type (with the BTree Folder's interface to
 deal with lots of objects), and the other containing all other items in
 the folder (DTML Methods, Gifs, etc, with a normal folder's interface).
 
 What's the best way to do this?

If you're using ZPatterns anyway, you might like to look at PlugIns. The 
idea with PlugIns is that a PlugIn manager delegates the handling of 
objects it contains to its various PlugIns. Typically, a PlugIn will 
claim objects based on the object's meta-type.
PlugIns appear in the user-interface as separate tabs. See the 
Customizers and Data Plug-ins tabs in a Folder w/ Customizer Support 
instance for an example.

--
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 )




[Zope-dev] SkinScript reference in two-up postscript

2001-01-05 Thread Steve Alexander

Hi folks,

   http://www.cat-box.net/steve/skinscript_ref-0-4-3b2.ps.gz

This is a two-up A4 postscript version of PJE's most useful SkinScript 
reference. It prints out to four landscape-orientation A4 pages.

  http://www.cat-box.net/steve/skinscript_ref-0-4-3b2_letter.ps.gz

This is similar, but for letter size paper.

Also available in pdf:

   http://www.cat-box.net/steve/skinscript_ref-0-4-3b2.pdf
   http://www.cat-box.net/steve/skinscript_ref-0-4-3b2_letter.pdf

The files were produced from the skinscript help page of ZPatterns 
0-4-3b2, printed to a file with Mozilla, and then converted to 2-up 
pages using impose.

The pdf versions were produced using ps2pdf on the postscript files.

--
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 )




[Zope-dev] ZPatterns: __getitem__ on a DataSkin instance

2001-01-05 Thread Steve Alexander

Let's say I have a DataSkin-derived ZClass that has the attribute 
"forename" (in a dataskin attribute propertysheet).

If I get an instance of this ZClass from the ZODB (set up to use a 
Folder w/ customizer suppport), I can refer to the "forename" attribute 
using dtml-var "this()['forename']".

However, if I get an instance of the same class from a Specialist, 
dtml-var "this()['forename']" gives me

Error Type: AttributeError
Error Value: __getitem__

Any idea why there's the difference?

Can the latter case be fixed?

--
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 )




[Zope-dev] Re: ZPatterns: __getitem__ on a DataSkin instance

2001-01-05 Thread Steve Alexander

Steve Alexander wrote:

 Let's say I have a DataSkin-derived ZClass that has the attribute 
 "forename" (in a dataskin attribute propertysheet).
 
 If I get an instance of this ZClass from the ZODB (set up to use a 
 Folder w/ customizer suppport), I can refer to the "forename" attribute 
 using dtml-var "this()['forename']".
 
 However, if I get an instance of the same class from a Specialist, 
 dtml-var "this()['forename']" gives me
 
Error Type: AttributeError
Error Value: __getitem__
 
 Any idea why there's the difference?
 
 Can the latter case be fixed?

A workaround, using the ever-flexible skinscript:

I've defined __getitem__ through skinscript and a PythonScript.

SkinScript:
   WITH SELF COMPUTE __getitem__=getattr

PythonScript:
   parameter list: index

   return getattr(index)


-- 
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] Re: ZPatterns: __getitem__ on a DataSkin instance

2001-01-05 Thread Steve Alexander

Steve Spicklemire wrote:

 Hi Steve,
 
Hmm.. is the 'id' of your PythonScript also getattr?

Yes. I forgot to mention that. And, I realized just after posting the 
email to the list that calling a method "getattr" is asking for trouble :-)

Actually, my workaround doesn't work except in the most trivial cases.
My code was making more errors as Zope tried to look up the _ variable 
via __getitem__ and thus via my PythonScript.

I've ended up using a dtml-if to choose whether to use a dtml-with 
stuff mapping block or just a plain dtml-with stuff block.

I'd still like to know why a Dataskin from a specialist is behaving 
differently from one in the ZODB in this respect.
--
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 )




[Zope-dev] ZPatterns: catching exceptions raised by triggers

2001-01-05 Thread Steve Alexander

Let's say I have a trigger that is called to ensure that what something 
is changed to holds true.

I use some skinscript like this:

WHEN OBJECT ADDED, CHANGED CALL self.ensure_conditions_hold()


I write the ensure_conditions_hold method so that it returns None if 
everything is ok, but raises an exception if there is a problem with the 
new state of the object.

That's all fine. However, I want to catch this exception in my 
application, and handle it in a friendly way. However, I've tried using 
dtml-try blocks and try: except: blocks from Python Scripts, and either 
way, I cannot catch the exception. It still causes Zope to return the 
standard_error_message screen.

I can only speculate that this is all due to the way that triggers get 
executed at the end of transaction. I guess I'll have to validate the 
data twice if I want to provide helpful feedback to the user.


Stranger still, the error message is reporting itself to have a strange 
content-type, so my browser is asking me if I want to download it as a 
file; I'm pretty sure this isn't related to the skinscript though, as I 
can get the same effect with other errors.

How do I catch an error raised by a Trigger?

--
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 )




[Zope-dev] ZPatterns; possible bug?

2001-01-04 Thread Steve Alexander

I have a specialist "Instructors".

It holds a rack, containing DataSkin-derived ZClasses of meta-type 
"Instructor".

The Instructor class has a DataSkin Attribute propertysheet called 
"Basic", and this has properties for forename, surname, address, areas.

I have some skinscript in the Instructors specialist:


WITH SELF COMPUTE
   name='%s %s' % (forename, surname),
   areas_comma_sep=_.string.join(areas, ','),
   address_lines=_.string.join(address, '\n'),
   address_comma_sep=_.string.join(address, (', '))

WITH SELF COMPUTE
   __roles__=_.None
   # XXX publicly visible!! Nutter!!
   # change __roles__ to ('Operator',) later.

This works fine. The __roles__ bit is a hack to make Zope 2.3 ZCatalog 
play nicely with the Specialist and __bobo_traverse__.

I have some other skinscript that keeps an instructors index in a 
ZCatalog inside Instructors.

WHEN OBJECT ADDED CALL
   Catalog.catalog_object(self, _.string.join(self.getPhysicalPath(),'/'))
WHEN OBJECT DELETED CALL
   Catalog.uncatalog_object(_.string.join(self.getPhysicalPath(),'/'))
WHEN OBJECT CHANGED CALL
   Catalog.uncatalog_object(_.string.join(self.getPhysicalPath(),'/')),
   Catalog.catalog_object(self, _.string.join(self.getPhysicalPath(),'/'))

This worked fine.

When I changed the first skinscript to make one WITH SELF statement, I 
got some strange inconsistencies:

WITH SELF COMPUTE
   name='%s %s' % (forename, surname),
   areas_comma_sep=_.string.join(areas, ','),
   address_lines=_.string.join(address, '\n'),
   address_comma_sep=_.string.join(address, (', ')),
   __roles__=_.None

On changing an instructor's properties using manage_changeProperties on 
its propertysheet, I'd see the change in the instructor. However, the 
ZCatalog metadata would always have the most recent value for "surname", 
but the last value for "name".

Changing the skinscript back to using two statements makes cataloging 
function normally again.

I could tell when the catalog was doing by instrumenting the recordify 
method of Catalog.py:

 def recordify(self, object):
 """ turns an object into a record tuple """
 print "recordify %s" % (object)
 record = []
 # the unique id is allways the first element
 for x in self.names:
 try:
 attr = getattr(object, x)
 if(callable(attr)):
 attr = attr()

 except:
 attr = MV
 print "  appending %s:%s" % (x, attr)
 record.append(attr)

 return tuple(record)

A typical (wrong) debug output would be:

recordify Instructor instance at 86c16b0
   appending id:instructor-977678608
   appending meta_type:Instructor
   appending bobobase_modification_time:2001/01/04 17:26:01.35408 GMT
   appending name:Bob Collins8
   appending surname:Collins9
   appending areas_comma_sep:M12

This is after changing the surname of the instructor from "Collins8" to 
"Collins9".

The cause of the problem? I don't know. Maybe I'm doing something silly.

I think what is happening in the broken example is that when the zope 
security machinery asks for __roles__, name is also computed. The 
machinery must request __roles__ before changing anything.

After that, surname gets changed. However, changing "surname" only 
invalidates "surname" in the cache; not anything that is computed using 
surname.

At the end of the transaction, when the triggers are called, name is 
already in the dataskin's attribute cache, so it does not get recomputed.

In the working example, when __roles__ is requested, it is in a 
different skinscript statement, so it does not cause "name" to be 
computed. Thus, "name" can be computed freshly after "surname" is set.

Is this behaviour intended, is it a bug, or is it an unimplemented feature?

Thanks.


Oh, almost forgot: ZPatterns-0-4-3b2

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

I


___
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] Re: Objects with multiple parents and storage flexibility, ZPatterns?

2001-01-03 Thread Steve Alexander

Chris Withers wrote:

 Hi,
 
 Once again I'm back at trying to solve this problem, hopefully with a
 little more knowledge this time ;-)
 
 What I'd like:
 'Zope' objects of type 'X', which can have multiple parents and can
 contain other objects of type 'X', where storage isn't necessarily tied
 to the ZODB but where the objects have a normal properties page (in
 terms of use, again, it'd be nice if it could be stored anywhere) and
 participate in all the normal Zope security and management interface
 processes, and they need to be catalogable.
 
 This sounds like ZPatterns to me, am I right?
 
 If so, it appears there are two choices:
 1. Folder w/Customiser Support (FwCS ;-) and DataSkins
 2. Specialist with one or more Racks and DataSkins

 Which one of these would be most appropriate?

If you use a Folder w/ Customizer Support, you'll need to create all the 
DataSkin instances in the ZODB, just as if they were normal ZClass (or 
whatever) instances. Thus, the instances all need to be "in there" to 
start with. You can't add data to your external database, and expect a 
new Dataskin instance to pop up in the ZODB. This is what is meant by 
"When using Folder with Customizer Support, DataSkins are anchored in 
the ZODB".

 FwCS containg DataSkins that also mix in the Folder class sound like
 they'd give a closer approximation to 'real Zope objects', but Racks
 sound like the only way that objects of the same metatype can come from
 different sources (eg, some objects of type 'X' from ZODB, some from
 SQL, some from LDAP ,etc) and seem to be more flexible in general, but
 can I have DataSkins that nest stored in a specialists' rack, eg:

You can get the data for your dataskins from a variety of sources, 
whether you choose to use Specialists or Folder w/ Customizer Support.

However, if you use Specialists, you can have the DataSkin instances 
appear only when requested. Thus, you can add records to your external 
database, and thereby have new Dataskins available from your application.

 http://server:8080/specialist/dataskin1/dataskin2
 
 How about doing something like:
 
 http://server:8080/specialist/dataskin1/dataskin2/manage

You can do this by providing the __bobo_traverse__ protocol, using 
SkinScript in your Specialist to give objects of the type of dataskin1 
an appropriate __bobo_traverse__ method.

I briefly described this on zope-dev a couple of days ago.

--
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] dynamic permissions in zope

2001-01-02 Thread Steve Alexander

Steve Alexander wrote:


 I believe the latest LoginManager allows you to specify what roles a 
 user has, and compute these each request, based on the details of the 
 request.
 
 This is probably more useful than having dynamically computed 
 permissions; While I can see how a user's roles will vary according to 
 where they are, what they are doing and when they are doing it, I cannot 
 see why permissions need to change in that way.
 
 However, you mention that you are new to Zope. ZPatterns can be 
 difficult to understand and get into. Other than the creators of 
 ZPatterns, I haven't heard of anyone using this computed permissions 
 system.

What I forgot to mention: LoginManager is a Zope product that is built 
using ZPatterns, another Zope product.

When you are doing advanced things with LoginManager, you need to know 
how ZPatterns works.

There are a couple of HOWTO documents on using LoginManager. It will be 
only a small change to alter the "userRoles" method that returns the 
roles a user should have to calculate these roles based on other criteria.

See these documents for information about how to set up LoginManager.

   http://www.zope.org/Members/dlpierson/sqlLogin
   http://www.zope.org/Members/jok/SQL_based_LoginManager

-- 
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] ANNOUNCE: PartitionedFileStorage

2001-01-02 Thread Steve Alexander

Shane Hathaway wrote:


 BTW, Evan helped me find and correct a bug.  You'll only run into it if
 you set your partition size to less than the size of the largest ZODB
 objects.

The new version of FileStorage.py in PartitionedFileStorage for 2.3 
overwrites some of the changes made the FileStorage locking protocol in CVS.

These are the ones using  _commit_lock_acquire _commit_lock_release.

--
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] PartitionedFileStorage - Eek!

2001-01-02 Thread Steve Alexander

Shane Hathaway wrote:


 Should be, although I just realized I don't know whether 0.0.2 was
 intended for Zope 2.2 or 2.3.

There is no difference between the PartitionedFile.py files in the 2.2 
and 2.3 versions, so I guess 0.0.2 will do as well for either.

--
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] ZCatalog reindex_object

2000-12-31 Thread Steve Alexander

Chris Withers wrote:

 Michael Bernstein wrote:
 
 reindex_object - should be called when an object is edited
 
 
 Hmmm... didn't see this method listed in the interfaces wiki. Where did
 you find it?

reindex_object is a method of the mix-in class CatalogAwareness.

   lib/python/Products/ZCatalog/CatalogAwareness.py line 191

 def reindex_object(self):
 """ Suprisingly useful """
 self.unindex_object()
 self.index_object()

 I just inserted a call to catalog_object which did the job but I wonder
 what the difference between index_object abd reindex_object and
 catalog_object is?

I think calling index_object should work, as a well-implemented catalog 
will do the right thing. However, calling reindex_object makes your 
intentions more explicit.

--
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] Updating a ZCatalog when objects in it change their path

2000-12-30 Thread Steve Alexander

Chris Withers wrote:


 However, the only way I could find to solve it was to add a
 manage_afterAdd method to Squishdot Sites which recatalogued all
 postings. This is a _lot_ more resource intensive than it needs to be,
 since I don't actually want to recatalog all postings (quite expensive
 when there are 3000+ of them ;-), I just want to modify the paths that
 ZCatalog has stored.
 
 Is there any way to do this? There probably should be ;-)

Look in the new ZCatalog product (released for testing a few weeks ago), 
in the manage_normalize_paths method of ZCatalog.py (line 603).

This method goes through every item in the Catalog, and checks to see if 
its path needs to be changed to the new convention of using the physical 
path to the object.

You could use a modified version of this method to do what you want, 
calling it from manage_afterAdd. You may need to store the old path to 
the ZCatalog instance in an attribute, so you'll know how to change the 
paths.

The following code should help, although I haven't tested it. It is 
shamelessly cribbed from Chris P's manage_normalize_paths method.

   paths = self._catalog.paths
   uids = self._catalog.uids

   for path, rid in uids.items():
   new_path=_method_to_return_new_path_after_add(path)
   del uids[path]
   paths[rid] = new_path
   uids[ppath] = rid


--
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 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 )




[Zope-dev] __bobo_traverse__, new ZCatalog and ZClasses

2000-12-24 Thread Steve Alexander

Zope 2.3, from cvs on 2000-12-24, patched with Chris P's latest ZCatalog 
stuff.

I'm getting a bad interaction between ZClasses, ZCatalog and 
__bobo_traverse__.

I have some ZClasses that are accessed via a container that implements 
__bobo_traverse__. The problem is that, although I can get to the ZClass 
instances by typing a URL into by browser, I get a security error when I 
try to get to them using restrictedTraverse.

This causes a problem, as it means these instances cannot be catalogued 
in a ZCatalog, because ZCatalog now uses restrictedTraverse to get an 
object for indexing.

The zope security validation gets stuck between not knowing for sure 
what the object's container is (according to comments from 
Traversable.py), and ZClasses not returning anything for __roles__.

ZPatterns jargon paragraph:
All this causes a problem if you want to use the ZPatterns idiom of 
ZClass DataSkins in a Specialist, catalogued using a ZCatalog. You can 
get around it by providing a __roles__ attribute using SkinScript.


Is there some bug in the ZClasses __roles__ machinery?

When does __roles__ get set on objects or classes anyway? I've found the 
description of what __roles__ are used for in the old Trinkets tutorial 
document. I think things have moved on a bit since then, though.


Some relevant code snippets:

Traversable.py

 t=get(object, '__bobo_traverse__', N)
 if t is not N:
 o=t(REQUEST, name)

 # Note we pass no container, because we have no
 # way of knowing what it is
 if (restricted and not securityManager.validate(
 object, None, name, o)):
 raise 'Unauthorized', name


ZopeSecurityPolicy.py, line 123:

 # Try to get roles
 roles=getattr(value, '__roles__', _noroles)

 if roles is _noroles:

 
 # We have an object without roles. Presumabely, it's
 # some simple object, like a string or a list.

--
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] RE: objectIds accessiblilty and a proposal

2000-12-18 Thread Steve Alexander

Brian Lloyd wrote:

 
 This comes up often enough that I'm inclined to do 
 something about it for 2.3. I propose that objectIds
 (and objectValues) will not be directly accessible 
 via the Web in 2.3. For xml-rpc applications, it should
 be a simple enough task to create a Python Script (or 
 even a DTML Method) that *is* Web accessible to relay 
 that information if it is needed.
 
 Thoughts?

I have no objections to that.

On a related issue, what about other dtml snippets that people generally 
don't want as web accessible, such as standard_html_header ?

On my pie-in-the-sky zope wishlist:

What I'd like is a new tab for zope objects that allows me to say which 
protocols the object is accessible from, and what to do if not.

For example:

   access route accessible?action

   called from template yes
   http on port 8080no return 404
   ftp  yes


Another example:

   access route accessible?action

   called from template yes
   http on port 8080no redirect to URL1


If medusa is ever extended to have http and https on different ports, 
then you could declare different accessible states and actions for the 
different http ports.

--
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] RE: objectIds accessiblilty and a proposal

2000-12-18 Thread Steve Alexander

Dieter Maurer wrote:

 Steve Alexander writes:
   On my pie-in-the-sky zope wishlist:
   
   What I'd like is a new tab for zope objects that allows me to say which 
   protocols the object is accessible from, and what to do if not.
   
   For example:
   
  access route accessible?action
   
  called from template yes
  http on port 8080no return 404
  ftp  yes
   
   
   Another example:
   
  access route accessible?action
   
  called from template yes
  http on port 8080no redirect to URL

 Sounds good to me.
 

 With the exception that I do not like the explicit port references.
 I would like to see there an indirection (e.g. use a name
 which can be mapped to a port at a central place).

I agree, that's a good idea.

The accessible state, and the action for a particular access-route could 
be acquired, like the current security settings. So, I'd have to say in 
only a single folder's accessing tab that all objects below that folder 
that are invisible to web traversal should return a 404.

Isn't there already a fishbowl proposal for this kind of thing? Did it 
get anywhere?

--
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] IMPORTANT! Zcatalog path handling changes in 2.3

2000-12-18 Thread Steve Alexander

Christopher Petrilli wrote:

 On 12/18/00 4:24 PM, "Steve Alexander" [EMAIL PROTECTED] wrote:
 
 
 Doesn't work with 2.3 from CVS, 2000-12-18 21:21 UTC
 
 
 ACK, I forgot that I also revealed afew bugs in other systems :/  I thought
 that I could just package up Zcatalog, but apparantly not Let me work on
 coming up with something new.

I can get your new ZCatalog to install and run with Zope 2.3 from CVS by 
commenting out the last two lines of 
lib/python/Products/ZCatalog/__init__.py:

   #context.registerHelp()
   #context.registerHelpTitle('Zope Help')

Of course, I miss out on getting help with the new API if I do this :-)


--
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, ZClasses, Specialists: Assigning responsibilities

2000-12-15 Thread Steve Alexander

Itai Tavor wrote:

 I have the following ZClasses, with matching Specialists: 
 Product, Graphic, Order, OrderLineItem. When a customer adds a product 
 to their order, they have to provide a graphic file which will be 
 printed on the product (imagine buying a lunch box with your cat's photo 
 on it). The Graphics Specialist can provide a addGraphicSnippet form. 
 But who's responsible for asking for this graphic when adding the 
 product to the order? Is it still the Product object? But a Product 
 turns into a Product-with-Graphic only when it's a part of an order, so 
 is it correct for the Product to even know about Graphics? the 
 alternative is to move the addToOrder methods to either Order or 
 OrderLineItems, but this doesn't make any more sense because these would 
 then have to know a lot more about a Product than is good for them. Any 
 ideas?

Sounds to me like you have a new type of Product.

You have your basic products (of which there are many kinds), and you 
have ProductWithGraphic products. A ProductWithGraphic is a "calculated 
product": it is composed of a basic product and a graphic. Its cost, 
delivery time, packing charge, and so forth, are calculated based on the 
combination of the basic product and the graphic.

To the rest of the application, a ProductWithGraphic is just another 
kind of product.

--
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] more on keyword indexes

2000-12-15 Thread Steve Alexander

Hi Josh,

I use KeywordIndexes a lot.

Just for kicks, I implemented what you describe below in Zope2.3 grabbed 
fresh from CVS just now.

I used DTML Documents for the objects to catalog, and I added a lines 
property called KW to each one.

I queried the catalog using syntax like
   dtml-in "Catalog(KW=['one', 'two'])"
or
   dtml-in "Catalog(KW='purple')"


Josh Zeidner wrote:

 Hello,
 
   I did a little more investigiation into the problem, and couldnt really
 find any documentation anywhere on what the actual semantics are of keywords
 and how they are queried.  For instance:
 
   I have three classes and each has an keyword index named KW:
 
   ObjectOne:KW = ['one','blue','furry']
   ObjectTwo:KW = ['two','flying','purple']
   ObjectThree:  KW = ['three','one-eyed','purple']
 
   If I were to query the ZCatalog with the following set of words:
 ['purple'] I would expect to get:
 
 ObjectTwo
 ObjectThree

Yes, that's what you get.

   Right?  If I query the database with ['one','two'] ( if this type of thing
 is at all possible ), I get :
 
 ObjectOne
 ObjectTwo

Yes, that's what you get.

   This seems like the obvious result: BUT: it depends if you want a AND/OR
 type search.  

It is an OR search.

 I could also expect to get nothing( if its an AND type search
 because no records match 'one' and 'two' ).  Here is better example, what if
 I queried: ['purple','one-eyed'].  Would I be expecting only ObjectThree or
 [ ObjectThree, ObjectTwo ] ( because they both match the keyword purple( a
 logical set-intersection ) ).

You get ObjectTwo and ObjectThree.


   Also I found the keyword indexes to have some more obvious bugs.  If I
 only used one keyword for the matching critiria,  for instance if I used
 'purple' , I would only get ObjectTwo.

I get ObjectTwo and ObjectThree, as I'd expect.


 Is anyone else using keyword
 indexes?  In what way are you using them?

All sorts of things. One useful use is to limit a query on a SiteIndex 
type of catalog to just a sub-tree of your site.

See my message to zope-dev on October:

   http://lists.zope.org/pipermail/zope-dev/2000-October/007535.html


--
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] keyword indexes

2000-12-15 Thread Steve Alexander

Josh Zeidner wrote:

 Hi,
 
   Currently I am wrestling with "keyword" indexes in ZCatalogs.  How do I
 query the ZCatalog for all records of objects indexed on a particular
 keyword.  For instance if my index is named MediaKeyword ive tried:
 
  dtml-in "Catalog.searchResults( MediaKeywords = ['ouch'] )"

That should work.

this has completely unpredictable results.
 
  dtml-in "Catalog.searchResults( MediaKeywords in ['ouch'] )"
 
this returns all indexed objects!

That won't work. The python

   MediaKeywords in ['ouch']

will be evaluated first, and will give a calue of 0 or 1. If 
MediaKeywords is a list, then it will always give 0, because there is 
only one item in ['ouch'], and that is the string 'ouch'.

   What am I doing wrong?  Is there a special ZCatalog function for querying
 keyword indexes?  I need some insight into this problem.

Are you sure that the keywords are being indexed in your catalog? A good 
trick is to index the keyword attribute, and also store it as metadata. 
That way, you can look through your search results at the keywords the 
Catalog thinks you have.

Also, check that you declared MediaKeywords as a keyword index, and that 
the MediaKeywords attribute in your objects is (or returns) a sequence 
type such as a tuple or a list.

--
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 )




[Zope-dev] Python 2 (Zope Unicode) support for 2.2.4

2000-12-12 Thread Steve Alexander

Hi Folks,

I've modified Toby Dickenson's patch to let Zope work with Python 2 so
that it patches against Zope 2.2.4.

  http://www.zope.org/Members/stevea/unicode_for_224.patch.gz


Toby's page about using unicode and Python 2 with Zope is here:

  http://www.zope.org/Members/htrd/wstring

--
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] case insensitive sorts

2000-12-06 Thread Steve Alexander

Andy McKay wrote:

 Minor nit and patch: I've found that really for me what users want to see is
 a case insensitive sort of objects, not the current python case sensitive
 sort. So that the order of objects from dtml-in and tree is a, A, b, B as
 apposed to A, B, a, b.
 
 Anyway Ive patched dtml-in and dtml-tree to do this sort on a ignore_case
 tag. Is this useful to anyone else? And Ive thought of patching my Zope so
 this is the default behaviour what does anyone else think. The next
 thing to patch is ZCatalog...


The way I approached this was to have a ZPatterns attribute provider, or 
a method, that provides a modified version of the value I want to sort on.

For example, I have a load of documents and folders with titles like

  Big Folder

  brown document

  "Berries for Cooking" list

I wanted to present these sorted by non-case-sensitive first letter or 
number. So, I made a method "title_for_sorting" that stripped off any 
punctuation at the start, and returned the first 20 characters in all 
lower case.  In this case, as it was a ZPatterns application, the method 
was presented as an attribute of the object using some skin-script. I 
used this attribute as a field-index in my SiteIndex ZCatalog.

The reason I mention this is that sometimes case-insensitivity is not 
enough for sensible sorting. In this case, I had to strip out 
punctuation too.

--
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] FIX for the infamous __call__ bug - testers needed!

2000-11-13 Thread Steve Alexander

Brian Lloyd wrote:
 

 Attached is an updated version of cDocumentTemplate.c. You 
 can drop this into the lib/python/DocumentTemplate directory 
 of your installation and rebuild it - after restarting the 
 Zope site, the __call__ problem should be gone.
 
 I'd really like to hear from some folks on this so I can 
 get the 2.2.3 release wrapped up - thanks!

I just tested this using a ZWikiPage from ZWiki 0.7.1 that is set for 
structuredtextdtml and has the following content

   dtml-with someFolder
 dtml-var objectIds
   /dtml-with

With the current cDocumentTemplate.so, I get the __call__ error.
With the new cDocumentTemplate.so, it works as expected.

So in summary, it works for me.

--
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] RFClarification: Security on Product Attributes

2000-11-10 Thread Steve Alexander

Jim Fulton wrote:

 
 Strings; fine, at least they're secure, and when they become proper
 objects in Python 2.0, the problem should go away?
 
 
 Will Python 2.0 let you assign string attributes?


% python
Python 2.0 (#3, Oct 26 2000, 15:07:09)
[GCC 2.95.2 19991024 (release)] on sunos5
Type "copyright", "credits" or "license" for more information.
  a=''
  a.foo='bar'
Traceback (most recent call last):
   File "stdin", line 1, in ?
TypeError: object has read-only attributes
 

--
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 )




[Zope-dev] DataSkinAddons 0-0-2 released

2000-10-24 Thread Steve Alexander

DataSkinAddons 0-0-2

http://www.zope.org/Members/stevea/DataSkinAddons

Changes:

DataSkinAddons 0-0-2, 24 October 2000

DataSkinAddons 0-0-2 works with ZPatterns-0-4-3b1 and Zope 2.2 only

Various changes to CatalogTrigger to bring it in line with the
new Expressions module from ZPatters 0-4-3b1, and to tidy up some
cruft.
Thanks to John Eikenberry for contributing to this.

Note that CatalogTrigger does not cause a ZPatterns transaction to
abort, but instead logs an error, if an object cannot be catalogued
or uncatalogued. In some cases, this may be wrong behaviour.
Some checkboxes might appear for this in the next release of
DataSkinAddons. Until then, use SkinScript if you want to abort
the transaction if there is a problem cataloguing or uncataloguing.

--
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] Getting all objects matching a given meta_type and more

2000-10-24 Thread Steve Alexander

Morten W. Petersen wrote:

 I've managed using the ZCatalog now.  However, I have a small problem:
 
 When I instansiate a ZCatalog at the root of a tree, and search
 for all objects matching a given meta-type, all the objects in
 the entire tree are returned.
 
 Is there a way to instruct the ZCatalog instance that it should only
 return objects from within a certin part of the tree, without instansiating
 a new ZCatalog instance in the given subtree?

Yes.

Create a keyword index in your catalog called "path_kw_for_catalog".

Create an external method called "path_kw_for_catalog" that, for an 
object, returns a list of strings that uniquely represent the physical 
path to that object, and to each of its parents by containment.

Create an external method "path_kw" that, for an object, returns a 
string that uniquely represents the physical path to that object.

Then, query your catalog using that keyword index, and the results 
path_kw for the path you want results from under.

As an example, path_kw_for_catalog might return

   ['foo_bar_baz', 'foo_bar', 'foo']

for an object at http://your.server.net/foo/bar/baz

In the same example, path_kw would return 'foo_bar' for the object at 
http://your.server.net/foo/bar


I don't know whether you can use the results of 
string.join(getPhysicalPath(), '/') as a keyword in a KeywordIndex in a 
ZCatalog. In the following methods, I'm assuming that you can't. They 
can be simplified if it turns out you can.

I'm also assuming that space characters are bad in keyword indexes. 
Again, I might be completely wrong. I guess I should check.

Anyhow, these methods should give you the general idea:

from string import join, replace

def kw_path_for_catalog(self):
 keywords=[]
 pp=self.getPhysicalPath()
 for p in range(2, len(pp)+1):
 keywords=keywords+[join(map(fix_bad_chars, pp[1:p]), '_')]
 return keywords

def kw_path(self):
 return join(map(fix_bad_chars, self.getPhysicalPath()[1:]), '_')

def fix_bad_chars(s):
 return replace(s, ' ', 'x')

--
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 )




[Zope-dev] ZPatterns bug: no help subdirectory in PlugIns

2000-10-19 Thread Steve Alexander

PlugIns-0-4-3b1 (part of the latest ZPatterns release).

__init__.py fails because at line 8 context.registerHelp() fails, as
there is no "help" subdirectory in the PlugIns product folder.

I guess this is an empty directory that got missed off when the whole
thing was tarred up.

A simple fix is "mkdir help" from the PlugIns directory.

--
Steve Alexander
Software Enigneer
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 )




[Zope-dev] Xron fragility

2000-10-11 Thread Steve Alexander

The Xron product seems rather "fragile" in use.

That is, if things go wrong when an Xron DTML Method is triggered, that
method doesn't get rescheduled.

An example of this is that my intranet DNS server needed to be rebooted.
Xron couldn't look up the appropriate domain name, and stopped working.

--
2000-10-11T08:16:34 PROBLEM(100) Products.Xron.Loggerr 
Trigger event: http://my.development.server:4080/my_xron_method
Trigger time: 2000/10/11 09:14:00 GMT+1
Failed to trigger event.
Type=bci.NotAvailable
Val=host not found (File:
http://my.development.server/my_xron_method/trigger Line: [])
None None for None
--
2000-10-11T08:19:04 PROBLEM(100) Products.Xron.Loggerr Failed to disarm
event


Also, if something bad happens in the Dispatcher thread, the thread
dies.


Before I leap in and start patching Xron, I'd like to have a discussion
about how Xron should handle problems.

My first thought is that on errors in the dispatcher thread, Xron should
enter an "error state" where it probes every so often to see whether it
can resume normal operation. The length of time between probes could
increase with each probe, to give good performance with transient
problems whilst preventing Xron from choking resources. 

--
Steve Alexander
Software Enigneer
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] Xron fragility

2000-10-11 Thread Steve Alexander

Chris McDonough wrote:
 
 Steve,
 
 I am also interested in scheduling... though I haven't looked closely at
 Xron.
 
  The Xron product seems rather "fragile" in use.
 
  That is, if things go wrong when an Xron DTML Method is triggered, that
  method doesn't get rescheduled.
 
 Does Xron take an optimistic approach to repeating jobs?  In other words,
 does it assume every job is a one-time job and that the last duty that a
 repeating job performs is to reschedule itself?

It is the Xron DTML Method's responsibility to reschedule itself.
It could be its first duty, however. Then again, as all the work happens
inside a ZODB transaction, it doesn't matter when the reschedule
happens.

 What does the Dispatcher thread do?  Does it fire off worker threads?

Xron has a single dispatcher thread. This thread knows how long to sleep
for until the next job needs to run. It uses Client.py to run a job.
Jobs are Xron DTML Methods. They have a "trigger" method that gets
called through the web from localhost, by the Dispatcher thread.

  Before I leap in and start patching Xron, I'd like to have a discussion
  about how Xron should handle problems.
 
  My first thought is that on errors in the dispatcher thread, Xron should
  enter an "error state" where it probes every so often to see whether it
  can resume normal operation. The length of time between probes could
  increase with each probe, to give good performance with transient
  problems whilst preventing Xron from choking resources.
 
 What are other threads in Xron doing while the Dispatcher thread is hosed?
 What are the other threads?

There are no other threads in Xron.
Xron creates a single thread to do all event dispatching. The work is
done in Zope ZODB threads (or whatever the correct terminology is). The
dispatcher thread communicates with a ZODB thread by using Client to
make a web request.

Xron usually makes requests as the anonymous user. However, I've patched
my Xron to make requests as XronUser by hardcoding (!) the username and
password for that in the RPC.py module of Xron. Then, I've manually
created a XronUser user in my root user folder. I give XronUser the
local roles needed to run methods I want to be scheduled via Xron.

This is not the ideal way to make Xron use authentication. I posted a
proposed design for that to zope-dev in August.

http://lists.zope.org/pipermail/zope-dev/2000-August/006548.html
http://lists.zope.org/pipermail/zope-dev/2000-August/006549.html
http://lists.zope.org/pipermail/zope-dev/2000-August/006550.html

--
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] Xron fragility

2000-10-11 Thread Steve Alexander

Chris McDonough wrote:
 
 As a side note, I do not like the fact that Xron requires you to use special
 DTML methods.  I suppose this is a requirement in this architecture due to
 the fact they need to be autocataloged, but I don't really like that feature
 either :-).

I think Xron could work with anything that has "trigger" and "disarm"
methods, that gets put into the Schedule catalog.


   What does the Dispatcher thread do?  Does it fire off worker threads?
 
  Xron has a single dispatcher thread. This thread knows how long to sleep
  for until the next job needs to run.
 
 Do you think this is this any more effective than having a producer thread
 do a lookup every minute to see what jobs are current, after which it should
 put the current jobs in a queue?

What if you want a small job to be done every 30 seconds?

  It uses Client.py to run a job.
 
 Why is this?  This doesn't make any sense to me on its face.  Why not just
 call the method from a separate thread?

Which separate thread? Do you create a new ZODB thread? That sounds as
if it might use quite a few resources.

Is there a Zope API for making ZODB threads call methods on objects, as
signalled by other threads? I'm guessing the easiest way to do that is
to use Client.py to make a new http request.

 I see... would it be naive if I were to say that I think that a scheduler
 should fire off threads of its own and not rely on an external facility to
 run the jobs?

I'd really like to see a scheduler as a standard part of Zope.
I think it would be good to have scheduled methods called from within
Zope, rather then going through http. I don't know enough about how
ZPublisher/ZODB works to know where to start this though.

--
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] Help, please!!! __call__ problems with DTML templates

2000-10-10 Thread Steve Alexander

Stephen Simmons wrote:


 1.)  How do you magically get the DTML context from 'dtml-var A' without
 having to resort to 'dtml-var "A(_,REQUEST)"' in the templates?

Give your class a class attribute of isDocTemp=1. This tells the DTML 
method calling machinery that you want to receive the namespace as 
REQUEST as the third argument to your __call__ method.

There was a thread on this in zope-dev on and around 26 September, 
subject "more __call__ ..."

 In the __call__ methods of different classes, I've seen some code like:
 'if REQUEST is None and not kw: REQUEST=self.REQUEST' (from
 Catalog.py)

Your method will usually get called with its third argument as the 
namespace, or REQUEST. However, sometimes, it may just be called with a 
"self" argument. The code in Catalog.py is falling back on getting the 
REQUEST out of the self argument, if it is not explicitly passed a 
namespace to work with.

 I can't see any consistency in what these classes are doing, so I don't know
 what I need to do.

Most developers would like more consistency here :-)
I'm hoping that all this will be much much clearer for Zope 2.3. That 
doesn't help much for now though.

 2.)  How to convert an arbitrary text string into rendered DTML inside a
 python product method?
 How do you get the object's properties, REQUEST and acquisition context all
 in the namespace?
 
 I've been trying code like:
template = 'span class="purpose"dtml-var purpose
 fmt="structured_text"/span'
dtml = HTML(template, globals())

If all you want to do is render some Structured Text, you can import and 
use the StructuredText module directly.

 P.S.  ChrisW, searching NIP for "__call__" returns every message with 'call'
 in it, which is not quite the same thing!

For cases like that, I have downloaded the plaintext mail archives as 
available from http://www.zope.org/Resources/MailingLists

I then use unix grep on them to search for just what I need.

--
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] Help, please!!! __call__ problems with DTML templates

2000-10-10 Thread Steve Alexander

Stephen Simmons wrote:

 
 2.)  How to convert an arbitrary text string into rendered DTML inside a
 python product method?
 How do you get the object's properties, REQUEST and acquisition context all
 in the namespace?
 
 I've been trying code like:
template = 'span class="purpose"dtml-var purpose
 fmt="structured_text"/span'
dtml = HTML(template, globals())
rendered = dtml(self, REQUEST)

Here's an except from my Python interactive interpreter:

  import DocumentTemplate
  my_dt=DocumentTemplate.HTML("""dtml-var "1+a"""")
  my_dt(None, {'a':4})
'5'

The object my_dt is callable, and takes the arguments (client, 
namespace). You can put a REQUEST in place of the simple dictionary I 
used above.

If you're trying this, make sure you have the PYTHONPATH environment 
variable set to /your/zope/directory/lib/python


--
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: SkinScript discovery

2000-10-04 Thread Steve Alexander

"Phillip J. Eby" wrote:
 
 Just out of curiosity, did you find this out by reading the draft
 SkinScript reference documentation on the ZPatterns Wiki?

No. I just guessed.
I think I might have read it in the source the other day too.

I'll take a look at the wiki now:
http://www.zope.org//Members/pje/Wikis/ZPatterns/SkinScriptSyntax

  expression

  A DTML-style Python expression. As with DTML, the "_"
  object is available for access to Python built-ins and
  library functions. 

Aha!

I'm looking forward to using the new "OTHERWISE LET" clause too, when
the next release of ZPatterns comes out.

Thanks.


 At 03:45 PM 10/4/00 +0100, Steve Alexander wrote:
 I just found out that you can access all sorts of useful methods in
 SkinScript from the magical "_" namespace variable.
 
 Let's say I have a DataSkin that has a propertysheet "journey", which
 has a "steps" property of type "lines". I can expose its "steps"
 property as an attribute, and also a neatly formatted version of the
 same, using this SkinScript:
 
 WITH self.propertysheets.get('journey') COMPUTE
   steps=getProperty('steps'),
   steps_comma_sep=_.string.join(self.steps, ', ')

--
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] two-phase-commit question

2000-09-30 Thread Steve Alexander

Kapil Thangavelu wrote:

 ZOPE_HOME/lib/python/Shared/DC/ZRDB/TM.py
 
 Glancing over the Transaction TM mixin class... i noticed a line
 commit=tpc_abort=tpc_begin
 
 i can understand tpc_begin=commit, but the abort seems strange. 
 if an abort happens in the two phase commit the equality doesn't 
 make sense to me.
 
 whats going on here? Is this meant to be overidden?

Yes. Override the methods that you need to. The rest are given a 
no-operation default implementation.

The class more or less defines an interface.

def tpc_begin(self, *ignored): pass
commit=tpc_abort=tpc_begin

The assignment you see is just a short-hand way of saying that commit, 
tpc_abort and tpc_begin have the same method signature and the same 
implementation


--
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 )




[Zope-dev] Re: [Zope] Restricting URL access to objects that are not complete web pages

2000-09-21 Thread Steve Alexander

Stephen Simmons wrote:

 
  My thoughts were to use an html_header that tracks how deeply 
components are
  nested so that inner components turn off the page wrapper. This 
achieves 1
  and 2. This also achieves 3 if sections raise an exception if their page
  wrapper is not turned off.

You only want to see standard_html_footer and so forth when
REQUEST.steps[-1]!=fragment_id, so it would not be accessible directly
by URL.

Try something like this for standard_html_footer:

dtml-if "REQUEST.steps[-1]=='standard_html_footer'"
dtml-raise type="NotFound"/dtml-raise/dtml-if
/BODY/HTML

I think using siteaccess for this is more elegant, though. All the
knowledge about what is allowed and what is not is maintained in one
place, and the knowledge can be declared flexibly using regular expressions.

--
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 )




[Zope-dev] adding local roles to folders within a Product

2000-09-21 Thread Steve Alexander

I have a ZClass-based product.

The folder (should I be calling this an Application Object? :-) ) that
contains all the product methods and objects that are accessible via the
web has some local roles defined on it.

I'm making a sort of Wizard to instantiate a new application instance.
This happens by copying an empty application folder from within the
ZClass product, to a chosen place in the standard part of the ZODB
object heirarchy.

I want to define the local roles on the "prototype" folder that is
inside my Product. However, when I go to
Control_Panel/Products/MyProduct/prototype/manage_access, I get the "map
permissions to permissions" screen, rather than the "map permissions to
roles, and define local roles" screen.

Can I define local roles on my prototype folder -- perhaps using an
external method, or DTML API calls to do it?

Or, is there some reason that local roles don't make sense within
products, and so I have to copy my prototype folder to elsewhere in the
ZODB, and then set the local roles?

--
Steve Alexander
Software Enigineer
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 )




[Zope-dev] Re: adding local roles to folders within a Product

2000-09-21 Thread Steve Alexander

Steve Alexander wrote:
 
 I want to define the local roles on the "prototype" folder that is
 inside my Product. However, when I go to
 Control_Panel/Products/MyProduct/prototype/manage_access, I get the "map
 permissions to permissions" screen, rather than the "map permissions to
 roles, and define local roles" screen.
 
 Can I define local roles on my prototype folder -- perhaps using an
 external method, or DTML API calls to do it?
 
 Or, is there some reason that local roles don't make sense within
 products, and so I have to copy my prototype folder to elsewhere in the
 ZODB, and then set the local roles?

Correction: I mean "user-defined roles" rather than local roles.

--
Steve Alexander
Software Enigineer
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] Returning a list of names from a Python Method

2000-09-19 Thread Steve Alexander

Michael Bernstein wrote:

 Michael Bernstein wrote:
 
 Does anyone on the list know how to change the getUserNames
 Python method to return a list of names instead of a list of
 objects?
 
 The code in question is this:
 
   user_ids=self.UserSource.getPersistentItemIDs()
 
   names=[]
   for i in user_ids:
   names.append(self.getItem(i))
   return names
 
 
 Ok, I solved this little problem (and of course it looks
 obvious once I've done it):
 
names=[]
for i in user_ids:
names.append(i)
return names

You can also use the Python map function for this. It will be more 
efficient that iterating through user_ids using "for i in user_ids:"

return map(None, self.UserSource.getPersistentItemIDs())
--
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] Using PropertySheets

2000-09-19 Thread Steve Alexander

Erich Seifert wrote:

 

 * I can't pass a default value to a tokens property. How to?

Can you pass in a space-separated string, such as '' or 'token1' or 
'token1 token2'?

 * I can't pass a default value to a boolean property. How to?

How are you trying to do this? You can pass in the string '1' for true 
and '0' for false.

 Could someone please give me some example code or hints?

It would really help to see some of the code you're already using. Can 
you also say a bit about what you are trying to do overall?

--
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] Can ZPatterns Plugins be used separately?

2000-09-18 Thread Steve Alexander

Kevin Howe wrote:

 Hi, I'm wondering if it is possible to use ZPattern Plugins in a
 non-ZPatterns Product? Allowance for Plugins would be a very useful feature
 in many applications.

You can use PlugIns without using the rest of ZPatterns, such as 
DataSkins and Racks. You still have to have the ZPatterns product 
installed, obviously. I can see this becoming even more useful when 
ZClasses work with PlugIns. This may be a while off, though.

I'm still in favour of splitting ZPatterns into separate DataSkins and 
PlugIns packages in the next feature release.

--
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] Membership and Local Roles

2000-09-18 Thread Steve Alexander

Michael Bernstein wrote:

 I posted this to the PTK list on Friday, but didn't get any responses
 over the weekend, so I'm reposting here.
 
 I feel that a barrier to Loginmanager and Membership becoming more
 generally usable for site builders is it's current lack of support for
 local roles. Specifically, members do not show up in the local roles
 screen (manage_listLocalRoles) user list.
 
 Through the magic of grep and find, I think I've identified the relevant
 sections of code in Zope that need to be duplicated in Membership (or
 maybe in LoginManager).

I think you've found out why local roles don't work. Congratulations on 
a successful code hunting mission :-)

I don't know for sure, but I think the API for returning a list of users 
has been omitted intentionally. A LoginManager instance might "contain" 
(or rather, provide authentication to) thousands of users. Listing all 
of these would arguably break the management interface.

Perhaps what LoginManager (or Membership) needs is a way of stating, for 
each user, whether they should appear in the local-roles list. This 
could be a checkbox for each user, or it could be a method that gets 
called to specify the users that appear, for example, using a regular 
expression, or perhaps based on some quality of the user object.

You should still be able to use local roles, even now, by using an 
external method to add local roles where you need them, and explicitly 
give the user id. You just can't select from the management interface.

--
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 )




[Zope-dev] ZPatterns bug: infinite recursion with External Attribute Provider

2000-09-17 Thread Steve Alexander

ZPatterns-0-4-2a2

When I use an External Attribute Provider, I get an infinite recursion
problem, and Zope hangs.

This is because DataManager (in DataManagers.py) uses normal getattr()
and object.__skinSlot__ methods to get and set the special attribute
__skinSlot__ on DataSkins.

Thus, the system tries to store the __skinSlot__ attribute in the
DataSkin instance by storing the __skinSlot__ attribute in the DataSkin
instance by storing the __skinSlot__ attribute in the DataSkin instance
by...

I can fix this, by patching DataManager to use client.__dict__ instead:

def _readableSlotFor(self,client):
#slot = getattr(client,'__skinSlot__',_marker)
slot = client.__dict__.get('__skinSlot__',_marker)

if slot is _marker: return {}

client._setSlot(slot); return slot

def _writeableSlotFor(self,client):
#slot = getattr(client,'__skinSlot__',_marker)
slot = client.__dict__.get('__skinSlot__',_marker)

if slot is _marker:
#slot = client.__skinSlot__ = PersistentMapping()
slot = client.__dict__['__skinSlot__'] = PersistentMapping()

client._setSlot(slot); return slot


This works, in as far as I can do things like add sub-objects to a
ZClass that derives from DataSkin and ObjectManager without infinite
regress. However, I still get an attribute error. This is because the
External Attribute Provider only offers to set and delete its
attributes. I'm confused as to why this should be -- surely the External
Attribute Provider should offer to get the same attributes as it is
offering to set and delete?

Or, do I have to use an extra provider in the form of some SkinScript or
a Generic Attribute Provider to do the getting?

I tried altering namesForRegistration, so that the External Attribute
Provider would offer to getattr for "*", then refreshed the customizer
I'd put the EAP into.

 def namesForRegistration(self,container):
 """XXX"""
 
 return {
 'provides':('attributes',),
 'setattr': self.Attributes, 'delattr': self.Attributes,
 'getattr': self.Attributes
 }


I can now add sub-objects to my ZClass instances, and I can traverse to
those sub-objects by typing them into the URL field of my browser.
However, I can't get a list of the sub-objects by calling objectIds.

I'm trying to make sense of External Attribute Provider so that I can
write a BTreeAttributeProvider for DataSkinAddons, as discussed on the
zope-dev list at the end of August, subject "BTreeFolder /w Customizer
support".

Any pointers appreciated.

--
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 based CD example. Halfway there! Need help

2000-09-16 Thread Steve Alexander

James Johnson wrote:

 I've got the storage entry part down.  I can't seem to get the data 
 out. It seems to me that I would put an Index_html method in the 
 specialist but I get a aq_base error when trying to put one in. So I 
 put it in my ZClass dataskin.  Here is the code I'm using below.
 I tried to access it many ways. All I get is a blank sheet.
 I tried using dtml-let myPPS="propertysheets.get('cd_info')"
 dtml-var "myPPS.getProperty('artist')'
 But it says object does not have getProperty.
 Hmm.

Add a SkinScript method to your Specialist, under the Data-PlugIns tab, 
with something like this:

WITH self.propertysheets.get('cd_info') COMPUTE
artist=getProperty('artist'),
label=getProperty('label')

You can then write your ZClass index_html and use dtml-var artist or 
dtml-artist; where you want the artist, and similarly with label.

--
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] Advice on DTMLDocument

2000-09-15 Thread Steve Alexander

Andy McKay wrote:

 Hi there,
 
 Well a while ago I came across a bug that I couldnt cut and paste and
 object. A few people helped me out on that, thanks. Ive had a week of
 squishing bugs and finally got to this one. The reason why? I was
 subclassing DTMLDocument but using my own __init__ (similar to one where I
 dont subclass from DTMLDocument), where I didnt fiddle with __name__. The
 result was when absolute_url() was called I was getting:
 http://fork:8080/code/test/ElementWithAttributes  !

In your __init__ method, try putting this line in:

YourClassName.inheritedAttribute('__init__')(self, id)

This is assuming that you have the argument "id" in your __init__ method.

I've no idea whether it will solve your problem, as I haven't tried to 
reproduce it.

--
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 )




[Zope-dev] ZPatterns bug: typo in Transactions.py

2000-09-14 Thread Steve Alexander

ZPatterns, latest released version.
def abort_sub(self, transaction):

In Transactions.py, aborting a subtransaction will fail because of a
method signature mismatch.

Was:

def abort_sub(self, transaction):
self.tpc_abort()

Should be:

def abort_sub(self, transaction):
self.tpc_abort(transaction)


I think there's something not quite right about the way ZPatterns is
handling subtransactions, even with this patch, and the other one
related to Transactions.py that I posted a while back.

Is there any detailed documentation about how Zope transactions and
subtransactions are supposed to work?

--
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 )




[Zope-dev] Re: ZPatterns (sub-)transaction problems

2000-09-14 Thread Steve Alexander

"Phillip J. Eby" wrote:
 
 I will try to have a ZPatterns snapshot release made this week that will
 include those fixes (plus the fix for a problem with DynPersist that we
 also discovered yesterday).

Great. I'm looking forward to that.


Can we lose DynPersist altogether for this release? 

Or are there still folks out there using ZPatterns with 2.1.6?

--
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] Context Acquisition - Security Hole?

2000-09-14 Thread Steve Alexander

Chris Withers wrote:

 Shane Hathaway wrote:
   How should I got about petitioning
   for
   dtml-var anobject aq_context to become valid syntax?
  
  There's one little (okay, big) problem with this idea: aq_context
  strips the security context.  In fact, it could be used to confuse the
  security machinery.
  
  Let's say I'm Joe Hacker and I have set up membership at
  www.zope.org/Members/jhacker.  I create a DTML method called index_html
  with this:
  
  dtml-with Members
  dtml-with hathawsh aq_context
dtml-call expr="index_html.manage_edit('1 0WN U')"
  /dtml-with
  /dtml-with
 
 Alright, I give up :-(
 This would be really useful, but if it's going to open up security holes
 everywhere, then I best leave it alone :-S

You could still have an aq_context attribute that would stay secure. It 
would just be very inefficient. The security checks still follow 
standard acquisition, but the object that is returned from an 
acquisition search is chosen context first.

Without further optimisation, this means a containment security check 
for each element of the context. Which kind of suggests worse than 
linear performance as the context path grows.

--
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 )




[Zope-dev] Re: ZPatterns: Error: User error! :-/

2000-09-11 Thread Steve Alexander

Steve Alexander wrote:
 
 I have a customizer folder with various data-plugins and customizers.

snipped
 
   File lib/python/Products/ZPatterns/Providers.py, line 178, in
 namesForRegistration
 (Object: PlugInBase)
 TypeError: (see above)
 
 I'll start to look into this.
 
 Any advice would be most welcome.

Found the problem... I did have different versions of ZPatterns on both
machines after all.

ZPatterns-0-4-1snap1
ZPatterns-0-4-2a1

Sorry... user error :-)
 
--
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 )




[Zope-dev] ZPatterns: Error reimporting .zexp containing Folder w/ CustomizerSupportSupport

2000-09-11 Thread Steve Alexander

I have a customizer folder with various data-plugins and customizers.

I just exported it from one zope installation, for importing into one on
a different server.

The installations are more or less identical -- same zope version, same
products.

When I try to reimport it, I get the following error:

  Error Type: TypeError
  Error Value: No data plug-ins available to link to in /emb

Traceback (innermost last):
  File lib/python/ZPublisher/Publish.py, line 222, in publish_module
  File lib/python/ZPublisher/Publish.py, line 187, in publish
  File python/Zope/__init__.py, line 221, in zpublisher_exception_hook
(Object: ApplicationDefaultPermissions)
  File lib/python/ZPublisher/Publish.py, line 171, in publish
  File lib/python/ZPublisher/mapply.py, line 160, in mapply
(Object: manage_importObject)
  File lib/python/ZPublisher/Publish.py, line 112, in call_object
(Object: manage_importObject)
  File lib/python/OFS/ObjectManager.py, line 535, in manage_importObject
(Object: ApplicationDefaultPermissions)
  File lib/python/OFS/ObjectManager.py, line 290, in _setObject
(Object: ApplicationDefaultPermissions)
  File lib/python/Products/ZPatterns/PlugIns.py, line 211, in
manage_afterAdd
(Object: PlugInBase)
  File lib/python/OFS/ObjectManager.py, line 298, in manage_afterAdd
(Object: PlugInBase)
  File lib/python/Products/ZPatterns/PlugIns.py, line 211, in
manage_afterAdd
(Object: Transactional)
  File lib/python/OFS/ObjectManager.py, line 298, in manage_afterAdd
(Object: Transactional)
  File lib/python/Products/ZPatterns/PlugIns.py, line 64, in
manage_afterAdd
(Object: PlugInBase)
  File lib/python/Products/ZPatterns/PlugIns.py, line 120, in _addPlugIn
(Object: Transactional)
  File lib/python/Products/ZPatterns/PlugIns.py, line 168, in
manage_refreshPlugIns
(Object: Transactional)
  File lib/python/Products/ZPatterns/PlugIns.py, line 332, in
manage_refreshPlugIns
  File lib/python/Products/ZPatterns/Providers.py, line 101, in
_PlugInsChanged
  File lib/python/Products/ZPatterns/Providers.py, line 178, in
namesForRegistration
(Object: PlugInBase)
TypeError: (see above)

I'll start to look into this.

Any advice would be most welcome.

--
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] PATH_TRANSLATED delimted with backslash ?

2000-09-10 Thread Steve Alexander

Evan Simpson wrote:
 
 From: "Steve Alexander" [EMAIL PROTECTED]
obj = self.restrictedTraverse(REQUEST.PATH_TRANSLATED)
 
  This stopped working when I tried the software on Windows.
 
  Bug or feature?
 
 I'm not sure, but I'm *very* curious what you're trying to accomplish with
 this code.  A better equivalent would probably be obj =
 self.getPhysicalRoot().restrictedTraverse(REQUEST.steps).

I'm producing a set of breadcrumb-style links. I want to test whether
the object at the requested URL has the attribute "breadcrumbs_text",
because if so, that text should be used instead of the results of my
breadcrumbs algorithm.

I have an object that is a DTML Document. It has the property
"breadcrumbs_text" set.

My breadcrumbs external method is called from standard_html_header.

When I look at the DTML Document through the web, the "self" object
passed to the breadcrumbs external method is the folder that contains
the DTML Document.
(I thought that should only be the case for DTML Methods!)

So, in order to check the existence of the attribute "breadcrumbs_text",
I needed to get hold of the object that was requested. I'm not using
virtual hosting for this project (although I will be later), so I threw
REQUEST.PATH_TRANSLATED in there as I could see from inspecting REQUEST
that it would give me what I needed.

It looks like using REQUEST.steps is better because it will continue to
work with virtual hosting.  I'll change the method to use REQUEST.steps.
Thanks.

--
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] SkinScript, and family

2000-09-09 Thread Steve Alexander

Bill Anderson wrote:

 Steve Spicklemire wrote:
  
  Hi Bill,
  
 I doubt that skinscript is going to help with 'potentially
  complicated calculations'.
 
 After looking, I don't think it wil either.
 
 I am building statistics of of a call Tracking System. For example, each
 ticket has a response time property, and one of the graphs needs average
 response time.
 
 Looks like PythonMehtods is the winner


Well, I'd start by using a CatalogingTrigger that responds to events 
related to your Tickets, and records the ticket_id, ticket_date and 
response_time in a ResopnseTimes ZCatalog.

Then, I'd use ZCatalog queries to get average response times for various 
periods of time.

I can't see a use for SkinScript in there, though :-)

ps. I am working on a skin script howto. Expect to see something after I 
return from a conference on Monday.

--
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 )




[Zope-dev] PATH_TRANSLATED delimted with backslash ?

2000-09-09 Thread Steve Alexander

I just tried out on Windows 98 a Zope application that was developed on
Linux.

Everything worked fine, except that REQUEST.PATH_TRANSLATED changed to
be delimited by backslashes on Windows 98, whereas it is delimited by
slashes on Linux.

This caught me out, as I'd been using it raw in an external method:

  obj = self.restrictedTraverse(REQUEST.PATH_TRANSLATED)

This stopped working when I tried the software on Windows.

Bug or feature?

--
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 )




[Zope-dev] ZPatterns: transaction bug

2000-09-03 Thread Steve Alexander

While updating a load of DataSkins all together using a ZCatalog, I got
this error:


2000-09-03T08:03:13 PANIC(300) ZODB A storage error occurred in the last
phase of a two-phase commit.  This shouldn't happen. The application may
be in a hosed state, so transactions will not be allowed to commit until
the site/storage is reset by a restart. 
Traceback (innermost last):
  File lib/python/ZODB/Transaction.py, line 296, in commit
  File lib/python/Products/ZPatterns/Transactions.py, line 108, in
tpc_finish
  File lib/python/Products/ZPatterns/Transactions.py, line 137, in
end_tran
  File lib/python/Products/ZPatterns/Transactions.py, line 48, in
_unregister
(Object: ProviderContainer)
KeyError: _v_registered


The line from Transactions.py in question is:

def _unregister(self):
del self._v_registered

From a little bit of instrumentation, I see that one of my Customizer
instances is getting unregistered twice in a row.

An obvious naive fix is to put the del line in a try-except block, or to
change it to

  if self._v_registered: del self._v_registered


From a lot of instrumenting code, tinkering and reading up on the ZODB
transaction system, I think I've found what the problem is.

The error happens when the ZCatalog attempts to commit a subtransaction.

___
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] ZPatterns: transaction bug

2000-09-03 Thread Steve Alexander

**Darn**; I pressed the send button on my mail client by accident while
still working on this one. Ignore the last message.

I think the error is to do with the way that
ZPatterns.Transactions.Reporter doesn't do anything special for
subtransactions. On committing a subtransaction, it commits the
top-level transaction that it knows about.

Then again, I'm new to the way ZODB handles transactions, so I might
well be wrong here.

More later...

--
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 )




[Zope-dev] ZPatterns transactions bug

2000-09-03 Thread Steve Alexander

Here's a trace of all the transaction calls to do with a particular
customizer.

I have instrumented ZPatterns.Transactions.Transactional like this:


def _register(self):
if self.id=='customize_items':
print "\n -- REGISTER %s" % self._v_registered
if self._v_registered: return
get_transaction().register(Reporter(self))
self._v_registered = 1


def _unregister(self):
try:
del self._v_registered
if self.id=='customize_items':
print "\n_unregister: NORMAL OPERATION"
# import traceback
# traceback.print_stack()
except:
print "\n\n_unregister: ERROR"
# import traceback
# traceback.print_stack()

ZPatterns.Transactions.Reporter in most of the methods. Specifically:

def tpc_begin(self, transaction, subtransaction=None):
if self.client.id=='customize_items':
print '\n -- TPC begin %s sub=%s' % (self, subtransaction)
self.tpc_entered = 1


Also: ZCatalog.py

def catalog_object(self, obj, uid):
""" wrapper around catalog """
self._v_total = (self._v_total +
 self._catalog.catalogObject(obj, uid,
self.threshold))

if self.threshold is not None:
if self._v_total  self.threshold:
print ' -- ZCatalog commit subtransaction start'
# commit a subtransaction
get_transaction().commit(1)
# kick the chache, this may be overkill but ya never
know
self._p_jar.cacheFullSweep(1)
self._v_total = 0
print ' -- ZCatalog commit subtransaction complete'


The trace starts when I try to update a ZCatalog containing lots of
DataSkin-derived instances.



 -- REGISTER 0

... lots of REGISTER 1

 -- REGISTER 1
 -- ZCatalog commit subtransaction start

 -- TPC begin Products.ZPatterns.Transactions.Reporter instance at
89600f8 sub=1

 -- TPC commit Products.ZPatterns.Transactions.Reporter instance at
89600f8

 -- TPC finish Products.ZPatterns.Transactions.Reporter instance at
89600f8

 -- TPC end tran Products.ZPatterns.Transactions.Reporter instance at
89600f8

_unregister: NORMAL OPERATION
 -- ZCatalog commit subtransaction complete

 -- REGISTER None

 -- REGISTER 1

 -- TPC begin Products.ZPatterns.Transactions.Reporter instance at
89f98b8 sub=1

 -- TPC commit Products.ZPatterns.Transactions.Reporter instance at
89f98b8

 -- TPC finish Products.ZPatterns.Transactions.Reporter instance at
89f98b8

 -- TPC end tran Products.ZPatterns.Transactions.Reporter instance at
89f98b8

_unregister: NORMAL OPERATION

 -- TPC commit_sub Products.ZPatterns.Transactions.Reporter instance at
89600f8

 -- TPC begin Products.ZPatterns.Transactions.Reporter instance at
89600f8 sub=None

 -- TPC commit_sub Products.ZPatterns.Transactions.Reporter instance at
89f98b8

 -- TPC begin Products.ZPatterns.Transactions.Reporter instance at
89f98b8 sub=None

_unregister: ERROR, can't del self._v_registered



I don't know enough about ZODB transactions, and the intent of
ZPatterns.Transactions to do anything more at present.

I did note in ZODB/Transaction.py this comment. Perhaps it is relevant?


  # - For every jar for which we've called tpc_begin on,
  #   we either call tpc_abort or tpc_finish. It is OK
  #   to call these multiple times, as the storage is
  #   required to ignore these calls if tpc_begin has not
  #   been called.


--
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] ZPattens Question? Guestbook example

2000-09-03 Thread Steve Alexander

Hi James,

Please don't post to the list in HTML.

James Johnson wrote:

 
 Hello,
 I'm trying to get the basic app building concept down with
 ZPatterns.
 Forgive me if I'm way off the mark.  I'm building off the guest
 book
 example from the new Zope book.  What I've done is created a
 product
 folder call Gbook.  Inside I've created a dtml method index_html, a
 specialist named Guestbook and a Dataskin instance called
 Guestbook_entry. I have one property sheet named GBookProps defined
 for dataskin ZClass.  Instead of storing the guestbook entries in
 documents I'm trying to store them using the dataskin database.
 
 In the Specialist(Guestbook) I have 3 methods addEntry,
 addEntryAction, and addEntryForm
 When I call addEntry I get.
 TypeError
 sequence-index must be an integer
 I thought I was so close to understanding me not understanding. :)
 It seems to me that the "only" way to produce a ZPatterns based
 product is to do it from python.
 How about this, should I be trying to add entries this way?  
 """dtml method addEntry"""
 dtml-var standard_html_header
 center
 h2 Inserting new Guest Book Table Info Item!/h2
 dtml-let id="'entry_%d' % len(self.objectIds())"
  ni="newItem(Guestbook)"
 /dtml-let

This is a bit odd -- you're closing your dtml-let tag immediately after 
opening it.
Also, I don't understand your call to newItem. You should be passing an 
id into it.

dtml-call "ni.propertysheets.manage_addPropertySheet
 (id='GBookProps', ns=''

You probably ought to close the bracket, quote and tag here.

 dtml-let nips="ni.propertysheets.get('GBookProps')"

The variable "ni" won't be bound to anything in particular here.


dtml-call "nips.manage_addProperty('guest_name', guest_name,
 'string')"
dtml-call "nips.manage_changeProperties(REQUEST)"
 
 /dtml-let
 form action=index_html
 input type=submit value="OK"
 /form
 /center

You can use ZPatterns from DTML alone quite easily. However, some things 
are easier from an external method or a python method.

--
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] ZPattens Question? Guestbook example

2000-09-03 Thread Steve Alexander

James Johnson wrote:
 
 I wonder if you are planning on releasing some UML stuff related to
 ZPatterns and Zope?

I don't think UML is a very good match for describing either the
internals of ZPatterns, or for describing systems built using ZPatterns
-- or Zope for that matter.

 I use a Freeware product called DOME. It has
 support for UML and COAD-YOURDON OOA.  

For Zope and ZPatterns work, I prefer the Coad notation to UML. It is
more Object-oriented, whereas UML is more class-oriented.

I tend to use a whiteboard and digital camera for modeling work. Either
that, or pens and paper.

 I'm don't have any formal
 training so I'm still trying to figure out what it all means.

Keep on figuring. I think you're doing ok :-)

 If you have any example diagrams that you can share that would be
 most kind.

What would you most like a diagram of? I find diagrams generally most
useful when they come along with a description in words.

 Here is the code I was trying to use in the first place.
 
 h2 Inserting new Guest Book Table Info Item!/h2
 dtml-let id="'entry_%d' % len(self.objectIds())"

I can see what you're trying to do here. You can't do it like this
though.

You can't use "len" or "self" in dtml. The variable "self" is kind of
taken as read in most cases. Use "_.len()" for "len()". So, you could
use 

  dtml-let id="'entry_%d' % _.len(objectIds())"

However, although this will return a value, it still won't do what you
want. The items that you store in a specialist actually live in a Rack.
They are not visible as normal sub-objects that you can access using
self.objectIds().

The number returned by len(self.objectIds()) represents the number of
DTML methods, DTML documents, folders, External methods, Python methods,
images, files and so forth, plus the number of Racks and Data-PlugIns in
the specialist.

Rather that try to give you new item a unique sequential id, try just
giving it a unique id.

You can use a method in a Rack called "newKey" for this. Then, this
method will be called to determine the new id, you pass _.None (from
DTML) or None (from a Python method or an External method).

I use this external method to generate a new unique key for my racks. I
put this inside the Rack, from the rack's methods tab.

from DateTime import DateTime

def newKey(self):
# self is a rack instance
fk = lambda x: 'entry-%d' % x
n = int(DateTime().timeTime())
max_tries = 10
key = fk(n)
while max_tries and self.getItem(key) is not None:
n = n + 1
max_tries = max_tries-1
key = fk(n)
return key


   ni="Guestbook.newItem(id)"
 
 dtml-call "ni.propertysheets.manage_addPropertySheet
 (id='GBookProps', ns='')"

You'll want a dtml-let here I should think.

   nips="ni.propertysheets.get('GBookProps')"
 dtml-call "nips.manage_addProperty('guest_name', guest_name,
 'string')"
 dtml-call "nips.manage_changeProperties(REQUEST)"


And, of course, another dtml-let closing tag here.
 
 /dtml-let

--
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] Converters.field2date, allow empty string to return None?

2000-09-02 Thread Steve Alexander

Brad Clements wrote:

 One thing that has been bothering me is that I can't easily test my 
 ZSQL Methods if they accept a date type unless I completely fill all the 
 date arg types.
 
 For example, if the sqlmethod has argument type 
   startdate:date=''
 
 
 and in the body I have
  dtml-if startdate ...
 
 When i use the test form, I can't leave the date field empty, otherwise I 
 get a conversion error from Converters.field2date()
 
 I also have this problem with any form that has type date, if the end-user 
 doesn't put a date in the form, I get a conversion error.
 
 Its okay with me to receive an empty string, which gets converted to 
 None .. I just put NULL in the sql database.
 
 So .. what's the correct fix to allow empty fields to return either '' or 
 None from field2date?

I take the form input as a string, and use an intermediate method that 
checks whether it makes a valid date, and massages it into shape if not.

For an empty form field, what is best to do depends on the application. 
When I'm using PropertySheets, for example, I often use a boolean 
property called "date_is_known". If the date is left blank, I set the 
date to 3000-01-01 UTC, and date_is_known to 0. Otherwise, the date gets 
set appropriately, and date_is_known is set to 1. I set the date so far 
in advance so that if it inadvertantly creeps into some analysis 
(because someone forgot to check date_is_known) it will be obvious that 
something is up. Of course, this does mean that my systems have a 
year-3000 problem. Perhaps I should use 3 instead? g

You can redirect to the form, or an error page, or the form with an 
error variable set, if the date is not parsable, or not valid for your 
application.

As you're using a SQL database that supports NULL values in date fields, 
you can obviiously process the results to mean the same thing.

Oh, if you're just asking people for a date, rather than a date and 
time, I'd suggest appending a standard timezone to the date before you 
store it. Otherwise, you may have problems with days slipping around if 
your server changes timezone or you enter daylight savings time. This is 
more of an issue near to the GMT zone.

--
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] Compatibility issues: ZPatterns 0.4.2

2000-09-01 Thread Steve Alexander

Steve Alexander wrote:

 Phillip J. Eby wrote:

  Now, I can provide *unfiltered* linkage by direct delegation, but this
  would mean dropping the ability to selectively take only certain
  attributes
  or sheets from the parent.  But I suppose that, compared to dropping the
  capability to acquire altogether, this might be preferable.
 
 
 This sounds fine for my use of Triggers that apply across everything
 that a Specialist manages.

I've got ZPatterns 0.4.2a1 now.

I see that Folders w/ customizer support now have their own 
Data-plug-ins tab (they didn't before), and that it does direct 
delegation, rather than filtered forwarding.

Does this mean that your suggestion above has become a design decision 
for ZPatterns? Data plug-ins directly in Customizers and Specialists 
aren't due to be deprecated? I'm guessing that this is the case.

Also, it is a bit of a pain to refresh each of the DataManager instances 
on each upgrade. How about an external method in ZPatterns to walk the 
object tree and update instances as required? Perhaps it could use 
ZopeFind. Or, seeing as Specialists and Customizer folders contain other 
DataManagers, could you add a button to a tab in Specialists and 
Customizer folders that refreshes them, and recursively all the 
DataManagers they contain? Then I'd just have to go to each top-level 
datamanager and refresh them when I upgrade.


Oh also, FYI, we're using ZPatterns for a couple of medium sized 
projects, one of which is functionally complete. SkinScript has proved 
extremely useful. I've been able to evolve an application in a very 
clean way using propertysheets and SkinScript, whereas before I'd have 
had to retrofit a custom base class.

Phillip and Ty, thanks for your sharing your work and sharing your ideas.

 
-- 
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] Compatibility issues: ZPatterns 0.4.2

2000-09-01 Thread Steve Alexander

"Phillip J. Eby" wrote:
 
 I see that Folders w/ customizer support now have their own
 Data-plug-ins tab (they didn't before), and that it does direct
 delegation, rather than filtered forwarding.
 
 Direct delegation?  I've lost you here.  If it's doing that, then
 something's broken.  

sorry -- I didn't really mean that.

 Check and see if you have any "Link to Parent Data
 Plug-ins" in your customizers (they're added by default now on new
 customizers).  You can filter the parent providers by selecting the ones
 you want to leave out on the "exclude" property.

That's what I meant. Great.

 Does this mean that your suggestion above has become a design decision
 for ZPatterns? Data plug-ins directly in Customizers and Specialists
 aren't due to be deprecated? I'm guessing that this is the case.
 
 Argh.  I knew there was something (else) I was forgetting to document in
 the CHANGES file.  I had better go fix that now.

I'll take that as a "yes" then. :-)

 Also, it is a bit of a pain to refresh each of the DataManager instances
 on each upgrade. How about an external method in ZPatterns to walk the
 object tree and update instances as required? Perhaps it could use
 ZopeFind. Or, seeing as Specialists and Customizer folders contain other
 DataManagers, could you add a button to a tab in Specialists and
 Customizer folders that refreshes them, and recursively all the
 DataManagers they contain? Then I'd just have to go to each top-level
 datamanager and refresh them when I upgrade.
 
 It isn't actually be necessary to refresh on every upgrade.  IIRC, that
 note about refreshing is in reference to pre-0.4.x versions.  I guess I
 need to fix that too...

I had a bit of oddness with a Folder with Customizer Support on
upgrading from 0-4-1snap1 to 0-4-2a1. Until I added then removed a
datamanager, there was some attribute error occuring. Unfortunately, I
didn't look into it before I accidentally fixed it. I'll be upgrading
another zope instance with ZPatterns later on, so I'll watch out for the
same behaviour then.

 do you think you could
 perhaps be persuaded to write a short reference and/or tutorial for us to
 include (perhaps as a help screen from the SkinScript method object's
 management screens)?  Thanks.

I have a DataSkins how-to / short introduction that is about half
complete. I was hoping to get this out by today, but then I discovered
SkinScript, and also real work got in the way :-)

I'll try and get it finished this weekend. Perhaps some of that can be
reused as help in the management screens.

--
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 )




[Zope-dev] ZCatalog: text searches fail with sort_on + patch

2000-09-01 Thread Steve Alexander

I'm getting an error in Catalog when I specify sort_on on a field-index,
and also search on a text index.

Zope 2.2.1, Python 1.5.2


Error Type: TypeError
Error Value: loop over non-sequence

Traceback (innermost last):
  File lib/python/ZPublisher/Publish.py, line 222, in publish_module
  File lib/python/ZPublisher/Publish.py, line 187, in publish
  File lib/python/Zope/__init__.py, line 221, in
zpublisher_exception_hook
(Object: ProviderContainer)
  File lib/python/ZPublisher/Publish.py, line 171, in publish
  File lib/python/ZPublisher/mapply.py, line 160, in mapply
(Object: search)
  File lib/python/ZPublisher/Publish.py, line 112, in call_object
(Object: search)
  File lib/python/OFS/DTMLDocument.py, line 177, in __call__
(Object: search)
  File lib/python/DocumentTemplate/DT_String.py, line 528, in __call__
(Object: search)
  File lib/python/DocumentTemplate/DT_In.py, line 630, in renderwob
(Object: SiteIndex)
  File lib/python/Products/ZCatalog/ZCatalog.py, line 463, in
searchResults
(Object: Traversable)
  File lib/python/Products/ZCatalog/Catalog.py, line 602, in
searchResults
  File lib/python/Products/ZCatalog/Catalog.py, line 555, in
_indexedSearch
TypeError: (see above)

This seems to be a simple type incompatibility error.

Attached is a patch that fixes this.

In Collector, http://classic.zope.org:8080/Collector/1586/view

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

*** Catalog.py.orig
--- Catalog.py
***
*** 552,558 
  if intset: 
  append((k,LazyMap(self.__getitem__, intset)))
  else:
! for r in rs:
  append((sort_index._unindex[r],
 LazyMap(self.__getitem__,[r])))
  
--- 552,558 
  if intset: 
  append((k,LazyMap(self.__getitem__, intset)))
  else:
! for r,x in rs.items():
  append((sort_index._unindex[r],
 LazyMap(self.__getitem__,[r])))
  



[Zope-dev] ZPatterns bug: Customizers don't rename well

2000-08-29 Thread Steve Alexander

ZPatterns 0-4-1snap1
Zope 2.2.1

To reproduce the error, do this:

  Create a Folder with Customizer support

  Give it a Customizer

  Rename that Customizer

  Press the "Customizers" tab in the folder


Zope Error

Error Type: AttributeError
Error Value: __customizerRegistry__

Traceback (innermost last):
  File /lib/python/ZPublisher/Publish.py, line 222, in publish_module
  File /lib/python/ZPublisher/Publish.py, line 187, in publish
  File /lib/python/Zope/__init__.py, line 221, in
zpublisher_exception_hook
  File /lib/python/ZPublisher/Publish.py, line 171, in publish
  File /lib/python/ZPublisher/mapply.py, line 160, in mapply
(Object: manage_main)
  File /lib/python/ZPublisher/Publish.py, line 112, in call_object
(Object: manage_main)
  File /lib/python/App/special_dtml.py, line 120, in __call__
(Object: manage_main)
(Info: /lib/python/Products/ZPatterns/www/PlugInGroup.dtml)
  File /lib/python/DocumentTemplate/DT_String.py, line 528, in __call__
(Object: manage_main)
  File /lib/python/App/special_dtml.py, line 120, in __call__
(Object: manage_below)
(Info: /lib/python/Products/ZPatterns/www/showCustomizers.dtml)
  File /lib/python/DocumentTemplate/DT_String.py, line 528, in __call__
(Object: manage_below)
  File /lib/python/DocumentTemplate/DT_In.py, line 630, in renderwob
(Object: manage_registry)
  File /lib/python/Products/ZPatterns/Customizers.py, line 63, in
manage_registry
AttributeError: (see above)


The error occurs because the rename method redirects to:

http://puffin.cat-box.net:7080/test/Customizers_

Pressing the "customizers" tab yields the url:

http://puffin.cat-box.net:7080/test/Customizers_/Customizers_/manage_workspace

--
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 )




[Zope-dev] inheritedAttribute

2000-08-28 Thread Steve Alexander

In the latest Zope source, I've noticed calls to inheritedAttribute in
the Python code.

I've found the C source code in ExtensionClass.c, but it doesn't help me
understand when I should use it from Python, and why.


*reads more source*

Ah! About 70 lines further on in ExtensionClass.c:

   "inheritedAttribute(class,name) -- Get an inherited attribute\n\n"
   "Get an attribute that would be inherited if the given (extension)\n"
   "class did not define it.  This method is used when overriding\n"
   "inherited methods.  It provides 2 advantages over accessing\n"
   "\n"
   "attributes directly through a superclass:\n"
   "\n"
   "1. The superclass need not be known,\n"
   "\n"
   "2. The superclass may be a Python class.  Without this method, it
would\n"
   "   be possible to override methods inherited from python classes
because\n"
   "   unbound methods gotten from Python classes cannot be called with
\n"
   "   extension class instances.  \n"


Is there some documentation of this on zope.org or dev.zope.org that
I've missed?

Thanks.

--
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] New version of BTreeFolder. Just a Newbie Question

2000-08-28 Thread Steve Alexander

Bill Anderson wrote:

 
 Any chance at a BTree Folder w/customizer suppor tin the near future? :)

I did some work towards this. However, I didn't continue.

I realised that I could get the same effect by having a BTreeFolder 
inside a Customizer Folder. The only downside is a slightly longer URL 
for objects in the BTreeFolder.

--
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 bug with patch

2000-08-28 Thread Steve Alexander

"Phillip J. Eby" wrote:
 
 At 10:22 AM 8/27/00 +0100, Steve Alexander wrote:
 
 I've fixed this by adding a test to the start of __set_attr__ of
 DataSkins.py:
 
 def __set_attr__(self,name,val,_v_dm_=_v_dm_):
 +   if name=='id' and val==self.__dict__['id']:
 +   return
 dm = self.__dict__[_v_dm_]
 
 This looks reasonable, and backward-compatible, since __init__ guarantees
 the dict will have an id.  I'm not thrilled with adding more overhead to
 attribute setting, however, so I'll probably do it like this:
 
 try:
 dm = self.__dict__[_v_dm_]
 except KeyError:
 if name=='id' and val==self.__dict__['id']: return
 raise
 
 Hopefully this should only perform the extra computations when the first
 part fails...

Are Python classes derived from DataSkin supposed to call
DataSkin.__init__ ?

Anyway, perhaps this would be a small improvement:

try:
dm = self.__dict__[_v_dm_]
except KeyError:
if (name=='id' and self.__dict__.has_key('id') 
and val==self.__dict__['id']): return
raise


--
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 bug with patch

2000-08-28 Thread Steve Alexander

 "Phillip J. Eby" wrote:
  
  try:
  dm = self.__dict__[_v_dm_]
  except KeyError:
  if name=='id' and val==self.__dict__['id']: return
  raise
  
  Hopefully this should only perform the extra computations when the first
  part fails...

 Are Python classes derived from DataSkin supposed to call
 DataSkin.__init__ ?

 Anyway, perhaps this would be a small improvement:

 try:
 dm = self.__dict__[_v_dm_]
 except KeyError:
 if (name=='id' and self.__dict__.has_key('id') 
 and val==self.__dict__['id']): return
 raise

What rubbish! I didn't mean that at all!

I think what I meant was this:

try:
dm = self.__dict__[_v_dm_]
except KeyError:
if name=='id':
if self.__dict__.has_key('id') and val==self.__dict__.['id']:
return
else:
self.__dict__['id']=val
return
raise  


--
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 bug with patch

2000-08-28 Thread Steve Alexander

Steve Alexander wrote:
  
 What rubbish! I didn't mean that at all!
 
 I think what I meant was this:
 
 try:
 dm = self.__dict__[_v_dm_]
 except KeyError:
 if name=='id':
 if self.__dict__.has_key('id') and val==self.__dict__.['id']:
 return
 else:
 self.__dict__['id']=val
 return
 raise

I think what I *really* meant was this:

try:
dm = self.__dict__[_v_dm_]
except KeyError:
if name=='id':
if self.__dict__.has_key('id') and val==self.__dict__['id']:
return
else:
self.__dict__['id']=val
self._p_changed = 1
return
raise

--
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 )




[Zope-dev] ZPatterns transaction bug

2000-08-27 Thread Steve Alexander

I have a trigger that is a datamanager-plugin for a Customizer folder.
The trigger listens to ADD events.

If the trigger rasies an exception as it is notified that a new DataSkin
object is being added beneath the customizer folder, I get a ZODB error:

2000-08-27T09:25:38 ERROR(200) ZODB Couldn't load state for
'\000\000\000\000\000\000*\336'
Traceback (innermost last):
  File /usr/local/zope/SiteBox/lib/python/ZODB/Connection.py, line 442,
in setstate
  File /usr/local/zope/SiteBox/lib/python/ZODB/FileStorage.py, line 587,
in load
(Object: /usr/local/zope/SiteBox/var/Data.fs)
  File /usr/local/zope/SiteBox/lib/python/ZODB/FileStorage.py, line 563,
in _load
(Object: /usr/local/zope/SiteBox/var/Data.fs)
KeyError: *Þ

Sometimes I get slightly different errors, where Zope refuses to commit
any more transactions.

Zope 2.2.1, ZPatterns 0-4-1snap1 with the DataSkins patch I posted a few
minutes ago.

--
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 )




[Zope-dev] Bug in error logging in Catalog

2000-08-27 Thread Steve Alexander

Zope 2.2.1, lib/python/Products/ZCatalog/Catalog.py

When there is an error uncataloging an object, uncatalogObject()
attempts to log the fact with this line:

LOG('Catalog', ERROR, ('uncatalogObject unsuccessfully '
   'attempted to uncatalog an object '
   'with a uid of %s. ' % uid))

However, if uncatalogObject has been passed a tuple, the error logging
will fail with "TypeError Error Value: not all arguments converted".

The fix is to change the line to:

LOG('Catalog', ERROR, ('uncatalogObject unsuccessfully '
   'attempted to uncatalog an object '
   'with a uid of %s. ' % `uid`))

or, to fit with the rest of the calls to LOG in Catalog.py:

LOG('Catalog', ERROR, ('uncatalogObject unsuccessfully '
   'attempted to uncatalog an object '
   'with a uid of %s. ' % str(uid)))


--
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] bug in CatalogAwareness?

2000-08-27 Thread Steve Alexander

Shane Hathaway wrote:

 
 I was suspicious of the entire method so I wrote a replacement which is
 based on a new interface available in Zope.  I *think* it's correct,
 but it's a drastic change so it's only in the new PTK and nowhere
 else.  (This is slightly modified from PTK CVS.)
 
 def __url(self):
 return string.join(self.getPhysicalPath(), '/')

The implementation of url() in CatalogAwareness.py in Zope 2.2.1 seems 
to ensure that there is a '/' at the start of the url that is given to 
the ZCatalog. I don't know how important that really is, though.

Perhaps your method should be changed to this:

def __url(self):
return '/'+string.join(self.getPhysicalPath(), '/')

--
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 )




[Zope-dev] New method for ZCatalog: recatalog_object

2000-08-27 Thread Steve Alexander

ZCatalog would be easier to use if it had a recatalog_object method:

def recatalog_object(self, obj, uid):
"""Adds object to the catalog if not already present.
Removes old entry first, if already in present."""
self.uncatalog_object(uid)
self.catalog_object(obj, uid)

This, and a new method in Traverable.py would make cataloging in
ZPatterns SkinScript very easy indeed.

Add to Traversable.py:

getPathAsString__roles__=None # Public
def getPathAsString(self):
   '''Returns the physical path as a string.
   The returned string will always start with a slash.'''
   return join(self.getPhysicalPath(), '/')


Otherwise, ZCatalog could be altered to accept lists of strings as uid
method attributes, and automatically convert them into slash-separated
strings.

Example SkinScript:

WHEN OBJECT ADDED, CHANGED CALL Catalog.recatalog_object(self,
self.getPathAsString())
WHEN OBJECT DELETED CALL
Catalog.uncatalog_object(self.getPathAsString())

Any comments?

--
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 )




<    1   2   3   4   >