Re: [Zope-dev] problem to rename folder

2001-10-24 Thread Steve Alexander

Johan Beauce wrote:

> Hello,
> 
> I have a little problem. I use this function to rename an object in my site
> (file or folder).
> It work perfectly with file but I have an error when I try to rename a
> folder 
> I think the error is from "PARENT[0]", so do you have a solution ???
> 
> 
> "objRename.manage_renameObjects([idName],[newId],getWay(REQUEST.PATH_INFO))"
> 
> 
> 
> Thanks a lot, 
> Johan.


Johan,

You sent this message to the [EMAIL PROTECTED] list and also to the 
[EMAIL PROTECTED] list. Do not do that. Send your message to one mailing 
list only.

Because your message is about using Zope and DTML rather than developing 
the internals of Zope, your should have sent your message to only the 
[EMAIL PROTECTED] list.

 
>>>This email and any files transmitted with it are CONFIDENTIAL and
> intended solely for the use of the individual or entity to whom they are
> addressed. 
> 
>>>Any unauthorised copying, disclosure, or distribution of the material
> within this email is strictly forbidden. 


Do you realize that you just sent this email to a public mailing list, 
with archives available on the world wide web?

--
Steve Alexander
Software Engineer
Cat-Box limited




___
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] standard_error_message and displaying non-html content.

2001-10-17 Thread Steve Alexander

seb bacon wrote:

> I don't believe there is a clean way.  I've changed the source not to
> display its own html at all.  It's not nice, but I suppose that's the
> benefit of OSS. 


Is there a FishBowl proposal on remedying this? If not, there should be one.

Perhaps someone who has this itch to scratch can get the ball rolling?


--
Steve Alexander
Software Engineer
Cat-Box limited






___
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] PageTemplateFile + Metal not working

2001-10-10 Thread Steve Alexander

I'm using ZPT in a Python Product. PageTemplateFile works fine, using it 
more-or-less as a drop-in replacement for DTMLFile.

However, I want to use METAL with this. Simple macros that work on page 
templates created in the ZODB fail to work from filesystem python products.

The error I'm getting is this:

   Error Type: Undefined
   Error Value: "macros" not found in
 "here/standard/macros/header_and_footer"

If I call _cook() on the PageTemplateFile objects in my module, I get a 
slightly different error:

  Error Type: Undefined
  Error Value: "header_and_footer" not found in
"here/standard/macros/header_and_footer"


This is the latest version of PageTemplates, TAL, and ZTUtils from CVS, 
with the latest Zope trunk from CVS.

Any ideas?

--
Steve Alexander
Software Engineer
Cat-Box limited




___
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 searching for missing values

2001-10-08 Thread Steve Alexander

Stephan Richter wrote:

> 
> I actually need to look at Casey's code and see what I can reuse. 


I posted a patch to CatalogQuery to allow an extended uniqueValues query.

http://lists.zope.org/pipermail/zope-dev/2001-September/013054.html

Use it if you'l find it useful.

--
Steve Alexander
Software Engineer
Cat-Box limited


___
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 API

2001-10-05 Thread Steve Alexander

E. Seifert wrote:

> Hi list,
> 
> as I'm not very familiar with the internals of ZCatalog I have a question to
> all you API experts:
> 
> Why does ZCatalog.py (under Zope 2.4.1) specify a 'addIndex' permission for
> a method called 'manage_delIndexes' although there is no such method? The
> only method I could find to delete Indexes is 'manage_deleteIndex'.
> 
> Can anyone comment on this?


Thanks for pointing this out. There was some cruft in ZCatalog.py, which 
has now has been cleaned up. The changes are in CVS, and will be in the 
next release of Zope.


The method manage_deleteIndex is still there, but is deprecated, and 
will issue a warning the first time it is called.

You can use manage_delIndex instead.

Both are protected by the addIndex permission.


--

Steve Alexander
Software Engineer
Cat-Box limited




___
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] Curious problem with comprehensions and PythonScripts

2001-10-05 Thread Steve Alexander

Steve Alexander wrote:

>
> Any ideas what might be happening?
> 
> I think the compiled code of the python script might be incorrect when 
> directly returning the results a comprehension. 


Hmmm... it happened again. I think it might have something to do with 
the PythonScript falling out of the ZODB cache.

I've changed the code to a filter(lambda ...) to see if it still happens 
with that.


-- 
Steve Alexander
Software Engineer
Cat-Box limited



___
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] Random.shuffle

2001-10-05 Thread Steve Alexander

Steve Alexander wrote:

> Any particular reason why you can't use Random.shuffle from a 
> PythonScript? Or any other methods of a Random object.
> 
> 
> I'd like to propose that restricted python be allowed access to methods 
> of random.Random.
> 
> I know that I can write a product to add a security declaration to 
> random.Random, but I'd like this to be enabled by default in Zope.


Surprisingly enough, you can set the global random seed from restricted 
python. That doesn't sound right to me.




-- 
Steve Alexander
Software Engineer
Cat-Box limited




___
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] Random.shuffle

2001-10-05 Thread Steve Alexander

Any particular reason why you can't use Random.shuffle from a 
PythonScript? Or any other methods of a Random object.


I'd like to propose that restricted python be allowed access to methods 
of random.Random.

I know that I can write a product to add a security declaration to 
random.Random, but I'd like this to be enabled by default in Zope.

--
Steve Alexander
Software Engineer
Cat-Box limited


___
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] Curious problem with comprehensions and PythonScripts

2001-10-05 Thread Steve Alexander

Here's the situation:

I have a dtml document with a list of questions under various headings, 
formatted like this:

HEADING 1
   question1
   question2
   question3

HEADING 2
   question 4
   question 5


I have a PythonScript that gives a list of only the questions to a Page 
Template:

PythonScript called get_questions:

data=container.data_document(None, None)

# ignore blank lines
# lines with no leading space are headings
# lines with leading space are questions

return [l for l in comps.splitlines()
   if l
   if l[0] is ' ']

I'm rendering this using a page template:




The problem is, I'm often (always?) getting no questions rendered.

However, if I change the python script to this, it works every time.

PythonScript called get_questions:

data=container.data_document(None, None)

# ignore blank lines
# lines with no leading space are headings
# lines with leading space are questions

questions = [l for l in comps.splitlines()
if l
if l[0] is ' ']

return questions



Any ideas what might be happening?

I think the compiled code of the python script might be incorrect when 
directly returning the results a comprehension.

--
Steve Alexander
Software Engineer
Cat-Box limited


___
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] ZTables and/or Catalog plugable brains?

2001-10-05 Thread Steve Alexander

Jay, Dylan wrote:

> (resent to here from [EMAIL PROTECTED] due to complete lack of resoonse. Perhaps
> there should be three levels of mailing list. zope-use, zope-app-dev,
> zope-dev or something)
> 
> I'm in the process of of write a zope product that will deal with a lot
> numerical data (records with a few ids and a few float values). Rightly or
> wrongly (comments welcome) I've decided to do this inside the ZODB rather
> than rely on a relation database. This is largely because this data will 
> 
> - not be high-write
> - I want to do processing on all this of this data on multiple servers
> - and I am presuming that at some point in the not too distant future zope
> will let me replicate this data very easily to make it even more highly
> available.


Write a Python Product. See the Zope Developers Guide for details.

  http://www.zope.org/Documentation/ZDG/Products.dtml



> Anyone with comments about how ZPatterns fits into all of this would also be
> welcome.


I can't see that it would particularly help you.

--
Steve Alexander
Software Engineer
Cat-Box limited





___
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] DateTime(string) uses GMT as timezone

2001-09-30 Thread Steve Alexander

Dieter Maurer wrote:

> Unfortunately
> 
>   DateTime(year,month,day) != DateTime("%d-%d-%d" % (year,month,day))
> 
> The former uses the local timezone (which I think is right)
> while the latter uses GMT+0 (which seems not right).
> 
> Thinks are quite bad, as the latter is used to convert
> ":date" form values into DateTime objects.


See also here:

http://lists.zope.org/pipermail/zope-dev/2001-August/012974.html



I get different times from a string, depending whether I use '-' or '/'
as a date delimiter.

  >>> from DateTime.DateTime import DateTime
  >>> DateTime('2001-08-20').pCommonZ()
'Aug. 20, 2001 12:00 am GMT+0'
  >>> DateTime('2001/08/20').pCommonZ()
'Aug. 20, 2001 12:00 am GMT+1'
  >>>

I find the difference a tad surprising.

Is this a bug or a feature?

If it's a bug, I'll work on a fix.

I'm guessing this is a feature; perhaps using the '-' delimiter suggests
I'm trying to use ISO formatting.

I'm running this in a GMT+1 timezone btw.

Zope latest from CVS, Python 2.1.


I never got a reply as to whether it was a bug or a feature, so I didn't 
work on a fix.

--
Steve Alexander
Software Engineer
Cat-Box limited



___
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 API

2001-09-30 Thread Steve Alexander

E. Seifert wrote:

> Hi list,
> 
> as I'm not very familiar with the internals of ZCatalog I have a question to
> all you API experts:
> 
> Why does ZCatalog.py (under Zope 2.4.1) specify a 'addIndex' permission for
> a method called 'manage_delIndexes' although there is no such method? The
> only method I could find to delete Indexes is 'manage_deleteIndex'.
> 
> Can anyone comment on this?


Well, considering that there's these methods in ZCatalog:

   manage_addColumn
   manage_delColumns
   manage_addIndex
   manage_deleteIndex

... manage_deleteIndex is obviously the odd one out.

Especially as it allows you to delete several indexes in one go.

I suggest it be renamed manage_delIndices or manage del_Indexes.


manage_clearIndex also operates on multiple indexes, so that should 
become manage_clearIndexes.

Funnily enough, the ZCatalog regression test at
./regressiontests/regressionCatalogTiming.py uses this call:

   manage_delIndexes([x])

which supports renaming manage_deleteIndex to manage_delIndexes.

However,  while dtml/catalogIndexes.dtml uses manage_delIndexes,
./dtml/manageIndex.dtml uses manage_deleteIndex.

manage_reindexIndex should also become manage_reindexIndexes, as it 
requires a sequence of ids. Also, manage_reindexIndex doesn't have an 
associated permission.

There's a few more place this touches, although all the changes are in 
ZCatalog.py and manageIndex.dtml.


Congratulations, you've found a bug!

This would have been more obvious if ZCatalog were using the new 
declarative security assertions, as the declaration would be right next 
to the method definition.


Here's a first-draft patch, for comments etc.
I haven't looked at the documentation of the API, so that might need 
changing too.


--
Steve Alexander
Software Engineer
Cat-Box limited


*** ZCatalog.py.orig
--- ZCatalog.py
***
*** 196,202 
'manage_catalogView', 'manage_catalogFind',
'manage_catalogSchema', 'manage_catalogIndexes',
'manage_catalogAdvanced', 'manage_objectInformation',
!   
'manage_catalogReindex', 'manage_catalogFoundItems',
'manage_catalogClear', 'manage_addColumn', 'manage_delColumns',
'manage_addIndex', 'manage_delIndexes', 'manage_main',
--- 196,202 
'manage_catalogView', 'manage_catalogFind',
'manage_catalogSchema', 'manage_catalogIndexes',
'manage_catalogAdvanced', 'manage_objectInformation',
!   'manage_reindexIndexes', 'manage_clearIndexes',
'manage_catalogReindex', 'manage_catalogFoundItems',
'manage_catalogClear', 'manage_addColumn', 'manage_delColumns',
'manage_addIndex', 'manage_delIndexes', 'manage_main',
***
*** 422,430 
  RESPONSE.redirect(URL1 + 
'/manage_main?manage_tabs_message=Index%20Added')
  
  
! def manage_deleteIndex(self, ids=None, REQUEST=None, RESPONSE=None,
  URL1=None):
! """ del an index """
  if not ids:
  return MessageDialog(title='No items specified',
  message='No items were specified!',
--- 422,430 
  RESPONSE.redirect(URL1 + 
'/manage_main?manage_tabs_message=Index%20Added')
  
  
! def manage_delIndexes(self, ids=None, REQUEST=None, RESPONSE=None,
  URL1=None):
! """ del indexes """
  if not ids:
  return MessageDialog(title='No items specified',
  message='No items were specified!',
***
*** 436,444 
  if REQUEST and RESPONSE:
  RESPONSE.redirect(URL1 + 
'/manage_main?manage_tabs_message=Index%20Deleted')
  
! def manage_clearIndex(self, ids=None, REQUEST=None, RESPONSE=None,
  URL1=None):
! """ del an index """
  if not ids:
  return MessageDialog(title='No items specified',
  message='No items were specified!',
--- 436,444 
  if REQUEST and RESPONSE:
  RESPONSE.redirect(URL1 + 
'/manage_main?manage_tabs_message=Index%20Deleted')
  
! def manage_clearIndexes(self, ids=None, REQUEST=None, RESPONSE=None,
  URL1=None):
! """ clear indexes """
  if not ids:
  return MessageDialog(title='No items specified',
  message='No items wer

[Zope-dev] testing types in PythonScripts

2001-09-28 Thread Steve Alexander

I have a variable, f.

The value of f might be a list, or it might be a string.

I want to do different things to f depending what type it is.

How do I check its type from a PythonScript?


I can't use type(), as this opens up a security hole with Extension 
Classes, where the type is the class.

I can't import types, as that seems to be restricted.


I suggest that either one or both of the following be altered:

  * The types module is allowed to be imported into restricted stuff.

  * A safe version of type() is put into the restricted global namespace.


I seem to recall a discussion of this a few months ago, where someone 
(Evan?) proposed a safe version of type(). I guess this got lost in the 
conversion to RestrictedPython with Zope 2.4.


Oh yeah... an ugly workaround is to try to append to f and see if you 
get and AttributeError.

--
Steve Alexander
Software Engineer
Cat-Box limited


___
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] zLog and stderr

2001-09-26 Thread Steve Alexander

Toby Dickenson wrote:

> I have some old python modules which are generating messages from the
> new python 2.1 warning framework. I can easily fix these modules,
> however it has exposed a problem in Zope..

 >
 > The warning framework tries to write to sys.stderr, and my Zope is
 > dying from an exception because stderr has been closed.

I bumped into this with Python 1.5.2, and a print statement in the 
Threading module. This was causing me problems using Xron.

The solution was to use this at the end of the start script:

   >> /some/path/logs/zope_stdout.log 2>&1

I keep a separate script called start_debug that doesn't do this, and 
adds -D to the z2.py switches.


> I think it makes sense that Zope should replace sys.stderr with an
> object that sends messages to zLog, however zLog itself sometimes
> wites to sys.stderr.


I guess it would be nice to specify switches to z2.py to say that stderr 
should go to ZLog, and ZLog's stderr messages should get appended to a 
specified file.

--
Steve Alexander
Software Engineer
Cat-Box limited




___
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] Acquisition, __getattr__ and making a Proxy/Symlink class

2001-09-26 Thread Steve Alexander

Lupus Yonderboy wrote:

> 
> Can anyone shed some light on how i might do this? All
> objects under the DocumentRoot will be derived from
> one of our base classes, so if we need to override
> __getattr__ as per TransparentFolders it can be done
> easily.


Have you looked at the __bobo_traverse__ traversal hook?

   http://www.zope.org/Documentation/ZDG/ObjectPublishing.dtml

--
Steve Alexander
Software Engineer
Cat-Box limited



___
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 problem: PATCH

2001-09-24 Thread Steve Alexander

Steve Alexander wrote:

  >
  >
  > Patch coming up soon...


Patch against Catalog.py, from CVS:

*** lib/python/Products/ZCatalog/Catalog.py.original
--- lib/python/Products/ZCatalog/Catalog.py.patched
***
*** 673,679 
if (type(so) is type('') and
lower(so) in ('reverse', 'descending')):
r.reverse()
! r=LazyCat(map(lambda i: i[1], r), len(r))

return r

--- 673,681 
if (type(so) is type('') and
lower(so) in ('reverse', 'descending')):
r.reverse()
! r=map(lambda i: i[1], r)
! r=LazyCat(r, reduce(lambda x,y: x+len(y), r, 0))
!

return r


I'd use a list comprehension instead of a map(lambda...) if I thought it
would get past Jim ;-)

--
Steve Alexander
Software Engineer
Cat-Box limited



___
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 problem: sort_on bug

2001-09-24 Thread Steve Alexander

Steve Alexander wrote:

> 
> This gives partial results:
> 
>  sort_on='subject_name')">


...because this returns a LazyCat instance, for which len() is broken.


> This gives full results:
> 
>  sort_on='subject_name')[:]">


...because this is a list.


> This gives full results:
> 
>  sort_on='subject_name')" sort="subject_name">


...because this is a LazyMap instance, for which len() works.


Patch coming up soon...



-- 
Steve Alexander
Software Engineer
Cat-Box limited




___
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 problem: sort_on bug

2001-09-24 Thread Steve Alexander

Steve Alexander wrote:

> I'm getting a strange problem with ZCatalog, using python 2.1, Zope from 
> CVS.
> 
> I get all the results I expect with this:
> 
> 
> 
> 
>  &dtml-subject_name; -- &dtml-relationship_name; -> &dtml-rater_name;
> 
> 
> 
> 
> But, I only get one subject_name's worth of results with this:
> 
> 
>  sort_on='subject_name')">
> 
>  &dtml-subject_name; -- &dtml-relationship_name; -> &dtml-rater_name;
> 
> 
> 
> 
> 
> This smells like a BTrees bug to me, but I'm not sure. I'm looking into 
> this closely now, but if anyone's seen this before, please speak up!



More data:


This gives partial results:



This gives full results:



This gives full results:





--
Steve Alexander
Software Engineer
Cat-Box limited


___
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 problem: sort_on bug

2001-09-24 Thread Steve Alexander

I'm getting a strange problem with ZCatalog, using python 2.1, Zope from 
CVS.

I get all the results I expect with this:




 &dtml-subject_name; -- &dtml-relationship_name; -> &dtml-rater_name;




But, I only get one subject_name's worth of results with this:




 &dtml-subject_name; -- &dtml-relationship_name; -> &dtml-rater_name;





This smells like a BTrees bug to me, but I'm not sure. I'm looking into 
this closely now, but if anyone's seen this before, please speak up!

--
Steve Alexander
Software Engineer
Cat-Box limited


___
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 bug

2001-09-18 Thread Steve Alexander

I'm updating a site that is currently using Python 1.5.2 and Zope 
2.3.something to use Python 2.1 and Zope 2.4.from_cvs.

I've had a problem: most products won't initialize. They fail on an 
AttributeError in SearchIndex/UnTextIndex.py related to setting up the 
help system.

This ugly patch fixes it. There must be a better way!



*** /lib/python/SearchIndex/UnTextIndex.py.original
--- /lib/python/SearchIndex/UnTextIndex.py.new
***
*** 327,333 
   return 0

   lexicon = self.getLexicon(self._lexicon)
! splitter=lexicon.Splitter

   wordScores = OIBTree()
   last = None
--- 327,337 
   return 0

   lexicon = self.getLexicon(self._lexicon)
!
! try:
! splitter=lexicon.Splitter
! except AttributeError:
! splitter=lexicon.lexicon.Splitter

   wordScores = OIBTree()
   last = None
***
*** 343,349 

   # Convert scores to use wids:
   widScores=IIBucket()
! getWid=lexicon.getWordId
   for word, score in wordScores.items():
   widScores[getWid(word)]=score

--- 347,356 

   # Convert scores to use wids:
   widScores=IIBucket()
! try:
! getWid=lexicon.getWordId
! except AttributeError:
! getWid=lexicon.lexicon.getWordId
   for word, score in wordScores.items():
   widScores[getWid(word)]=score

--
Steve Alexander
Software Engineer
Cat-Box limited


___
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] Unauthorized error with this code

2001-09-17 Thread Steve Alexander

Servizio tecnico NOMOS wrote:


> 
> *This work and diplay correctly: test test.*
> 
> ** 
> 
> *This problem there is only ZOPE 2.4.0, the precedent version is run OK.*
> 
> ** 
> 
> *Can you help ME ?*


You should read up on the Zope security model. You'll need to make 
security declarations in that class, or define the class attribute

   __allow_access_to_unprotected_subobjects__=1


You can read about the Zope security model in the Zope Developers' Guide:

   http://www.zope.org/Documentation/ZDG


Please do not post HTML mail to this mailing list. Your emails will most 
likely be ignored if you do so.

--
Steve Alexander
Software Engineer
Cat-Box limited


___
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 Unauthorized from __bobo_traverse__.

2001-09-12 Thread Steve Alexander

James Johnson wrote:

> Don't know if this helps,
> 
> http://lists.zope.org/pipermail/zope-dev/2000-December/008524.html


Gosh, I wrote that one :-)

I recall that ZCatalog was changed to use unrestrictedTraverse instead 
of restrictedTraverse for Zope 2.3...

> x.unrestrictedTraverse(('','y','z'))


... which you can't use from restricted things like (Script) Pythons and 
  DTML Methods. So, the answer lies in External Methods and Python 
Products. If only I could remember what the question was...

--
Steve Alexander
Software Engineer
Cat-Box limited




___
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: Collector down - status and potential help request

2001-09-11 Thread Steve Alexander

Ken Manheimer wrote:

> I was wrong - the collector csv dumps apparently did not include the
> *body* of the items, which is, um, important.  We're nearly back to square
> one on recovering the old issues.  Aargh.


I've got the following Collector items from the google cache:

374
375
386
476
645
718
736
796
842
860
871
892
894
916
919
939
945
954
995
1002
1005
1014
1028
1049
1056
1059
1066
1102
1103
1112
1134
1156
1158
1159
1179
1183
1194
1195
1204
1219
1220
1228
1257
1260
1270
1279
1298
1328
1360
1364
1371
1388
1409
1413
1441
1442
1445
1457
1480
1540
1541
1542
1551
1566
1570
1586
1606
1629
1687
1737
1768
1772
1797
1848
1884
1892
1928
2022
2120
2183
2200
2205
2254
2410
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2468

I'll throw something together to get the important data out.

Ken, perhaps you can list the important fields that are going to be put 
into a new Collector, so that anyone helping out uses the same ordering 
/ field-names.

--
Steve Alexander
Software Engineer
Cat-Box limited


___
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] HowTo: Make an Image/File a DataSkin ???

2001-07-10 Thread Steve Alexander

Steve Spicklemire wrote:

> 
> Hi Ulrich,
> 
>   Hmm.. can you just call DataSkin.__init__(self, id) in the File's constructor?


You might need to do it like this:

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

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



Re: [Zope-dev] Traversal Barf

2001-07-10 Thread Steve Alexander

Casey Duncan wrote:

> seb bacon wrote:
> 
>>I've been getting a puzzling error.  It's not reliably reproduceable.
>>It occurs perhaps one time in four when I'm using Opera.  At first, it
>>appeared only to be related to Opera, but now I'm getting the same
>>error in netscape.  I can just hit refresh and it works again.
>>There's no sign of anything like ConflictErrors or the like on the
>>console.
>>
>>Has anyone seen this before?  What could it be?
>>
>>< snip >
>>
>> File /usr/local/Zope/lib/python/DocumentTemplate/DT_Let.py, line 146, in render
>>(Object: rootpath="absolute_url()")
>>  File /usr/local/Zope/lib/python/DocumentTemplate/DT_Util.py, line 334, in eval
>>(Object: absolute_url())
>>(Info: absolute_url)
>>  File , line 0, in ?
>>  File /usr/local/Zope/lib/python/OFS/Traversable.py, line 119, in absolute_url
>>(Object: Traversable)
>>KeyError: SERVER_URL
>>
>>Cheers,
>>
>>seb
>>
>>
> 
> I have seen a similar traceback which was due to a bug in CopyPaste.py,
> to which I have submitted a patch. It had to do with a lack of an
> acquisition wrapper at an inopportune time. It looks as though
> absolute_url() is being called without a proper wrapper around the
> object it is begin called for.


Looks to me like absolute_url() is being called when absolute_url(1) 
should be used.

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



Re: [Zope-dev] Cookie with dictionary as content

2001-06-09 Thread Steve Alexander

[EMAIL PROTECTED] wrote:

> Hi guys,
> 
> I'm developing the ZPivotTable product. For implementing the drilldown
> mechanism, I need to store the information about which columns and rows
> are open in a cookie. I thougt of storing this information in form of
> a dictionary, which would be stored in a cookie.
> 
> The dictionary consists of several lists, containing the open columns
> or rows.
> 
> Could you give me a tip how i can store the dictionary in the cookie.
> I've already tried to converting it to a string and converting the string
> back, when needed.


You could consider using a session manager, and only store an id in the 
cookie.

Otherwise, look at how the dtml tree tag achieves what you describe. You 
have to be a bit careful that you only serialize pure data and not 
pickled objects into your cookie, otherwise you're opening up a huge 
security hole.

Look at the source in lib/python/TreeDisplay/TreeTag.py, around line 
578, in the methods encode_seq and decode_seq.

--
Steve Alexander
Software Engineer
Cat-Box limited


___
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 on linux: Dispatcher thread stops after a while

2001-05-28 Thread Steve Alexander

Homan Els wrote:

> ZOPE 2.2.2 , Xron -0-0-9, Python 1.5.2
> 
> Hi Steve,
> 
> I am running Zope  under linux (Suse 6.4).   And I would like to use
> Xron.  But, I can not get it running.
> I did read your email : Xron on linux. And therefore I would like to
> know, how you did manage to use Xron.
> I have the general Xron problem, that the zope-server is not responding
> anymore after the installation of Xron.



What user do you run Zope as?

There's a problem with Linux where if you start off a thread, then 
change uid in the main thread, the thread that you spawned before will 
remain in the old uid, or unexpected things will happen.

This is what Zope does when you run it as root. Zope initializes its 
products as root, and then changes to user "nobody".

You can find out more about this if you search for discussions about 
BIND and Linux.

The solution for Zope and Xron is to run Zope as user "nobody". You 
might need to chown the files in your zope directory.

Note that you will not be able to run Zope on a privileged port (below 
1024) if you do this.

The alternative is to hack Zope so that it calls Xron after it has 
changed use to "nobody", so Xron can safely spawn its thread as user 
"nobody". If you do this, you'll be able to run zope as the root user, 
and Zope + Xron will work running on port 80.

--
Steve Alexander
Software Engineer
Cat-Box limited





___
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] getPersistentItemIDs not cooperating?

2001-05-23 Thread Steve Alexander

Steve Spicklemire wrote:
> 
> Well.. it turned out to be more subtle.
> 
> It goes back to the old problem that getPersistentItemIDs doesn't return
> a real list, but rather a BTreeItems object. When you call manage_delete
> on *one* item, it affects the BTreesItems object you are iterating over!

Right... another one of those "it returns a mutable internal object"
problems.

In that case, is there a security problem with what getPersistentItemIDs
returns being accessible to TTW scripting?

I'm changing the OS on my development machine, so I can't easily check
this out right now.

--
Steve Alexander
Software Engineer
Cat-Box limited

___
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] getPersistentItemIDs not cooperating?

2001-05-23 Thread Steve Alexander

Steve Spicklemire wrote:

> 
> Has anyone seen anything like this?
> 
> It works.. partially. For some reason it looks like getPersistentItemIDs 
> does not always return a *complete* list. I need to run this method 
> several times to completely exhaust the Rack's storage.


Yes, I've seen this. It's on my list of things to look into when I've 
got a certain large project out of the way :-/

> Thoughts? 



Well, getPersistentItemIDs() just returns the result of calling keys() on the Rack's 
BTree.


I guess it is a problem with the BTree code.

I doubt it'll be fixed though. Instead, we should update Rack to use the 
new BTrees module.

--
Steve Alexander
Software Engineer
Cat-Box limited



___
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] Splitter.c hack by Spisak; anyone have a Splitter.so?

2001-04-25 Thread Steve Alexander

Erik Enge wrote:

> Hola,
> 
> please don't make me touch C or a ... erm... you know, one of those
> compiler-thingys.   I don't like them.
> 
> Does anyone have a nicely baked Splitter.c for Linux?  The one that Spisak
> hacked to make it chew and swallow anything?


If you have the Splitter.c file, you ought to be able to get a source 
distribution of Zope, delete the original Splitter.c, replace it with 
the new one, then run python wo_pcgi.py or python w_pcgi.py to set 
everything up.

If you're running from the source distribution already, just replace 
Splitter.c, and run the appropriate wo?_pcgi.py to compile.

--

Steve Alexander
Software Engineer
Cat-Box limited





___
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 AttributeProvider question

2001-04-22 Thread Steve Alexander

Phillip J. Eby wrote:

> Steve Alexander wrote:
> 
>>  As a simpler workaround, you can use 
>>your_object.commitSubtransaction() instead of redirecting to a new page. 
>>
> Um, this shouldn't be the issue here.  _SetAttributeFor() should be called
> when the attribute is set; it's not transaction-driven.  Something weird is
> happening with Christian's situation that I haven't investigated yet.


I agree. However, if Christian's problem can be worked-around by 
redirecting before setting attributes, then it should also be 
workaroundable by calling commitSubtransaction.


> Actually, the status should be AddedStatus, and it should stay that way
> throughout the transaction, unless the object gets deleted in the same
> transaction.


That's what I'd originally thought. Then I (mis-?)read the code again...

The __set_attr__ method of DataSkins.py says:

self._objectChanging(name)

The _objectChanging method says:

 if self._v_status_ is not ChangedStatus:
 d[_v_dm_]._objectChanging(self)
 d[_v_status_] = ChangedStatus

I don't see an exception for if _v_status is already AddedStatus.

--
Steve Alexander
Software Engineer
Cat-Box limited



___
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 AttributeProvider question

2001-04-22 Thread Steve Alexander

Christian Scholz wrote:

>
> So what I do now as workaround is 
> 
> dtml method 1:
> 
> - creates new object via newItem()
> - redirects to dtml method 2
> 
> dtml method 2:
> - retrieves the newly created object with getItem()
> - calls manage_changeProperties on that object
> 
> This is working. Putting the manage_changeProperties directly after the
> newItem() is not working. I've also tried retrieving the new object
> directly after newItem() and calling manage_changeProperties on that
> but this also did not work.
> (so it is named correctly as otherwise it wouldn't be called either in dtml method 
>2).
> 
> So the main problem is: SetAttributeFor() is not called (and also _objectChanging()
> is not called) in the same request cycle after creating a new object.
> They're called however in the "next" request after retrieving it with getItem().


   As a simpler workaround, you can use 
your_object.commitSubtransaction() instead of redirecting to a new page. 
A few Zope versions ago, that could conceivably cause problems with 
certain database adapters. With some of the recent fixes to Zope, you 
should be ok using subtransactions even with DAs that don't support 
them. Check this out before you use it for important stuff though :-)

   You really should be able to create a new object and set its 
attributes in the same transaction. The status of the object (_v_status 
in DataSkin.py) will be ChangedStatus, if you're adding and changing in 
the same transaction. That's a good place to look for where the problem is.

--
Steve Alexander
Software Engineer
Cat-Box limited


___
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] [] vs () in dtml-in: is this a bug ?

2001-04-22 Thread Steve Alexander

Stefane Fermigier wrote:

> Hi,
> 
> please try this as a DTML Method:
> 
> 
> 
>   
> 
> 
>
> 
> 
>   
> 
> 
> 
> Why should the two results differ ?


This is a designed-in feature of dtml-in.

When you call an items() method on a dictionary-like object, you get 
back a list of two-tuples: [(key1,value1), (key2,value2, ...]

It is often nice to iterate through such a list in dtml, so, dtml-in 
detects that the next item in the iteration is a two-tuple, and puts the 
elements of the tuple in sequence-key and sequence-item.

  If you look throughthe zope-dev list archives, you'll find a number of 
arguments on each side as to whether this is a bug or a feature.

--
Steve Alexander
Software Engineer
Cat-Box limited



___
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 AttributeProvider question

2001-04-21 Thread Steve Alexander

Christian Scholz wrote:

> Good evening everybody!
> 
> I have some question regarding attribute and agent programming for ZPatterns.
> 
> I have some provider which is registered for the "handlers" and "attributes"
> methods and some attributes.
> 
> My problem is when trying to create a new object and directly editing it, e.g.
> 
> obj=newItem()
> obj.propertysheets.data.manage_changeProperties(foobar=13)
> 
> the propertysheet is defined and my provider is also registered for
> handling the property "foobar". Unfortunately my SetAttributeFor() method
> is never called.


Have you defined a namesForRegistration method in your provider?

See Components.py for an example:


   lib/python/Products/ZPatterns/SkinScript/Components.py

--
Steve Alexander
Software Engineer
Cat-Box limited


___
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] Virtual dataskinned ZClass instance

2001-04-18 Thread Steve Alexander

Godefroid Chapelle wrote:

> 
> 
> When using context.getId(), I get the id of the specialist, not of the
> HumanClass instance...


use container.getId()

Also, try setting a proxy role on the SkinScript.

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



Re: [Zope-dev] Dataskin with no persistence.

2001-04-12 Thread Steve Alexander

Godefroid Chapelle wrote:

>
> data plug-in : a skinscript computing attributes based on an id and the
> xml.
> 
> storage :
>Class to use for stored items: HumanClass
>Objects are: loaded by accessing attribute nom  (which is defined in
> the skinscript)
> 
> Store 'persistent' data: Directly in this object
> 
> 
> I store no HumanClass instance and try to get an instance :
> 
> specialist.getItem(anId)
> 
> I always get None.
> 
> 
> Am I trying to do something impossible because of lack of understanding
> or am I just wrong in one property of ZClass, Specialist, Rack ?


What you're doing sounds about right.

What does your SkinScript look like?

In the ScinScript, you need to determine what data to use based on 
self.id. Here's the SkinScript I use for a similar function; I'm 
creating "virtual" instances of one ZClass, based on instances of a 
different ZClass from another Specialist. In this case, the other 
specialist is "Responses".

WITH Responses.get_data_for_code(code=self.id) COMPUTE
   subject_name,
   rater_name,
   relationship_name,
   response_code,
   process_step


--
Steve Alexander
Software Engineer
Cat-Box limited


___
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 Questions

2001-04-02 Thread Steve Alexander

Michael R. Bernstein wrote:

> Hi all,
> 
> I had some questions about SkinScripts:
> 
> 1) Are there any naming conventions for SkinScripts?

I have used the names "attributes" "domain_catalog" and "site_index" 
quite often.

I use "attributes" for computed attrubutes, "domain_catalog" to trigger 
cataloging in a ZCatalog within the Specialist, and "site_index" for 
cataloging in an acquired ZCatalog common to the entire application.

I typically use the SiteIndex for text searches across many types of 
content.

I also often call a Class Extender "instance_methods".

On other applications, I've split the SkinScript according to whether it 
provides attributes for the object computed from its own real 
attributes, or whether it provides attributes and triggers that link the 
object to other objects and take care of referential integrity.



> 2) Is there any reason (other than factoring) to split
> SkinScripts up, or is putting all your declarations in one
> SkinScript ok?

Each SkinScript statement gets compiled into a separate 
provider/trigger/agent/whatever, so it doesn't make any difference to 
how fast the SkinScript executes.

You do need to split your SkinScript up according to what proxy roles 
they need.

There's another related issue of what attributes to compute in a single 
SkinScript statement, but that's pretty much covered in the 
documentation. I looked into this quite deeply when I found I needed the 
"INVALIDATE FOR" syntax.

--
Steve Alexander
Software Engineer
Cat-Box limited


___
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] iso_week for Zope's DateTime

2001-03-18 Thread Steve Alexander

The Collector doesn't seem to be working at the moment, so I'm posting 
this here.

I've written a small test for my iso_week function.

You can download it, plus some test data, plus the script to create the 
test data here:

   http://www.cat-box.net/steve/zope_iso_week.tar
   (700k)

You'll need to install mxDateTime if you want to make your own test 
data. You'll need bzip2 if you want to use the supplied test data.

The function passes the test for all dates from 1600-01-01 to 2585-08-23.

I've submitted it (with the date argument renamed self) to the Collector 
as a feature patch to DateTime.py. if you want to keep the standard 
DateTime.py, you can use it as PythonScript in Zope easily enough.


def iso_week(date):
   doy=date.dayOfYear()
   dow=(date.dow()-1)%7
   y=date.year()
   thurs_this_week=doy+(3-dow)
   is_leap=y%4==0 and (y%100!=0 or y%400==0)

   if thurs_this_week>(is_leap and 366 or 365):
 week=1
 if dow<8:
   y=y+1
   else:
 mon_this_week=doy-dow
 day_year_begins=(dow-doy+1)%7
 day_of_4_jan=(day_year_begins+3)%7
 monday_of_first_week=4-day_of_4_jan
 week=(mon_this_week-monday_of_first_week)/7+1
 if week==0:
   y=y-1
   is_last_leap=y%4==0 and (y%100!=0 or y%400==0)
   if day_year_begins==4 or (day_year_begins==5 and is_last_leap):
 week=53
   else:
 week=52

   return y,week,dow+1


--
Steve Alexander
Software Engineer
Cat-Box limited


___
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] Designing ZPatterns/Python-product-based, reusable applications - take 2

2001-03-17 Thread Steve Alexander

Itai Tavor wrote:

>
> This brings up another thing that bothers me: When I started learning 
> object models and ZPatterns everyone advocated using Coad notation. Now 
> Peter Coad himself is using UML and you're building TransWarp around 
> UML. Is this a conspiracy to confuse me?

ZPatterns is very much about objects and collaborations between objects.

The Coad notation is very good for talking about objects like this.

TransWarp is more about classes, and generating customized classes from 
a mixture of existing classes and aspects. You can understand aspects as 
declarations about how to handle certain kinds of behaviour.

UML is very good for talking about classes and the relationships that 
can exist between objects of particular classes.



Often, I tend to think in Coad, but write in UML.

--
Steve Alexander
Software Engineer
Cat-Box limited


___
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_main don't work with Mozilla

2001-03-15 Thread Steve Alexander

Duncan Booth wrote:

> On 15 Mar 2001, you wrote in local.zope.dev:
>
>>   
>> Matt wrote:
>> 
>>>  should have a corresponding  right?  In which case
>>> >> it should not have a trailing slash.  They are only needed for single
>>> tags that have no corresponding close, eg   etc.
>> 
>>  I agree but in the management interface of Zope it's not the case.
>>  You 
>> have  Some stuff...  and you should have
>>  stuff . That's the reason why it doesn't work anymore
>> > Mozilla.
> 
> 
> It just seems to be one place in zope's code. OFS/dtml/main.dtml, line 43 
> needs the spurious slash removing.

It's always worth looking in the Collector for this sort of thing.

   http://classic.zope.org:8080/Collector/2020/view

   Submitted On: Mar 4, 2001 5:01 am

--
Steve Alexander
Software Engineer
Cat-Box limited



___
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] PythonScript for iso_week

2001-03-14 Thread Steve Alexander

Hi folks,

At various times in the past, people on this list have asked about 
getting week numbers from DateTime instances.

I recently had this requirement, so I wrote a PythonScript to produce an 
iso_week tuple (year, week_number, dow_monday_is_one__sunday_is_seven) 
from a DateTime instance.

I've submitted the same to the collector as a feature-enhancement patch 
to DateTime.py.

I've tested this by empirically comparing it with the output of 
mxDateTime's iso_week attribute for all days from 1920-01-01 to some 
date in the twenty-third century.

Note also that this iso_week method does not create additional DateTime 
instances.

See also http://www.cl.cam.ac.uk/~mgk25/iso-time.html


PythonScript iso_week

Parameters: date

doy=date.dayOfYear()
dow=(date.dow()-1)%7
y=date.year()
thurs_this_week=doy+(3-dow)
is_leap=y%4==0 and (y%100!=0 or y%400==0)

if thurs_this_week>(is_leap and 366 or 365):
   week=1
   if dow<8:
 y=y+1
else:
   mon_this_week=doy-dow
   day_year_begins=(dow-doy+1)%7
   day_of_4_jan=(day_year_begins+3)%7
   monday_of_first_week=4-day_of_4_jan
   week=(mon_this_week-monday_of_first_week)/7+1

   if week==0:
 y=y-1
 is_last_leap=y%4==0 and (y%100!=0 or y%400==0)
 if day_year_begins==4 or (day_year_begins==5 and is_last_leap):
   week=53
 else:
   week=52

return y,week,dow+1



--
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: External Attribute Provider question

2001-03-11 Thread Steve Alexander

Hi Phillip,

Is there a good reason that ExternalAttributeProvider sets up a 
dictionary to put its attributes into, rather than a PersistentMapping?

This is the way it seems to store things in the Rack:

Rack's BTree
   |
   + object_id
  : PersistentMapping
|
+ ('ZPatterns.Rack', 'Self')
: Persistent object, eg ZClass instance
+ ('ZPatterns.AttributeProviders','ExternalAttributes')
: {}  # dict filled with external attributes

The thing is that when the dict gets updated by the External Attribute 
Provider, the whole second-level-in PersistentMapping object gets updated.

If an External Attribute Provider instead set up a new PersistentMapping 
in its slot, only that PersistentMapping would change in the ZODB on 
updates.

Do you think this is a reasonable change for the External Attribute 
Provider class? Or, should I write my own provider, derived from 
External Attribute Provider, that uses a PersistentMapping instead of a 
dict?

Actually, I can see the use for a Persistent AttributeProvider where you 
have a configurable slot, so you can group attributes that change at 
different rates in groups of those that change together.

The second half of the slot-key's tuple would be configurable as a 
property on the attribute provider.

--
Steve Alexander
Software Engineer
Cat-Box limited


___
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] SAP DB <--> ZODB ?

2001-03-10 Thread Steve Alexander

ender wrote:

> On Friday 09 March 2001 07:20, Steve Alexander wrote:
> 
>>> I just heard that the SAP DB has gone Free and Open Source.
>> 
> 
> sapdb isn't open source yet. it will be in a few months. 

It is GPL-ed now, and you can download it now.


  http://freshmeat.net/projects/sapdb/

--
Steve Alexander
Software Engineer
Cat-Box limited


___
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] SAP DB <--> ZODB ?

2001-03-09 Thread Steve Alexander

I just heard that the SAP DB has gone Free and Open Source.



  SAP DB is an open, SQL-based, relational database management system that
   provides high availability and performance scaling from small to very 
large
   implementations.

  In addition, SAP DB goes beyond relational database technology by offering
object orientation as well as support for managing unstructured data. It
supports open standards including SQL, JDBC and ODBC; access from Perl and
Python; and HTTP-based services with HTML or XML content. SAP DB is platform
independent, so users can deploy it for a wide array of projects.

   Since 1994, the SAP e-Business Solution is available on SAP DB 
technology.
Today  SAP DB is being used by nearly 800 customers.

  On October 5, 2000, at Linux World SAP DB was announced to be made 
available
as Open Source software using the GNU General Public License for the 
database
kernel and the GNU Lesser General Public License for clients and programming
interfaces.


http://freshmeat.net/projects/sapdb/

I'd never heard of SAP DB before, although I've heard of SAP.

This looks as if it would be good for a ZODB storage.

--
Steve Alexander
Software Engineer
Cat-Box limited


___
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] Class attr hotfix

2001-03-05 Thread Steve Alexander

Casey Duncan wrote:

>
> Oh nothing too scary. Mostly I have used it to store a counter to
> automatically assign ids to new ZClass instances.
> 
> I was really thinking of this as a way to store properties across all
> instances of a ZClass. I agree that manipulating objects from DTML is
> BAD. My intention was to just store a property value or three.

You could use webdav propertysheets attached to the ZClass object for this.

--
Steve Alexander
Software Engineer
Cat-Box limited


___
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] is there a hook for before the transaction is committed

2001-03-05 Thread Steve Alexander

John D. Heintz wrote:

> Hi Tim,
> 
> I have two suggestions, I hope one of them helps.
> 
> 1) Attached is a TM.py file that I wrote based on the one you mention 
> below.  I've tried to make it more obvious and better documented.
> 
> 2) Don't use this kind of functionality, but rather use sub-transaction 
> commits.
> 
> The first suggestion has more overhead than what I assume you would 
> need, but the second one won't work for all situations.
> 
> A Fishbowl proposal of mine, HashingSupport, was going to use the same 
> kind of hook you are asking about.  In this case though, using 
> sub-transaction commits made a lot more sense.
> 
> In general though, I think that _v_* attributes pose a non-trivial 
> problem that probably requires a hook on abort() if not commit() as well.


Take a look at ZPatterns; specifically, the classes Keeper and Kept from 
ZPatterns/Transactions.py

You can see examples of how they are used in DataSkins.py and Rack.py, 
although there really isn't much to it.

I've included the docstrings below.

class Keeper:
"""Resets an object's per-transaction cache attributes at txn boundaries
Note that Keepers are created by Kept objects semi-automatically, 
and   there is usually no need to create one manually.  A Keeper
automatically registers itself with the Zope transaction upon
creation, and instructs its Kept client to clear its per-transaction
cache at all transaction boundaries.  Keeper methods are called only
by the Zope transaction, so don't mess with them."""


class Kept(Base):
 """Thing which has a Keeper to clear its per-transaction cache.

 Objects derived from Kept should reference the 'self._v_Keeper'
 attribute whenever they need to flag that they have made changes to
 their cache that would require it to be cleared.  (Note that
 '_v_Keeper' is an *attribute*, not a method, and so should not be
 called, just referenced.)

 Once this has been done, the next transaction state transition
 that occurs (sub/main transaction commit or abort) will cause
 the object's Keeper to call for a cache reset.

 Subclasses of Kept should define a '__per_transaction_cache_attrs__'
 attribute as a sequence of attributes which they would like to have
 deleted from their '__dict__' at reset time.
 """


___
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, DynPersist.dll and Zope 2.3.0

2001-03-04 Thread Steve Alexander

Morten W. Petersen wrote:

> Hi guys,
> 
> I've got a problem making a version of the DynPersist.dll file work
> on windows.  The message when trying to load the DynPersist module
> says (paraphrasing) "A unit attached to the system doesn't work".
> Anyone else experienced this?


Try this one:

   http://www.cat-box.net/steve/DynPersist-0.4.3b1.dll

I've had this one working on Windows 2000, Zope 2.3.


> Also, I read that users of > Zope 2.2.x could skip this module,
> is there any quick hack to fix this?

It should be possible. However, getting attributes from a DataSkin would 
probably take a bit longer.

I haven't tried it, so I don't have a quick hack.

Basically, take a look at DynPersist.c, and roll the same functions for 
__get_attr__, __set_attr__ and __del_attr__ into the DataSkin class from 
DataSkins.py.

--
Steve Alexander
Software Engineer
Cat-Box limited




___
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] PlugIns: updated dtml files for ZPatterns+PlugIns

2001-03-04 Thread Steve Alexander

Hi folks,

I've updated the dtml files for Zope 2.3 for the PlugIns product.

You can find them here:

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

The update is to fix some badly formed HTML that makes the Zope 
Management Interface unusable with recent Mozilla builds.

The same problem affects Zope 2.3 from public CVS.

See Collector report 2020:

   http://classic.zope.org:8080/Collector/2020/view

--
Steve Alexander
Software Engineer
Cat-Box limited


___
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] Could not load state?

2001-02-28 Thread Steve Alexander

Chris Withers wrote:

> Hi,
> 
> I've started seeing errors like this:
> 
> --
> 2001-02-27T11:18:34 ERROR(200) ZODB Couldn't load state for
> '\000\000\000\000\00
> 0\021\275\220'
> Traceback (innermost last):
>   File E:\Zope\23C76D~1.1B1\lib\python\ZODB\Connection.py, line 477, in
> setstate
> 
> AttributeError: 'None' object has no attribute 'load'
> 
> ...popping up from time to time. I think they're coming from a product we've
> written, but beyond that I have no idea what's going on.

I hazard a guess that you're changing a mutable attribute of a persistent object, 
without doing a _p_changed=1 on your persistent object.

--
Steve Alexander
Software Engineer
Cat-Box limited


___
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] How to build indexes in the MemberCatalog of Membership Component?

2001-02-27 Thread Steve Alexander

Bill Anderson wrote:

>
> I use, and recommend the use of a ZPattern trigger. You can get it by
> downloading the DataSkins product. This way, whenever a member is
> modified, it automatially updates/creates it's entry in the catalog.
> Just be sure to specify MemberCatalog :)

To expand on what Bill said:

Stick this in a SkinScript method in your Membership folder, on the Data Plug-Ins tab 
of err... Users perhaps? User Sources?
You should be able to work it out. (I don't have a live LoginManager to hand right 
now.)

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

--
Steve Alexander
Software Engineer
Cat-Box limited


___
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] catalog object owners?

2001-02-26 Thread Steve Alexander

Morten W. Petersen wrote:

> 
> Aha?  So if I specify a field index of, get_parent_node_id, which is a
> function call on all objects that are to be indexed, this would
> index the returned value?

yes.

> If so, how long has this been available?

Absolutely ages!
At least since 2.2. I don't have any 2.1 installs around to check with.

--
Steve Alexander
Software Engineer
Cat-Box limited


___
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 problems

2001-02-26 Thread Steve Alexander

Morten W. Petersen wrote:

 > Hi guys,
 >
 > I'm having trouble making ZCatalog work.  The problem is that there
 > are 29 objects of a given meta type, with the same booleans that
 > should be returned for an iteration; but only 20 are.  Is this a
 > result of caching perhaps?  Or lazy results?

Could be that your objects have different ideas of what are proper 
boolean values.

I assume you're using a FieldIndex. Try calling 
uniqueValuesFor(index_name) to see what values are stored. You may find 
that you have 0, 1, '1' and '', for example.

In situations like that, I get the unique values, then construct a query 
for the catalog based on the true or false values.

To get the true values, something like

   Catalog(boolean_index=
filter(None, Catalog.uniqueValuesFor('boolean_index'))

To get the false ones:

   Catalog(boolean_index=
 filter(lambda x: not x,
    Catalog.uniqueValuesFor('boolean_index'))

--
Steve Alexander
Software Engineer
Cat-Box limited


___
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.3.1b1, strange things when ConflictError.

2001-02-26 Thread Steve Alexander

Erik Enge wrote:

> On Mon, 26 Feb 2001, Steve Alexander wrote:
> 
> 
>> Chris McDonough wrote:
>> 
>> 
>>> The use of a literal anonymous list in methodb's signature for "objects" may
>>> have something to do with the results you're getting on conflict.  Try
>>> assigning "objects" to an empty list in the method body instead.
>> 
>> Of course!
> 
> 
> I'm missing out on something here.  Why is this an "of course"?  What's a
> "literal anonymous list"?

Consider this method:

   def methodFoo(self, objects=[]):
 # do stuff, including altering the list objects

The list that is assigned to "objects" in the definition of arguments is 
only created once. There is only one instance of the list for all the 
calls to methodFoo. If you alter that list, then it is altered for the 
future too.

Try it in Python from the interactive prompt:

 >>> def foo(o=[]):
...   o.append('x')
...   print o
...
 >>> foo()
['x']
 >>> foo()
['x', 'x']
 >>> foo()
['x', 'x', 'x']
 >>>

--
Steve Alexander
Software Engineer
Cat-Box limited


___
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.3.1b1, strange things when ConflictError.

2001-02-26 Thread Steve Alexander

Erik Enge wrote:

 >
 > The reverse problem is now gone.  But the fact that every time I get
 >  a ConflictError it doesn't "flush" the 'objects' of methodB, and
 > just seems to append to it, still remains.
 >
 > I only get this when a ConflictError occur.

I don't know exactly why this might happen. I'd need to reproduce the 
problem, and look through things with a debugger, or instrument the code 
with print statements or something like that.

Perhaps you've found a bug (or feature) in the support for concurrency 
in Extension Class.

You can probably work around the problem, and get faster code into the 
bargain: rewrite methodB so that it is not recursive.

--
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.3.1b1, strange things when ConflictError.

2001-02-26 Thread Steve Alexander

Chris McDonough wrote:

> The use of a literal anonymous list in methodb's signature for "objects" may
> have something to do with the results you're getting on conflict.  Try
> assigning "objects" to an empty list in the method body instead.

Of course! Yet another demonstration of the dangers of using mutable objects 
carelessly :-)

--
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.3.1b1, strange things when ConflictError.

2001-02-25 Thread Steve Alexander

I wasn't reading the code clearly the first time around.

By far the simplest place to return copied results from methodB is to 
change the last line to

  return objects[:]

Erik Enge wrote:

> 
> def methodB(self, object, skip=[], stop=[], objects=[]):
> "doc string"  
>   try:
>   if object.meta_type in skip:
>   return self.methodB(object.getParentNode(), skip,
>   stop, objects)
> 
>   if object.meta_type in stop:
>   raise AttributeError
>   else:
> # I don't think I need this.
>   if object not in objects:
>   objects.append(object)
>   else:   
>   raise AttributeError
>   
>   return self.methodB(object.getParentNode(), skip,
>   stop, objects)
>   except AttributeError:
>   return objects

--
Steve Alexander
Software Engineer
Cat-Box limited


___
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.3.1b1, strange things when ConflictError.

2001-02-25 Thread Steve Alexander

Erik,

You're returning a mutable object from methodB. You should either return 
an immutable object (such as a tuple or a string), or return a *copy* of 
your mutable object.

some_list.reverse() reverses the list in-place. That's why you're seeing 
the strange reversal results you report.

The easiest way to achieve this is to change methodA as below:

> 
> def methodA(self):
> "doc string"
> objects = self.methodB(self)
>   objects.reverse()
> 
>   attrib = '' 
> 
>   for object in objects:
>   attrib = attrib + 'some html'
> 
>   return attrib

def methodA(self):
  "doc string"
  objects = self.methodB(self)[:]
  objects.reverse()

Here, you're making a copy of what methodB returns, before doing stuff to it.

Otherwise, you can re-reverse what methodB returns using try: finally: in methodA.

If methodB is called by anything else, as methodB is recursive, you should either make 
it non-recursive, or access it via a methodC:

def methodC(self, object):
  return self.methodB(object)[:]

--
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 ZCatalog Stuff.

2001-02-25 Thread Steve Alexander

Christopher Petrilli wrote:

> 
> SMOC :-)

You're in the South Michigan Orienteering Club?
   http://www.angelfire.com/mi/SMOC/

You think we should implement indexes using the Shell Multivariable 
Optimising Controller?

   http://www.yokogawa.com.sg/Public/Solution/SMOC.asp

Or some Simulation Middleware Object Classes?

   http://www.ntsc.navy.mil/Programs/Tech/ModSim/SMOC/smoc.htm?men=PGD


Otherwise, I'm stumped :-)

--
Steve Alexander
Software Engineer
Cat-Box limited


___
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] Storing lots of big objects in containers

2001-02-24 Thread Steve Alexander

Morten W. Petersen wrote:

> [Erik Enge]
> 
> | Can't you just subclass the BTree Folder as you would with OFS.Folder?
> | 
> | I think you might be confusing the Zope BTree implementation with the
> | BTree Folder Product?
> 
> I've tried subclassing BTreeFolder, but then, whenever the object is
> accessed, zope falls flat on its face.  :-\

If you're deriving from BTree, make sure that the class BTree's __init__ method gets 
called.
Otherwise, there will be no BTree obeject to store your data in.

Does your class have an __init__ method? If so, you need to put as its first line:
  
  MyClass.inheritedAttribute('__init__')(self)

Where MyClass is the name of your class.

--
Steve Alexander
Software Engineer
Cat-Box limited


___
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] Minor typos/changes to ZCatalog.

2001-02-24 Thread Steve Alexander

Erik Enge wrote:

 >
 > Will FieldIndexes also behave like TextIndex, in that they remove
 > stop words, digits and so forth?

No.

 > I think I've picked up somewhere that FieldIndexes treats the whole
 > content of the attribute it indexes as one big chunk of .. erm...
 > characters, and doesn't remove anythink?  Correct?

Yes.

But it's not just characters. A field index indexes an object, and uses 
the overloaded comparison operators for that object to put it in an 
appropriate place. So, you can index DateTime objects, tuples, strings, 
numbers, floats...

--
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] Python Script

2001-02-23 Thread Steve Alexander

Cyril Elkaim wrote:

 >
 > for item in container.objectItems():
 >   if string.strip(item[0]) == image:
 > image_width = int(item[1].getProperty("width"))
 > image_height = int(item[1].getProperty("height"))

Also, a stylistic point:

In Python, you can use something called "tuple unpacking" or "list 
unpacking" that can often help to make your code clearer if you find 
yourself referencing the elements of a tuple by index.

Thus, you can rewrite your code, quoted above, as below:

   for name,object in container.objectItems():
 if string.strip(name) == image:
   image_width = int(object.getProperty("width"))
   image_height = int(object.getProperty("height"))

--
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] Python Script

2001-02-23 Thread Steve Alexander

Cyril Elkaim wrote:
 >

> This script works fine if I test it inside the test tabs of the zclass. But
> if I run it from an instance 'container.objectItems()' returns nothing. I 
> understand why but my problem is how to get access of the images from
> the instance.
> 
> What I need is something giving a reference to the zclass definition from
> one of its instance. I think I can use the DOM model and walk through until
> I find it but it should be better to have a direct access from the instance
> itself, wrong?

>From an external method, you can do

  dir(self.__class__)

or

  dir(type(self))

to get the attributes of your class.


 From a PythonScript, you can use something like

   container.Control_Panel.Products.product_name.class_name

to get a reference to the ZClass definition.

You should also be able to use this:

   container.manage_addProduct['product_name'].class_name

I suggest you make a PythonScript or external method in your ZClass 
definition called list_attributes, that returns a list of the attributes 
of the ZClass definiton. Your other methods can call that.
That way, if you change the Product of your ZClass in the future, you 
only have one thing to alter (should you choose the PythonScript).

I advise against using an external method for this, as (if you're not 
careful) it may return unwrapped objects, which is a security hazard.

--
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] Python Script

2001-02-23 Thread Steve Alexander

Cyril Elkaim wrote:

>
> How can I access the methods definitions of the zclass from an instance ?
> 
> I don't talk about calling them but getting an 'attribute' of the zclass
> knowing only its name at _runtime_ not _compile_ time?

I don't entirely understand what you want to do.

Calling a method on a ZClass instance involves getting the attribute 
that represents that method, then calling it. Get the object that 
represents the method, and do what you want with it.

Can you give me a concrete 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 )



Re: [Zope-dev] ZPatterns feature patch: kickTriggers

2001-02-23 Thread Steve Alexander

Steve Spicklemire wrote:

 > Hmmm...
 >
 > tripTriggers(...)

I like this one.

 > pullTriggers(...)
 > fireTriggers(...)

I'm not so sure about these two.

I think the name should not imply that calling the method will cause 
triggers to be fired immediately, as the triggers are fired only at a 
transaction boundary.

 > dunno... kickTriggers works for me...

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] Python Script

2001-02-23 Thread Steve Alexander

Cyril Elkaim wrote:

>Hi All,
> 
> I must say that I have very hard time with both Scripts and Zclass.
> My problem is the context and the container proprties of a script inside a Zclass.
> 
> If I understand well the context is an URL point of view, the object accessed
> through the web.
> 
> The container is fixed, it's the object in the database, OK?
> 
> Now what is the container in the case of a Zclass _instance_. 

In this case, container is the ZClass instance.

This is consistent with the object-oriented way of defining methods in a class 
definition, and using them bound to an instance of that class.

--
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 feature patch: kickTriggers

2001-02-23 Thread Steve Alexander

I've patched DataSkins.py to add this method:


 def kickTriggers(self,_v_status_=_v_status_,_v_dm_=_v_dm_):
 """Cause triggers to be set off at the end of this
transaction, without needing to set any attributes."""
 self = self._canonicalForm()
 if self._v_status_ is not ChangedStatus:
 d=self.__dict__
 d[_v_dm_]._objectChanging(self)
 d[_v_status_] = ChangedStatus


I often want triggers to fire on a DataSkin because some other 
specialist knows about a change that will affect that Dataskin's 
computed attributes. I don't need to change the DataSkin; I just want 
the triggers to fire at the end of the transaction.

My current hack for causing triggers to fire without needing to actually 
change an attribute has recently stopped working.

   object.propertysheets.Basic.
   manage_changeProperties(bogus_property_to_prime_triggers=1)

This is due to recent optimisations in OFS/PropertySheets.py in Zope 2.3 
from CVS -- now, an object only gets changed when you alter a property 
that actually exists. This is a good thing, as it reduces bloat in the ZODB.

I'd welcome suggestions on a better name for the method than 
"kickTriggers". :-)

--
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] initializing objects in ZPatterns

2001-02-22 Thread Steve Alexander

Christian Scholz wrote:

>
> I've now tried
> 
> WHEN OBJECT ADDED CALL
>   
>self.propertysheets.data.manage_changeProperties(company_address=self.company_address)
> 
> which gives me some Unauthorized error on the method call.

Give your skinscript an appropriate proxy role.

--
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 madness. (Must log in as emergencyuser.)

2001-02-22 Thread Steve Alexander

Chris McDonough wrote:

> I'm not sure why this isn't in 2.3.1b1, but yes, the code in getobject was
> changed to use unrestrictedTraverse for this very reason.

Does that open up a security hole?

Can I get to an object via the getobject method of ZCatalog that I can't get to 
otherwise?

I thought that was the reason it was changed to restrictedTraverse in the first place.


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

2001-02-22 Thread Steve Alexander

Chris Withers wrote:

> Tres Seaver wrote:
> 
>> Chris, this necrohippophilic sadism has to stop!
> 
> 
> Erm? I think my education is lacking... what does that mean? :-S

necrohippo philic sadism
dead-horse-loving act of deliberate harm upon

--
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] Setting vars in expression eval() namespace

2001-02-22 Thread Steve Alexander

Julio Maia wrote:

> 
> This is not going to be handy once the block is composed by a large dtml
> block. I wonder if dtml-var shouldn't support the syntax I've described
> above.

I suggest instead using a PythonScript, and using the DTML class that you
can import from the Products.PythonScripts.standard module.

You can use this to render DTML on the fly, as you wish.

--
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] initializing objects in ZPatterns

2001-02-22 Thread Steve Alexander

Christian Scholz wrote:

> Hi!
> 
> I just encountered another problem with ZPatterns (well not exactly with ZPatterns
> but the way I use it.. ;-)
> 
> I have some Specialist with a normal rack which stores data persistently in the ZODB.
> Everytime I am creating a new object I want to create an object of another specialist
> on the fly and store it's id inside my first object.
> 
> Thus I have setup a SkinScript with the following content:
> 
> 
>   INITIALIZE OBJECT WITH company_address=addresses.createAddress()
> 
>   WITH addresses.getItem(self.company_address) COMPUTE company_addr=RESULT
> 
>   STORE company_address IN SELF
> 
> The createAddress is called actually and it returns the ID of the new object
> (thus the object is created). Unfortunately the id is not stored inside
> company_address. After reading the new object again this value is still empty
> (and thus also no address object is return by the address specialist). Same happens
> when just using some dummy property and filling it with a fixed string. This
> also disappears..

To get company_address stored, you can probably do something like:

  your_object.manage_changeProperties(company_address=your_object.company_address)

or possibly your_object.propertysheets.NameOfSheet.manage_changeProperties...
depending on what kind of object you're using.

You could have this as a trigger:

WHEN OBJECT ADDED CALL
  self.manage_changeProperties(company_address=self.company_address)


As for whether it is a bug, the implementation of the INITALIZE clause just puts
its attributes directly into the DataSkin's attribute-cache. It appears to be
designed for the behaviour that you see.

You could get the behaviour that you want by making the implementation actually
set the attributes instead. I'm not sure what the other implications of doing
that are, though.

If you're interested, the code is in

  lib/python/Products/ZPatterns/SkinScript/Components.py
about line 71.

--
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] Setting vars in expression eval() namespace

2001-02-22 Thread Steve Alexander

Julio Maia wrote:

 > Hi,
 >
 > I'm trying to create a tag to evaluate the expression passed to it,
 > adding in the expression eval namespace a variable that contains
 > the result of dtml processing of the tag's block. For instance, the
 >  following construct:
 >
 > 
 >   some text 
 > 
 >
 > would invoke the expression "foo(a=1)" with a variable named 'block'
 >  set to 'some text 3' in the expression's namespace (btw, is it
 > possible to achieve this using regular dtml?).

This may be too simple example, but how about:



--
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] DTML Documents/Folders in ZClasses fail to access anything

2001-02-21 Thread Steve Alexander

Itai Tavor wrote:

> Hi,
> 
> I got a ZClass 'Test', with a DTML Method 'view' containing  id>, and a DTML Document 'view2' with the same line. instance/view 
> works. instance/view2 returns (ZDebug output):

>From SimpleItem.py:

"""Direct use of the 'id' attribute is deprecated - use getId()"""

The difference you're seeing is because the DTML Method is acquiring the
id attribute, whereas you're getting the DTML Document's own id
attribute.

--
Steve Akexander
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] Python Product as DataSkin

2001-02-21 Thread Steve Alexander

Michael R. Bernstein wrote:
 >
 > File /home/webmaven/Products/ZPatterns/DataSkins.py, line 208, in
 > __set_attr__ (Object: ElementWithAttributes) KeyError: (see above)



What version of ZPatterns are you using?

I certainly don't have the __set_attr__ method covering line 208 in my 
version.

This looks like a bug I reported (w/ patch) for the last but one 
"official" release, the fix to which made it into ZPatterns-0.4.3b2 (the 
latest one on the ZPatterns page).

The first few lines of the __set_attr__ method of DataSkin.py should 
look like this:


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

If they don't, you'll get the error that you're reporting.

Try installing the latest ZPatterns and see what happens. If you're 
using Zope 2.2.x, use the "official" one. If you're using Zope 2.3, 
you'll need to apply various patches, or use my interim version, which 
works only with Zope 2.3.

   http://www.cat-box.net/steve/ZPatterns-stevea-20010204.tar.gz

--
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: ThreadSafeCounter

2001-02-21 Thread Steve Alexander

Andy McKay wrote:

>> | The ideal solution would be to use an object that lives in the ZODB,
>> | I wonder if there is a way to keep the 'object history' empty?  That
>> | is, keeping the counter 'packed' while retaining 'object history'
>> | information on all other objects.
> 
> 
> That would work, however I just dont think that fits neatly into the ZODB in
> any way since all objects are appended.

Don't get ZODB confused with FileStorage. What you say is true of FileStorage, not of 
ZODB.

 
>> I'm no ZODB expert, but I think the short story is that you can't have
>> this across several threads -- because you would have to use _v_
>> attribs.  And what good is a ThreadSafeCounter if it's not threadsafe?
> 
> Well it would be threadsafe since the object cannot be written too by
> multiple threads as discussed earlier it will keep try 3 times and then
> fail. To me the ideal answer is a simple FileSystem product that allows you
> to mount a file system inside the ZODB. This would implrement locking and be
> hence be thread safe. Its a real science project. This would also have to be
> ZEO friendly, but to be honest for my use and most other peoples, this isnt
> a huge concern.

A simpler solution is to use a mounted storage that doesn't do undo, and stores 
changes in place.

--
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] Unindex_Object, bug (Again)

2001-02-20 Thread Steve Alexander

Chris McDonough wrote:

> Andy,
> 
> Eek!!  Please do submit this to the collector again.
> 
> Apologies,
> 
>  - C
> 
> - Original Message -
> From: "Andy Dawkins" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, February 20, 2001 7:18 AM
> Subject: [Zope-dev] Unindex_Object, bug (Again)
> 
> 
> 
>> The bug with zope 2.3.0 that I reported with this mail:
>> 
>> http://zope.nipltd.com/public/lists/dev-archive.nsf/ByKey/5FE0F6EF4EFF2299
>> 
>> Has made it in to 2.3.1b1
>> 
>> Can we please get rid of it this time??
>> 
>> Do I need to submit anything to the collector for this to happen?

It is already fixed in 2.3 from public CVS.

--
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.3.1b1 bug? (:tokens)

2001-02-20 Thread Steve Alexander

Erik Enge wrote:

> Hiya.
> 
> variable:tokens
> 
> is a bit fubar.  If I raise it on the next page it says stuff like 
> 
>   ['item', 'item1', 'item', 'item']
> 
> ie. it repeats some of the items in variable for no apparent
> reason (variable contains only 'item' and 'item1').  Also, if I do:
> 
>   ">
> 
> and raise variable2 on the "next page" it says:
> 
>   ['item', ['item1']]

> Is it just my installation?  Zope 2.3.1b1 on Linux 2.4.1 with python
> 1.5.2.  If need be I can do a thorougher report and possibly a patch, but
> not till later this week I'm afraid.

I just tried to reproduce this with 2.3 from CVS.
Here's the DTML Method I used:




  
  
">
  
  



It all works as I expect; no problems.

--
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 goes crazy after ZClass change

2001-02-20 Thread Steve Alexander

Itai Tavor wrote:

> Hi,
> 
> I have a Rack which uses ZClass Company for storage. I renamed Company 
> to CompanyX and created a new Company ZClass, giving it the same 
> methods, propertysheets and properties as CompanyX. When I tried to view 
> editInstanceForm_html of an instance of this class, I got the method 
> stored in CompanyX. So I deleted CompanyX from the control panel. I 
> still got the CompanyX method. I used the Rack's Storage tab to select 
> another ZClass. Still got the method from CompanyX.
> 
> when I click Remove Orphaned Slots on this Rack, I get:
> 
> Any ideas how I can fix this without recreating the Rack and all my 
> persistent data?

Use the Zope Undo mechanism to return your application to the state it 
was in before you renamed Company to CompanyX.

Either that, or restore from one of your backups.

Check things are working. Now, take another backup.


Then, do the same renaming thing as you did before, but ensure that you 
make the new Company ZClass have the same "Class Id" as the old one had, 
and that the old Company ZClass (now CompanyX) has a different "Class 
Id". You can find the "Class Id" field on the Basic tab of a ZClass.

This "Class Id" is how Zope works out what ZClass to use when it comes 
across a ZClass instance.

--
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] Python Product as DataSkin

2001-02-20 Thread Steve Alexander

Michael R. Bernstein wrote:
 >

>> In Zope 2.3) it is aliased to Globals.InitializeClass.
>  
> So, if I'm developing this on 2.2, I need to use
> Globals.default__class_init__(FooClass) instead of
> Globals.InitializeClass(FooClass)?

Yes. At least, using default__class_init__ will work on Zope 2.2 and 2.3.
I don't know whether InitializeClass is in Zope 2.2, but it is definitely in Zope 2.3.
  
>> Use it by having
>> 
>>   import Globals
>> 
>> somewhere in your class definition,
> 
> If 'import Globals' appears at the start of the FooClass.py
> file, does it still need to appear in the class definition
> itself?

Sorry -- my imprecise language!
"import Globals" needs to be in the .py file that your
class is defined in, at the module level of indentation.
You're importing Globals so that you can use it in the 
module rather than in the Class definition.


>>   Globals.InitializeClass(YourClassName)
>> 
>> at the end.
> 
> 
> At the end on the file, or the end of the class definition?

After the class definition, so, qiute probably at the end of the file.

--
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] Python Product as DataSkin

2001-02-19 Thread Steve Alexander

Michael R. Bernstein wrote:

> Steve Alexander wrote:
> 
>> Is the __init__ method of DataSkin getting called?
>> 
>> This would happen if, for example, you define an __init__ method in your
>> class, but you don't use something like:
>> 
>> from Globals import default__class_init__
>> 
>> default__class_init__(yourClass)
>> 
>> At least, I *think* that's one of the things that default__class_init__
>> does.

Nope... I got confused. Globals.default__class_init__ sets up the security
attributes for you class, from whatever combination of security
declarations you've used.

In Zope 2.3) it is aliased to Globals.InitializeClass.

Use it by having

  import Globals

somewhere in your class definition, and 

  Globals.InitializeClass(YourClassName)

at the end.

See the following URL for more information:

http://www.zope.org//Wikis/DevSite/Projects/DeclarativeSecurity/ZopeSecurityForDevelopers


>> Otherwise, you'll need to make sure you call DataSkin.__init__
>> from your __init__ method, probably using Acquisition.inheritedAttribute.)

So, at the start of your __init__ method, call:
   NameOfYourClass.inheritedAttribute('__init__')(self, id)

Your __init__ method might look like this:

   def __init__(self, id, title):
   FooClass.inheritedAttribute('__init__')(self, id)
   # rest of your __init__ 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] Python Product as DataSkin

2001-02-19 Thread Steve Alexander

Michael R. Bernstein wrote:

 >
 > Hmm. I thought I was doing it wrong. Here is the error and traceback
 > from trying to instantiate the modified Product (through the
 > standard mgmt interface):
 >
 > This resource may be trying to reference a nonexistent object or
 > variable _v_dm_



 > Any ideas?

Is the __init__ method of DataSkin getting called?

This would happen if, for example, you define an __init__ method in your 
class, but you don't use something like:

from Globals import default__class_init__

default__class_init__(yourClass)

(At least, I *think* that's one of the things that default__class_init__ 
does. Otherwise, you'll need to make sure you call DataSkin.__init__ 
from your __init__ method, probably using Acquisition.inheritedAttribute.)

--
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 Zope for Groupware/Messaging applications

2001-02-18 Thread Steve Alexander

Joachim Werner wrote:

 >
 > And, instead of switching back-ends in ZPatterns, I could as well
 > just rewrite my non-ZPattern objects to work with the new back-end,
 >  which doesn't seem to be more work.

Well, do your first project both ways. It would make an interesting 
comparative study.


I think you're getting distracted by the flexible storage options of 
ZPatterns, and missing the main benefit to your application.
In your original message, you said:

 > There should be very flexible views on the data, e.g. a message or
 > document can  either be viewed on the owner's personal workspace or
 > on the project portal the document was posted to.

"Flexible views on the data" is where ZPatterns really makes things 
easier. Of course there are other ways to achieve the same ends. 
However, I believe that using ZPatterns makes it easier to evolve your 
system in the face of changing requirements.

--
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] Calling Catalog from python script

2001-02-16 Thread Steve Alexander

R. David Murray wrote:

>
> And the expedition was a qualified success.  It turns out that
> getObject has one of those nasty unadorned try: except: structures
> in it.  It was masking an authorization error.  The auth error
> is occuring in urestrictedTraverse, and the last lines of my traceback
> are:
> 
>   File /usr/local/zope/Zope230/lib/python/OFS/Traversable.py, line 190, in unrestr
> ictedTraverse
> (Object: ApplicationDefaultPermissions)
> Unauthorized: 0060175400
> 
> 0060175400 is the ID of the first object returned by the catalog.
> 
> Any guesses why this is happening?  I get the same result whether I'm anonymous
> or logged in as a manager.
> 
> Also, anyone want to guess why getObject uses try/except?  I can't off
> the top of my head think of any reason it should be there.
> 
> This is 2.3.0, I suppose I should try the new beta just for kicks...

Yes, do try the new beta. If this is what I think it is, it is fixed in the latest
2.3, as I submitted the patch that fixed it :-)

Are your objects traversed to through an object that does __bobo_traverse__
-- like a ZPatterns Specialist, for example?

If so, that's your problem. It's a combination of ZClasses not having a __roles__
attribute, and some security context being lost when going through a
__bobo_traverse__.

The patch to ZCatalog brains makes it fall back on resolve_url, which works
just fine.

--
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] SkinScripts instantiating new objects

2001-02-16 Thread Steve Alexander

Stefan Karlsson wrote:

> 
> BTW is it possible to save the ProjektHandler instance persistently
> in the attribute? Is there an easier way than creating a separate
> specialist for the ProjektHandler class and storing the instances there?

I think you're getting design and implementation confused here.

Should ProjektHandlers be a Dataskins? If so, they should live in their own Rack.
Or, does a ProjectHandler really belong as a part of the instance of something else?
In this latter case, you could add a ProjectHandler as an attribute.
As to whether this is a wise thing to do; well, I can't say, as I don't know what 
problem you're trying to solve.

If you want to store ProjektHandlers as attributes of a persistent class, just add 
them, using a method of your base Python class, or an External Method.
In this case, you'll almost certainly want to define the ProjektHandler class in a 
Product, and not in an External Method.

 
>> That's as I expect. Generally, you call methods from URLs, you don't 
>> retrieve the values of attributes.
> 
> So, what do you suggest, should I implement __bobo_traverse__ or
> something in foo to make the URL work?

Yes.

For example, make projekt a method rather than an attribute. Or, have a getProjekt 
method.

I'd like to offer some advice, but please don't take this the wrong way; I mean it 
respectfully.
You seem to be trying to design your application using SkinScript and External Methods 
and Specialists.
I suggest first designing the application on paper, then implementing it using 
SkinScript, Specialists and so forth.

--
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] SkinScripts instantiating new objects

2001-02-16 Thread Steve Alexander

Stefan Karlsson wrote:

 > Hi,
 >
 > I want my SkinScript to instantiate a new object of type
 > ProjektHandler and put it into an attribute called projekt.

In your example, there is no sense of the ProjektHandler instance being 
saved persistently in the attribute. A new object is created for each 
transaction. Is this what you want?

 > For this I have created
 > an external method, returning a new object of type ProjektHandler

Where have you put this external method? That is, where in the ZODB?


 > The skinscript look like this:
 >
 > WITH self.getNewProjektHandler(self.id, 'Projektagare')
 >   COMPUTE projekt=RESULT
 >
 > This works if I call it from python, e. g print
 > self.mySpecialist.getItem('foo').projekt
 >
 > But it does not work when I call it from the web, e. g >
 >   http://server/mySpecialist/foo/projekt

That's as I expect. Generally, you call methods from URLs, you don't 
retrieve the values of 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 )



Re: [Zope-dev] AttributeError

2001-02-16 Thread Steve Alexander

Andre Schubert wrote:

> 
> Could anyone help me to solve the following Error that occurs sometimes.
> 
> 2001-02-16T09:11:42 ERROR(200) ZODB Couldn't load state for
> '\000\000\000\000\000\0008\004'
> Traceback (innermost last):
>   File /usr/share/Zope-2.2.4/lib/python/ZODB/Connection.py, line 443, in
> setstate
> AttributeError: 'None' object has no attribute 'load'
> 
> Q: How can a find out wich object affected, by id or path or somewhat
> else ??
Andre,

What products do you have in your Zope installation?

Are you using any External methods?

This sounds like something has written something to the ZODB that 
shouldn't be written there.

--
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] How to read ZODB with Python script?

2001-02-15 Thread Steve Alexander

Petr Knapek wrote:

 >
 > I would like to know how to connect to running Zope ZODB from
 > a  python script.  I would like to have possibility to read
 > only  objects from ZODB?  Is there any possibility how to do
 > it when Zope application server is running and not to corrupt
 > the ZODB?

This was asked on the [EMAIL PROTECTED] list only a few weeks ago. You 
can look up the discussion in the list archives.

The best solution is for you to use ZEO, and write your python 
object-reader as a ZEO Storage Client.

I believe this is easier than it might sound, although I haven't tried 
it myself.

(did I get the terminology right?)

--
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] Calling Catalog from python script

2001-02-14 Thread Steve Alexander

[EMAIL PROTECTED] wrote:

 > "R. David Murray" wrote:

 >> catent.getobject()
 >>
 >> That would seem to be a lot more OOish.

In 2.3 you can call catent.getObject(). You can pass an optional REQUEST 
in as an argument, to support lookup via resolve_url rather than 
restrictedTraverse.

--
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: ThreadSafeCounter

2001-02-13 Thread Steve Alexander

Tres Seaver wrote:

>
> ...it is quite feasible to have one or more storages
> inside your Zope ... often at a non-trivial time cost.

Where does the time cost come in? I've noticed a delay on first mounting
another storage, but I haven't looked for a delay on accessing objects
in the storage.

--
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: ThreadSafeCounter

2001-02-13 Thread Steve Alexander

Shane's ExternalMount product is here:

   http://www.zope.org/Members/hathawsh/ExternalMount

However, I couldn't find it from searching on zope.org, and it isn't 
listed on Shane's zope.org page.


--
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: ThreadSafeCounter

2001-02-13 Thread Steve Alexander

Andy McKay wrote:

>> A simpler solution is to use a mounted storage that doesn't do undo, and 
>> stores changes in place.
> 
> You are the second person to answer with that. Would anyone care to give a
> quick how-to on how to mount a non-undoing storage, such as FileStorage

FileStorage is what the standard Data.fs is, and it supports undo.

> since this doesnt seem immediately obvious to me.

Take a look at ExternalMount, and at what's used in the CoreSessionTracking product.

I can't find a URL for ExternalMount at the moment. I'm using it though, so it 
*definitely* exists!


Also, see lib/python/ZODB/dbmStorage.py

"""Very Simple dbm-based ZODB storage
 
This storage provides for use of dbm files as storages that
don't support versions or Undo.  This may be useful when implementing
objects like hit counters that don't need or want to participate
in undo or versions.
"""  

--
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] Formal argument for acquisition and aq_self

2001-02-13 Thread Steve Alexander

I've just been reading through some academic papers by Tom Mens.

The paper at this link looks interesting, as it appears to me to 
describe a problem that is addressed in Zope by acquisition wrappers.

http://prog.vub.ac.be/Research/ResearchPublicationsDetail2.asp?paperID=51

Abstract
Most object-oriented languages provide a self pseudo variable that 
serves two purposes: invoking methods through self sends and returning a 
self reference. Current formal models capture this behaviour by 
introducing a self parameter that fulfils both roles. We will show that 
this double functionality is incompatible with object-based 
encapsulation. Moreover we will point out that the separation of both 
functionalities is needed in type systems. We propose a formal model 
based on a primitive self send construct, and present its denotational 
semantics. A self reference is implemented through a self send instead 
of the other way around. This model is extended formally with an 
object-based encapsulation mechanism. It allows us to keep inheritance, 
encapsulation and typing orthogonal. This way we obtain a flexible and 
incremental software development scheme.


In the case of Zope, the "self sends" are represented by the way an 
acquisition wrapper dispatches messages. The "self reference" is given 
by aq_base (or one of the other aq_ attributes, depending on what you 
want "self" to mean at the time).

--
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] Strange AttributeError in AccessControl/User.py

2001-02-13 Thread Steve Alexander

Morten W. Petersen wrote:

> Hi guys,
> 
> indeed a strange problem, anyone experienced this?
> 
>   Zope Error
> 
>  Zope has encountered an error while publishing this resource. 
> 
>  AttributeError
> 
>   Sorry, a Zope error occurred.
> 
>Traceback (innermost last):
>  File /home/morten/Zope/lib/python/ZPublisher/Publish.py, line 222, in 
>publish_module
>  File /home/morten/Zope/lib/python/ZPublisher/Publish.py, line 187, in 
>publish
>  File /home/morten/Zope/lib/python/Zope/__init__.py, line 221, in 
>zpublisher_exception_hook
>(Object: CatalogAware)
>  File /home/morten/Zope/lib/python/ZPublisher/Publish.py, line 162, in 
>publish
>  File /home/morten/Zope/lib/python/ZPublisher/BaseRequest.py, line 442, 
>in traverse
>  File /home/morten/Zope/lib/python/AccessControl/User.py, line 496, in 
>validate
>(Object: RoleManager)
>  File /home/morten/Zope/lib/python/AccessControl/User.py, line 231, in 
>allowed
>AttributeError: aq_inContextOf

What version of Zope are you using?

On my Zope 2.3 fom CVS, the line of User.py that could conveivably cause that error is 
20 line on at 251.

Perhaps you're hitting a but that's been fixed in a later version of Zope, or in CVS 
for the next version?

--
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] Virtual Host Monster Paranoia

2001-02-13 Thread Steve Alexander

Toby Dickenson wrote:

> 
> No, but they can get to:
> 
> http://www.simpledomain.com/blah/VirtualHost/bad.stuff/blah
> 
> which gets rewritten to:
> 
> 
>http://zopehost.foo.com/VirtualHost/http/www.simpledomain/blah/VirtualHost/bad.stuff/blah

If VHM doesn't do it already, patch it so that it rejects URLs with more than one 
VirtualHost part.

> Understanding its behaviour behaviour might be beyond the complexity
> threshold for a paranoid admin to be comfortable.

Then again, there's the advantage of having something included as a standard part of 
Zope.

--
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] ProxyPass and SiteAccess getting REMOTE_ADDR

2001-02-13 Thread Steve Alexander

William Noon wrote:

> Last week I was setting up an Apache VirtualHost to point to a Zope
> object tree using the ProxyPass directive and SiteAccess to get all the
> urls right (great stuff!).
> 
> However, I noticed that the REMOTE_ADDR was always set to the 
> proxy host.  This makes sense because Zope just gets the host/port from
> the socket connection.  But I needed the real remote_addr for logging
> and user admin.  Adding 'Header's wouldn't pass the info to Zope.
> 
> The Zope mail archives mentioned the problem a couple of times without
> a configuration fix.
> 
> A simple fix to the proxy module (in proxy_http.c) will create a new
> header called 'Original-Addr' to contain the client's ip address.

Also, take a look at mod_proxy_add_forward for Apache, and these other resources:

  http://www.zope.org/Members/stephen/ApacheProxyPatch
   http://modules.apache.org/search?id=124

   ftp://ftp.netcetera.dk/pub/apache/mod_proxy_add_forward.c

I believe there is some code in mod_proxy_add_forward to deal with 
getting the client's IP address from chains of proxies.


--
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] http headers

2001-02-12 Thread Steve Alexander

Tim McLaughlin wrote:

> Anyone know how I can log or view the http headers that Zope sends when it
> responds to a http request?

Take a look at tcpwatch:

http://www.zope.org/Members/hathawsh/tcpwatch

--
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] Python Based DataSkins and Propertysheets

2001-02-12 Thread Steve Alexander

Johan Carlsson wrote:

> 
> Whoooha!
> I added PropertyManager to EmployX and it saves properties?

Is that a question? I'm not sure I can answer that.

> Is this correct?
> - The objects are stored presistently in the Racks storage (BTree).

With the way a rack is set up by default, yes. You just say in the Rack what class it 
should store.

> - The attributes 

> (and the propertysheet which is a attribute) 

The properties in a propertysheet are stored as attributes.
The propertysheet is a view on an instance's data.

>   are
>   managed by the "PersistentAttributes" attribute provider.

The PersistentInternalAttributeProvider stores the attributes of an instance in a dict 
in the Rack.

I had a conversation with Phillip Eby on this list a couple of months ago about 
exactly how
PersistentInternalAttributeProviders and PersistentExternalAttributeProviders work. 
You should be able
to find the messages in the list archives.

>   (Can I verify this by some kind of inspection?)

You can look through the ZODB from a python interactive prompt, and look inside a 
Rack's BTree to see how things are laid out.

I think there are some HOT TO documents on looking in the ZODB from the python 
interactive prompt.

> - If I would create Attribute Providers (with SkinScripts) they
>  could redirect the storage to what ever storage i like.

Yes. You may want to set the Rack up differently, that is, so it doesn't store 
Dataskins persistently, but accesses them based on an id.
Look at a Rack's tabs.


> Hm, I realize that I'm still very confused and the only way out of that 
> is "doing stuff" and see what happens.

I guess so :-)  There's also reading the source code... which may or may not help 
clarify things.

--
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] Python Based DataSkins and Propertysheets

2001-02-12 Thread Steve Alexander

Johan Carlsson wrote:

> 
> Ah, I see. 
> But why do I need SimpleItems, isn't PropertyManagers sufficient?

It makes your class play nicely with Zope.

So, it can work with DAV, be copied and pasted, properly work
with traversal, work with ZDOM, be Owned, support undo, work
with Acquisition, and manage roles.

Take a look at the source to lib/python/OFS/SimpleItem.py

You can omit some of this if you know for sure in advance that you
will be using instances of your class only with Specialists in 
Racks.

However, ZPatterns is set up so you can use the same DataSkin class
with instances stored in a Rack or stored as normal Persistent objects
in the ZODB.


>> In your case, I suggest making your class Persistent, and using
>> PropertyManager properties.
>
> But making it presistent doesn't that lock the objects to be stored in the ZODB?
> I may want to change storage to SQL later.

No it doesn't tie the object to the ZODB if you're using a Specialist. That's the 
magic of ZPatterns.

--
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] Python Based DataSkins and Propertysheets

2001-02-12 Thread Steve Alexander

Steve Alexander wrote:

> Johan Carlsson wrote:
> 
>>> You need to derive EmployX from DataSkin and some Zope persistent 
>>> class such as SimpleItem. Otherwise,
>>> it won't be persistent.
>> 
>> Accualy I don´t have to do that.

Looking more closely at DataSkins.py, I see that class DataSkin derives from 
Persistent.

So, I was wrong -- please ignore what I said about needing to derive from Persistent 
:-)

-- 
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] Python Based DataSkins and Propertysheets

2001-02-12 Thread Steve Alexander

Johan Carlsson wrote:

>>> Hi, 
>>> I am trying to figure out ZPatterns and because I rather work with Python Products 
>when with Zclasses I am trying to convert the EmployZ product to Python.
>>> So far I got half the way there, the Rack recognizes the DataSkin
>>> And on newItem in the Specialist it a new slot gets created and I can see them and 
>their ID.
>>> 
>>> Now the problem is creating a Propertysheet in the DataSkin that gets stored in 
>the Rack.
>> 
>> The attributes of a Persistent DataSkin will get stored in the Rack without too 
>much extra work.
>> 
>> 
>> 
>>> class EmployX(
>>> DataSkin,
>>> #VirtualSheets,
>>> ): 
>> 
>> You need to derive EmployX from DataSkin and some 
>> Zope persistent class such as SimpleItem. Otherwise,
>> it won't be persistent.
> 
> 
> Accualy I don´t have to do that.
> Have a look at Itamar Shtull-Traurings and Heiko Stoermers
> FlatDatabase:
> 
> def manage_change(self, REQUEST, RESPONSE):
> """ Change properties """
> for prop in self.database_properties.propertyMap():
> name=prop['id']
> if REQUEST.has_key(name):
> if 'w' in prop.get('mode', 'wd'):
> value=REQUEST.get(name)
> setattr(self, name, value) <<<<
> RESPONSE.redirect(REQUEST.URL1)
> 
> 
> But as I noticed the "properties" was saved as
> attributes not as properties in a propertysheet.

That's another way of doing it. It is a bit less transparent.
I find it more straightforward to make my classes SimpleItems
and PropertyManagers, as it means I can just call
manage_changeProperties() without writing extra methods.


> I can live with that, but I still would like to know if and 
> how to use propertysheets provided by a DataManager
> inside a Pyhton DataSkin?

There are two kinds of PropertySheet in Zope:
  DAV propertysheets
  Propertysheets that go with ZClasses

There are also Properties for objects that are PropertyManagers,
such as DTML Documents.

There is an important difference in how these different types of 
properties work:

  DAV Propertysheets are independent Persistent objects

  Propertysheets that go with ZClasses and also
  PropertyManager propertysheets are stored as attributes
  in the objects they belong to.

Therefore, in ZPatterns, you use AttributeProviders to do stuff
with PropertyManager properties and ZClass-style propertysheets.

You use SheetProviders to do stuff with DAV Propertysheets.

If you're using ZClass-style propertysheets, you need to use
DataSkin Attribute Propertysheets, rather than the default
Common Instance Propertysheets.


In your case, I suggest making your class Persistent, and using
PropertyManager properties.

The reason to use ZClass-style propertysheets is if you want to 
easily partition your properties into sets of properties with
different permissions.

--
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   5   6   >