[Zope] Re: How to do...[Rendering zpt on the fly]

2006-10-27 Thread Josef Meile

Hi Garito,

I saw in another thread you still need this. If I'm not wrong what you 
are pretending is to somehow render zpt on the fly. So, here is my idea:

I would like to write things like:

object.property = 'here/anotherproperty'
object.anotherproperty = 'Barcelona'

and ask it like:

print object.property -> 'Barcelona'

or

 -> 'Barcelona'

Is this possible?
I think you could perhaps create a new class to store the tal expression 
attributes, let's say you called it ExpressionAttribute. This class 
must be callable and be able to evaluate tal expressions. This is a 
small sketch of how I think it should look like:


from Products.PageTemplates.ZopeTemplate import ZopeTemplate

class ExpressionAttribute:
  #Here I also assume that you only enter the expressions
  #without html and the tal part, like: 'here/property'
  #Please also noticed that all sintax errors in your zpt
  #code must be catched somewhere
  def __init__(self, id, talExpr):
self.talExpr = '' % talExpr

#I'm not sure about this, but I think it will create a Template on
#the fly.
self.zpt = ZopePageTemplate(id, text = self.talExpr)

  #Note: I really don't know if you have to pass other parameters to
  #pt_render, ie: the container of your property. You will have to test
  #this.
  def __call__(self):
return self.zpt.pt_render()

Then, in the __init__ of your zope product you will need to do things 
like this:


class YourProd(...):
  def __init__(self,prop1,prop2,prop3,...):
#This is a normal property
self.prop1 = prop1

#This two are tal expression properties
self.prop2 = ExpressionAttribute(prop1)
self.prop3 = ExpressionAttribute(prop1)

Then, I guess you can call it as:
yourProdObj.prop3 or in tal: here/prop3

I'm not sure about what I wrote and if this is what you are looking for. 
I just hope it helps.


Regards
Josef
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] How to create a new TAL statement?

2006-10-27 Thread Tino Wildenhain

Garito schrieb:

Hi all!

As Aj and Chris advise my to forget the __getattr__ bussiness I try to 
solve the same question by other ways


Now I have a new question:

Can you point me to some help about how to create a new TAL statement?

I would like to create a tal:yanged (for example) statement to control 




would work :-) But what are you really trying to do and why?

Regards
Tino
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] How to create a new TAL statement?

2006-10-27 Thread Garito

Hi all!

As Aj and Chris advise my to forget the __getattr__ bussiness I try to 
solve the same question by other ways


Now I have a new question:

Can you point me to some help about how to create a new TAL statement?

I would like to create a tal:yanged (for example) statement to control 
how zope give to use some properties


Thanks!

--
Mis Cosas
http://blogs.sistes.net/Garito


___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Weird ZCatalog issue...

2006-10-27 Thread Chris Withers

Chris Withers wrote:

This ain't right, anyone else seen this or anything like it?

zopectl debug:
 >>> len(app.some_catalog.unrestrictedSearchResults())
2937144

 >>> i = 0
 >>> for b in app.some_catalog.unrestrictedSearchResults():
   i+=1

 >>> i
821165


Also:

>>> len(tuple(app.some_catalog.unrestrictedSearchResults())
821165

Why is the lazy list of brains getting its length wrong?

Chris

--
Simplistix - Content Management, Zope & Python Consulting
   - http://www.simplistix.co.uk
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Weird ZCatalog issue...

2006-10-27 Thread Chris Withers

This ain't right, anyone else seen this or anything like it?

zopectl debug:
>>> len(app.some_catalog.unrestrictedSearchResults())
2937144

>>> i = 0
>>> for b in app.some_catalog.unrestrictedSearchResults():
   i+=1

>>> i
821165

wtf?

(Zope 2.8)

Chris

--
Simplistix - Content Management, Zope & Python Consulting
   - http://www.simplistix.co.uk
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )