Re: [Zope3-Users] Problem with macro

2007-02-26 Thread Florian Lindner
Am Sonntag, 25. Februar 2007 15:03 schrieb Marius Gedminas:
 On Sun, Feb 25, 2007 at 02:02:43PM +0100, Florian Lindner wrote:
  I have a simple problem. A template:
 
  html metal:use-macro=views/standard_macros/view
  i18n:domain=xgm.de/Blog body
  metal:block metal:define-macro=Blog
  metal:block metal:fill-slot=body
h1 tal:content=context/title /
div tal:replace=context/description /
   [...]
/div
 
  /metal:block
  /metal:block
/body
  /html
 
  That is registered as view.html.

 How?  browser:page name=view.html template=foo.pt / ?

  Now I want to use the macro in another page:
 
  div metal:use-macro=context/Blog/@@view.html/Blog /
 
  (tried different variations)

 Ah, but did you try

   metal:use-macro=context/Blog/@@view.html/index/macros/Blog /

No, have not tried it yet.

But
div metal:use-macro=context/Blog/@@view.html/index/macros/Blog /

gives an error too:

  File /home/florian/Zope3/src/zope/tales/expressions.py, line 124, in _eval
ob = self._traverser(ob, element, econtext)
  File /home/florian/Zope3/src/zope/app/pagetemplate/engine.py, line 65, in 
__call__
object = object[name]
KeyError: 'Blog'

Blog in a object contained by the xgm object. Blog is object that has the 
view.html registered.

Thanks,

Florian
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Question about IOrderedContainer interface

2007-02-26 Thread Thierry Florac

  Hi,

I have a little question about the IOrderedContainer interface.

Actually, this interface is derived from IContainer, and only contains
a single method, updateOrder() which is an updating method.

When I create a subclass of OrderedContainer for which I'd like only a
limited set of roles to have reordering permission, I'd like to do
something like :

  require
interface=IReadContainer
permission=zope.View /
  require
interface=IOrderedContainer
permission=zope.ManageContent /

But this doesn't work, because of a ConfigurationConflictError.

So I can see only three ways to make this working :
 - make IOrderedContainer derived from IWriteContainer instead of
IContainer (what I've done until now !)
 - make IOrderedContainer a separate interface, so that I could do
something like :

  require
interface=IReadContainer
permission=zope.View /
  require
interface=IWriteContainer
permission=zope.ManageContent /
  require
interface=IOrderedContainer
permission=zope.ManageContent /

 - wait for someone else to give me another solution, which wouldn't
need to modify Zope source code :-)

Thanks for any help or advise,

  Thierry Florac
-- 
  Chef de projet intranet/internet
  Office National des Forêts - Département Informatique
  2, Avenue de Saint-Mandé
  75570 PARIS Cedex 12
  Mél : [EMAIL PROTECTED]
  Tél. : +33 01.40.19.59.64
  Fax. : +33 01.40.19.59.85

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Question about IOrderedContainer interface

2007-02-26 Thread Martin Aspeli



Thierry FLORAC wrote:
 
 
   Hi,
 
 I have a little question about the IOrderedContainer interface.
 
 Actually, this interface is derived from IContainer, and only contains
 a single method, updateOrder() which is an updating method.
 

That's pretty silly, it should probably be IWriteContainer :-(

Note that if anyone's fixing OrderedContainer, the default implementation
isn't terribly optimal as well - it uses PersistentMappings and not BTrees.
I've got impementations where I wanted to reuse it but use a BTree, and I've
done things like this:
http://svn.plone.org/svn/plone/plone.portlets/trunk/plone/portlets/storage.py

Martin
-- 
View this message in context: 
http://www.nabble.com/Question-about-IOrderedContainer-interface-tf3293814.html#a9162073
Sent from the Zope3 - users mailing list archive at Nabble.com.

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Problem with macro

2007-02-26 Thread Marius Gedminas
On Mon, Feb 26, 2007 at 02:40:13PM +0100, Florian Lindner wrote:
 Am Sonntag, 25. Februar 2007 15:03 schrieb Marius Gedminas:
  On Sun, Feb 25, 2007 at 02:02:43PM +0100, Florian Lindner wrote:
   I have a simple problem. A template:
  
   html metal:use-macro=views/standard_macros/view
   i18n:domain=xgm.de/Blog body
   metal:block metal:define-macro=Blog
...
   That is registered as view.html.
  
   Now I want to use the macro in another page:
  
   div metal:use-macro=context/Blog/@@view.html/Blog /
  
   (tried different variations)
 
  Ah, but did you try
 
metal:use-macro=context/Blog/@@view.html/index/macros/Blog /
 
 No, have not tried it yet.
 
 But
 div metal:use-macro=context/Blog/@@view.html/index/macros/Blog /
 
 gives an error too:
 
   File /home/florian/Zope3/src/zope/tales/expressions.py, line 124, in _eval
 ob = self._traverser(ob, element, econtext)
   File /home/florian/Zope3/src/zope/app/pagetemplate/engine.py, line 65, in 
 __call__
 object = object[name]
 KeyError: 'Blog'
 
 Blog in a object contained by the xgm object. Blog is object that has the 
 view.html registered.

Do you know which 'Blog' is the one that gives you the error?  The macro
or the item on 'context'?

It could very well be that your define-macro doesn't take effect, because it is
inside a use-macro and outside any fill-slot.

Marius Gedminas
-- 
Lost packet, 42 bytes, last seen on a saturated OC3, reward $$$.
-- Eric^2 on Slashdot


signature.asc
Description: Digital signature
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Question about IOrderedContainer interface

2007-02-26 Thread Marius Gedminas
On Mon, Feb 26, 2007 at 05:28:12PM +0100, Thierry Florac wrote:
 I have a little question about the IOrderedContainer interface.
 
 Actually, this interface is derived from IContainer, and only contains
 a single method, updateOrder() which is an updating method.
 
 When I create a subclass of OrderedContainer for which I'd like only a
 limited set of roles to have reordering permission,
...
 So I can see only three ways to make this working :
...
  - wait for someone else to give me another solution, which wouldn't
 need to modify Zope source code :-)

require
  interface=IReadContainer
  permission=zope.View /
require
  interface=IWriteContainer
  permission=zope.ManageContent /
require
  attributes=updateOrder
  permission=zope.ManageContent /

Marius Gedminas
-- 
There's an old story about the person who wished his computer were as easy to
use as his telephone. That wish has come true, since I no longer know how to
use my telephone.
-- Bjarne Stroustrup


signature.asc
Description: Digital signature
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] External content with ZPT

2007-02-26 Thread Sam Young

Hello,

Is there a simple way to use ZPT to include external content?
Something that resembles Apache SSI--I was hoping there is something
along the lines of tal:include=addr but it does not appear to be
quite this easy. The content in question is a script that I'd rather
not rewrite.

Search has turned up wrapping the functionality in python code. Can I
do this without a urllib2 wrapper?


Thank you,
Sam
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Problem with macro

2007-02-26 Thread Florian Lindner
Am Montag, 26. Februar 2007 18:14 schrieb Marius Gedminas:
 On Mon, Feb 26, 2007 at 02:40:13PM +0100, Florian Lindner wrote:
  Am Sonntag, 25. Februar 2007 15:03 schrieb Marius Gedminas:
   On Sun, Feb 25, 2007 at 02:02:43PM +0100, Florian Lindner wrote:
I have a simple problem. A template:
   
html metal:use-macro=views/standard_macros/view
i18n:domain=xgm.de/Blog body
metal:block metal:define-macro=Blog

 ...

That is registered as view.html.
   
Now I want to use the macro in another page:
   
div metal:use-macro=context/Blog/@@view.html/Blog /
   
(tried different variations)
  
   Ah, but did you try
  
 metal:use-macro=context/Blog/@@view.html/index/macros/Blog /
 
  No, have not tried it yet.
 
  But
  div metal:use-macro=context/Blog/@@view.html/index/macros/Blog /
 
  gives an error too:
 
File /home/florian/Zope3/src/zope/tales/expressions.py, line 124, in
  _eval ob = self._traverser(ob, element, econtext)
File /home/florian/Zope3/src/zope/app/pagetemplate/engine.py, line
  65, in __call__
  object = object[name]
  KeyError: 'Blog'
 
  Blog in a object contained by the xgm object. Blog is object that has the
  view.html registered.

 Do you know which 'Blog' is the one that gives you the error?  The macro
 or the item on 'context'?

 It could very well be that your define-macro doesn't take effect, because
 it is inside a use-macro and outside any fill-slot.

It's probably that. I've changed the Blog macro to BlogMacro und now it 
complains abobut BlogMacro being missing.
How would you do that? (for explanation what I want see my original posting)

Thanks,

Florian
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] External content with ZPT

2007-02-26 Thread Maciej Wisniowski

 Is there a simple way to use ZPT to include external content?
 Something that resembles Apache SSI--I was hoping there is something
 along the lines of tal:include=addr but it does not appear to be
 quite this easy. The content in question is a script that I'd rather
 not rewrite.
The 'script' you're talking about returns HTML?? Is this a web page?
web service? file? It is available under URL? The  content is script
itself or something that this script returns?

Not sure if I understand correctly but if you want to paste some html
from url, then AFAIK ZPT has no statement (shortcut) for this kind of
things.

 Search has turned up wrapping the functionality in python code. Can I
 do this without a urllib2 wrapper?
Depends what 'external' is for you... In general you may use different
protocol, something with xml-rpc, json and this stuff. What is wrong
with urllib2? On the other hand you may just use iframes or some
javascripts/ajax things on the client side.

-- 
Maciej Wisniowski


___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] External content with ZPT

2007-02-26 Thread Marius Gedminas
On Mon, Feb 26, 2007 at 01:08:17PM -0500, Sam Young wrote:
 Is there a simple way to use ZPT to include external content?

Assuming that your ZPT is a template used for a view,

  span tal:replace=structure view/whatever /

where your view class has a method called 'whatever' that
reads/downloads/acquires by whatever means necessary the external
content you want.

 Something that resembles Apache SSI--I was hoping there is something
 along the lines of tal:include=addr but it does not appear to be
 quite this easy. The content in question is a script that I'd rather
 not rewrite.

There is no direct way to access files or URLs within ZPTs.

Marius Gedminas
-- 
To be intoxicated is to feel sophisticated but not be able to say it.


signature.asc
Description: Digital signature
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Re: NotYet error when creating content during container creation

2007-02-26 Thread Tom Dossis
 
 Yes, this is what I'd recommend. A handler for an ObjectAddedEvent will
 always see the object already as part of the object hierarchy (which is,
 after all, what ObjectAddedEvent is about).
 

I found myself doing this quite often.
I use a decorator to make the code read nicer..


class MyContainer(Container):

@callafteradd
def setup(self)
self['subobject'] = SomeObject()
self['subobject2'] = AnotherObject()
...


def callafteradd(method):
Decorator which invokes a method after an instance
has been added to a container.

caller_locals = sys._getframe(1).f_locals
if caller_locals.get('__callafteradd__') is None:
caller_locals['__callafteradd__'] = ()
caller_locals['__callafteradd__'] += (method,)
return method


@component.adapter(IObjectAddedEvent)
def ObjectAddedHandler(event):
callafteradd_methods = getattr(ob, '__callafteradd__', ())
for f in callafteradd_methods:
f(ob)

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Cannot view the instances after I refresh the product in ZMI

2007-02-26 Thread Alex Cheng

Hello,

I have modified my product code and click refresh in ZMI to update the
product. Unfortunately when I view its instance in zope. The error message
is follows:

*Error Type: TypeError*
*Error Value: 'NoneType' object is not callable

Could you help me?

Thanks.
*--
powered by python
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users