[Zope] brain hurts regarding dynamic fcn args in Python

2000-06-19 Thread Jeff Sasmor

Hi- I guess I'm somewhere past a 'newbie' (after a few solid months)
and I'm developing a calendar-based (but not based on calendar tag)
'event-log' 'black-box app' for lack of a better term, for eventual relase
to Zope.org, if only as a helper for _new_ newbies.

I'm stuck on what I guess is a pythonish thing and my brain hurts.

Is there a (straightforward?) way to dynamically compose function
argument lists?  For example, in C, you can write"

f(arg1, arg2, (conditional expression)?(val for TRUE state):(val for FALSE state)).

Or  one can embed a fcn call within an argument list in order to supply a
needed function parameter.

In my case here in Zope, sometimes I have to search a ZCatalog
prior to displaying the results in a dtml-in looping construct.

dtml-in
"Catalog.searchResults(meta_type='EventDoc',event_date=[first,last],event_date_usage='range:min:max',sort_on='event_date
')"

  
/dtml-in


Now if the 'moderated' property is active I want to add the keyword arg

reviewed='on'

to the arg list at the time that the searchResults method is invoked.
Since this invokation is in an expression it's certainly a python thing, but I can't 
find
any reference to this type of capability in any reference I have.  Did I miss 
something or
is there just no simple way to do this?

The only way I can see to do it is to wrap Catalog.searchResults() in an external 
method with
some ifs and elifs.


TIA.
Jeff Sasmor
[EMAIL PROTECTED]


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




[Zope] Problem with 1 ZCatalog search on same page

2000-06-28 Thread Jeff Sasmor

Hi Zopistas-

I have problem that I hope that there's an answer to.  Perhaps this has been
covered on this list already, but I couldn't find it by searching the NIP archives
and 800+ results for "ZCatalog" was mind-numbing.

I have two ZCatalog searches on the same page (in the same DTML method). Each
has different fields so they have different numbers of results displayed in two 
tables.  

This works just fine.

What's wierd is that the 'batch_size' code interacts between the two-- if the size of 
the 
first table's  set of  results is  batch size and the size of the second table's 
results
is  batch size then the second table has a "next N results" link.  If I click this 
then 
the second table dutifully displays the next data set.  BUT- the first table just 
displays the
LAST item it had displayed before.

From a quick glance at the way that ZCatalog works, it seems as if this behaviour 
could
be correct; and the batching code in the ZC can't handle more than one set of results 
associated with a single DTML method. But I am by no means sure of my interpretation
of the python code here.


Anyone have any insights?

TIA,

Jeff Sasmor
[EMAIL PROTECTED]


PS. For those Zopistas who are MontyPythonistas: I get to see "Eric Idle exploits 
Monty Python" tonite (weds 6/28) at Carnegie Hall in NewYawkCity.  They promise
lumberjacks, etc.  This goes on tour to some cities in the US this summer. Bought
these tickets months ago so have the 4th Row Orchestra!
I hope this is as good as seeing Monty at NYC's Civic Center 
dtml-more-years-ago-than-I'd-like-to-admit.  John Cleese
stepped on my foot whilst selling albatrosses (?) at that one.  But I digress...



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




[Zope] FYI - poss. reindex_object alleged 'bug' workaround

2000-07-07 Thread Jeff Sasmor

Zopers and PyCoders-

I was having a problem with ZCatalog-- namely, editing
the properties of a CatalogAware item (in a custom form) 
after creation resulted in no change to the indexed value in
the Catalog.

I know about reindex_object and was using that-- so it
wasn't just that I was leaving it out!  Hmmm.

I read the [EMAIL PROTECTED] list archives on zope.nipltd.com
(what a great resource, thanks!!!) and found some mentions that
this was broken in 2.1.6, which is what I am using.

ANYWAY, I found that 

dtml-call "_.this.reindex_object()"

solved the problem immediately (well, for me, anyway). 
Just thought I would pass this on so it would be archived for 
others with this problem (or at least something to try
in a moment of desperation!).

Why does this work?  I have some guesses about some of the 
PyCode in CatalogAwarenesss.py but I'm still too much of a
Python newbie to make any comments.....


Jeff Sasmor
[EMAIL PROTECTED]




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




[Zope] Renderable ZClass and Zope 2.2

2000-07-26 Thread Jeff Sasmor

Hi-
I am trying to 'update' my EventFolder product to
Zope 2.2 but a  really wierd thing is going on:

When I try to create an instance (an EventFolder, which is
subclassed from Renderable and ObjectManager) I get an
error shown in the traceback below.

There EventFolder_add method in the ZClass creates a
catalog (Catalog) which does not seem to be accessable...

yet, why is the instance being renedered at all?  It appears
as if the instance is being rendered before the transaction
is committed and therefore there's no Catalog-- this I get. But
why is the instance being rendered at all?

Is there some incompatability with Renderable and 2.2?

Confusedly,

Jeff Sasmor
[EMAIL PROTECTED]

---
Error Type: AttributeError
Error Value: Catalog

Traceback (innermost last):
  File /usr/local/Zope220/lib/python/ZPublisher/Publish.py, line 222, in publish_module
  File /usr/local/Zope220/lib/python/ZPublisher/Publish.py, line 187, in publish
  File /usr/local/Zope220/lib/python/Zope/__init__.py, line 221, in 
zpublisher_exception_hook
(Object: RoleManager)
  File /usr/local/Zope220/lib/python/ZPublisher/Publish.py, line 171, in publish
  File /usr/local/Zope220/lib/python/ZPublisher/mapply.py, line 160, in mapply
(Object: EventFolder_add)
  File /usr/local/Zope220/lib/python/ZPublisher/Publish.py, line 112, in call_object
(Object: EventFolder_add)
  File /usr/local/Zope220/lib/python/OFS/DTMLMethod.py, line 167, in __call__
(Object: EventFolder_add)
  File /usr/local/Zope220/lib/python/DocumentTemplate/DT_String.py, line 502, in 
__call__
(Object: EventFolder_add)
  File /usr/local/Zope220/lib/python/DocumentTemplate/DT_Let.py, line 147, in render
(Object: folder="EventFolder.createInObjectManager(REQUEST['id'], REQUEST)")
  File /usr/local/Zope220/lib/python/DocumentTemplate/DT_With.py, line 146, in render
(Object: folder)
  File /usr/local/Zope220/lib/python/DocumentTemplate/DT_Util.py, line 337, in eval
(Object: 
manage_addProduct['ZCatalog'].manage_addZCatalog(this(),'Catalog','EventCatalog' ))
(Info: this)
  File string, line 0, in ?
  File /usr/local/Zope220/lib/python/Products/ZCatalog/ZCatalog.py, line 112, in 
manage_addZCatalog
  File /usr/local/Zope220/lib/python/Products/Renderable/Renderable.py, line 17, in 
__str__
(Object: Renderable)
  File /usr/local/Zope220/lib/python/OFS/DTMLMethod.py, line 167, in __call__
(Object: render)
  File /usr/local/Zope220/lib/python/DocumentTemplate/DT_String.py, line 502, in 
__call__
(Object: render)
  File /usr/local/Zope220/lib/python/DocumentTemplate/DT_With.py, line 146, in render
(Object: ZopeTime)
  File /usr/local/Zope220/lib/python/DocumentTemplate/DT_Let.py, line 147, in render
(Object: tdate="'%s/%s/1' % (tyear,tmonth) "
  this_month="'%s/%s' % (tyear,tmonth) "
  ddate="_.DateTime(tdate)")
  File /usr/local/Zope220/lib/python/DocumentTemplate/DT_Let.py, line 147, in render
(Object: smeth="dateSearch.absolute_url()")
  File /usr/local/Zope220/lib/python/DocumentTemplate/DT_Util.py, line 337, in eval
(Object: 
renderMonth(ddate,smeth,bodyFgColor,bodyBgColor,headingFgColor,headingBgColor, 
'showyear' , moderated))
(Info: smeth)
  File string, line 0, in ?
  File /usr/local/Zope220/lib/python/Products/ExternalMethod/ExternalMethod.py, line 
270, in __call__
(Object: renderMonth)
(Info: ((DateTime('2000/07/01'), 
'http://www.ptang.com:8080/test/asdasd/dateSearch', '#00', '#ff',
'#ff', '#00', 'showyear', 'on'), {}, None))
  File /usr/local/Zope220/lib/python/Products/EventFolder/Extensions/rendercal.py, 
line 97, in renderMonth
(Object: Renderable)
AttributeError: (see above)


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




[Zope] ZCatalog Question

2000-08-15 Thread Jeff Sasmor

I have a product that has three CatalogAware Zclasses.  They
are indexed by the catalog correctly, but when I look at the
catalog's status tab, the number of objects for each index are
identical, even though the ZClasses themselves don't all have the same
properties.

Intuitively, this seems wrong. Or maybe my intuition is wrong.
It "makes more sense" to have differing number of objects
based on how many of each type of ZClass instance was indexed
and what the properties of each one was.

Anyone have any enlightenment (or is that Zen...) ?

Jeff Sasmor
[EMAIL PROTECTED]




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




[Zope] Can't change title of a common instance property sheet

2000-08-18 Thread Jeff Sasmor

I suppose this is some sort of lack in the Zope management UI, but
maybe someone else knows how to do this:

If you create a ZClass property sheet you can pick an ID and a title.

But you don't seem to be able to EDIT the title of the property
sheet ever again.

Is there some magic property sheet property name or
is there just no way to edit the title from the management 
interface?

The other bizzare thing is that you can export a property sheet,
but there seems no obvious way to import one anywhere.
Anyone have a clue on this?  What's it there for?

TIA


Jeff Sasmor
[EMAIL PROTECTED]



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




[Zope-dev] Interaction between new (2.2) ZCatalog and Renderable

2000-07-27 Thread Jeff Sasmor

Hi Zdevs,

I posted a message to [EMAIL PROTECTED] and then later
figured out the problem and now feel that the issue
belongs in Zope-Dev, so here it goes.

Submitted for your approval...


I think that I have found an interaction between changes made in
manage_addZCatalog (lib/python/Products/ZCatalog/ZCatalog/py)
and the Renderable ZClass product.  It's also possible that this
interaction will affect other things as well.

The new version of method 'manage_addZCatalog' has calls to str()
near its beginning.  The older (2.1.6) does not.  The Renderable
product overrides str to do its work.  This gets _very_ messy
when you initialize a catalog in the xxx_add dtml method for a
ZClass (that is, if you create an instance of the ZClass and the _add
method instantiates a ZCatalog instance.) and the ZClass itself is
renderable.

The manage_addZCatalog method ends up invoking the str() method
that's in the Renderable product.  This code attempts to publish(?) the
a dtml method named render (this is what it does by default).
In my case, the dtml method tries to query the created ZCatalog instance.

This does not work! since the ZC instance isn't actually created since the
_add method has not completed(?).
So the render dtml method borks with an attribute error.
Correct me if I have reverse-engineered these conclusions from looking
at the traceback and made a logic error

As one can see from the traceback attached to the end of this email,
the manage_add methof (I put X near where this mess begins)
warps into the render dtml method at line 112 of manage_addZCatalog,
which is the first str() (can be seen in the src).  This ends up in
an External Method, rendercal.py (last line of traceback).  If you were
to look there you'd se that it's doing a Catalog.searchResults().

**SO** it appears as if you cannot instantiate a ZCatalog in the _add
dtml method of a ZClass IFF the ZClass inherits from Renderable AND
if the render dtml method of the class (required by Renderable) uses
the ZCatalog.

This interaction may very well affect other products as well. But right now
my brain hurts.  Excuse me if someone else reported this, but I haven't
seen mention of it so far.

This should be easy to reproduce.  On a 2.2 system that has the Renderable
ZClass product installed, install EventFolder (it's on Zope.org, there's a .zexp
and some External Methods in the tgz file, just untar it in the Zope root and
copy the .zexp to the import dir and import it).  Try to create an
instance and you should get this error.

It seems to me the only solution is to recreate the class without the
Renderable inheritance.  Not a big deal to lose  But what other
schizoZopia is waiting in the future.


Jeff Sasmor
[EMAIL PROTECTED]


Traceback (innermost last):
  File /usr/local/Zope220/lib/python/ZPublisher/Publish.py, line 222, in publish_module
  File /usr/local/Zope220/lib/python/ZPublisher/Publish.py, line 187, in publish
  File /usr/local/Zope220/lib/python/Zope/__init__.py, line 221, in 
zpublisher_exception_hook
(Object: RoleManager)
  File /usr/local/Zope220/lib/python/ZPublisher/Publish.py, line 171, in publish
  File /usr/local/Zope220/lib/python/ZPublisher/mapply.py, line 160, in mapply
(Object: EventFolder_add)
  File /usr/local/Zope220/lib/python/ZPublisher/Publish.py, line 112, in call_object
(Object: EventFolder_add)
  File /usr/local/Zope220/lib/python/OFS/DTMLMethod.py, line 167, in __call__
(Object: EventFolder_add)
  File /usr/local/Zope220/lib/python/DocumentTemplate/DT_String.py, line 502, in 
__call__
(Object: EventFolder_add)
  File /usr/local/Zope220/lib/python/DocumentTemplate/DT_Let.py, line 147, in render
(Object: folder="EventFolder.createInObjectManager(REQUEST['id'], REQUEST)")
  File /usr/local/Zope220/lib/python/DocumentTemplate/DT_With.py, line 146, in render
(Object: folder)
  File /usr/local/Zope220/lib/python/DocumentTemplate/DT_Util.py, line 337, in eval
(Object: 
manage_addProduct['ZCatalog'].manage_addZCatalog(this(),'Catalog','EventCatalog' ))
(Info: this)
  File string, line 0, in ?
 it begins
  File /usr/local/Zope220/lib/python/Products/ZCatalog/ZCatalog.py, line 112, in 
manage_addZCatalog
how did we get here 
  File /usr/local/Zope220/lib/python/Products/Renderable/Renderable.py, line 17, in 
__str__
(Object: Renderable)
  File /usr/local/Zope220/lib/python/OFS/DTMLMethod.py, line 167, in __call__
(Object: render)
  File /usr/local/Zope220/lib/python/DocumentTemplate/DT_String.py, line 502, in 
__call__
(Object: render)
  File /usr/local/Zope220/lib/python/DocumentTemplate/DT_With.py, line 146, in render
(Object: ZopeTime)
  File /usr/local/Zope220/lib/python/DocumentTemplate/DT_Let.py, line 147, in render
(Object: tdate="'%s/%s/1' % (tyear,tmonth) "
  this_month="'%s/%s' % (tyear,tmonth) "
  ddate="_.DateTime(tdate)")
  File /usr/local/Zope2

[Zope-dev] Re: [Zope] CatalogAware

2001-06-26 Thread Jeff Sasmor


Subject: [Zope] CatalogAware


 CatalogAware has been blamed for alot of problems. Its three
 weaknesses I am aware of are:
snip 
 
 b. It uses URLs not paths, and so doesnt play right with
virtual hosting
 

*

I ran into this problem using VHMonster with my EventFolder product
and found a work-around, just for anyone who might be struggling with this

See http://www.netkook.com/Members/jeff/ef/faq/document_view#vhost

This article discusses how to use _vh_ with  VHM. 
(boy does that sound cryptic...)

Jeff Sasmor
[EMAIL PROTECTED]
www.netkook.com





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