[Zope-dev] Interfaces in Zope 2.5, 2.7, and 3.x

2004-02-26 Thread Terry Hancock
I have a product that uses a component/interface model
internally.  I wrote this against the scarecrow Interface 
module in Zope 2.5.1.

However that module has limitations.  One particular one is
what I call a SubInterface -- which is a special case of 
Interface.Attribute (a subclass of it) that asserts that an
object contained within a parent interface implements a
particular interface.

So, for example, a SubInterface might say that in order to
conform to interface foo, the attribute bar must point to
an object which implements Mapping (e.g. a dictionary --
it doesn't have to *be* a dictionary, but it must act like one).

Anyway, I wrote my own interface module to do this,
extending the Interface module in Zope 2.5.1 (which lacks
this feature).  All of my code actually imports interface support
from my module instead of directly from Interface.

For unrelated reasons, though, I had to upgrade to Zope 2.7
(and someday, I imagine I'll want to consider moving to Zope 3.x).

My first attempt with Zope 2.7, though yields total breakage!

The Interface module has been extensively overhauled, method
names changed, etc. After giving up on just fixing a few name-
changes, which seems to be woefully inadequate, I decided to
try to lift the old Interface module -- but now Zope reads the 
__implements__ attribute and isn't happy if it isn't one of its own
interface objects!


Installing Narya ... Traceback (most recent call last):
  File ./testNaryaInterface.py, line 11, in ?
ZopeTestCase.installProduct('Narya')
  File /usr/local/narya/z2.7.0/lib/python/Testing/ZopeTestCase/ZopeLite.py, line 
119, in installProduct
get_folder_permissions(), raise_exc=1)
  File /usr/local/narya/z2.7.0/lib/python/OFS/Application.py, line 732, in 
install_product
initmethod(context)
  File /usr/local/narya/zope/Products/Narya/__init__.py, line 25, in initialize
icon='www/Icon/Thread.gif')
  File /usr/local/narya/z2.7.0/lib/python/App/ProductContext.py, line 176, in 
registerClass
interfaces = instancesOfObjectImplements(instance_class)
  File /usr/local/narya/z2.7.0/lib/python/Interface/Implements.py, line 120, in 
instancesOfObjectImplements
visitImplements(implements, klass, r.append, getInterface)
  File /usr/local/narya/z2.7.0/lib/python/Interface/Implements.py, line 90, in 
visitImplements
raise Exceptions.BadImplements(
Interface.Exceptions.BadImplements: __implements__ should be an interface or tuple,
not a instance pretending to be a Interface

(Seems I'm a pretender ;-) ).

Now, I can implement a new module based on the Zope 2.7 Interface -- but
a close look at that seems to show that it, too, is rather experimental (lots of
stubs, not-yet-implemented attributes, etc).  So I'm also sort of interested in
the interface module in Zope X3.

It appears that some new bells and whistles have been added to the
Interface module (e.g. what's a superinterface?).   Any chance, I'm
wondering if SubInterface is now redundant?

Also, is there a general guide to best practice of using / learning the
Interface module?  I note there are now interfaces defined for the interface
module (cool!), and it looks like some self-documentation has been
implemented.

The biggest problem (and this seems to be the usual problem with
self-documenting tools) is that there doesn't seem to be a start here
defined anywhere.  So you wind up starting somewhere in the middle and
wasting a lot of time trying to decipher the big picture from lots of details,
which is backwards. It'd be nicer if there was a README to get you started
on this, maybe define some jargon, etc.  It's really hard to infer what the
overall design concept is by only looking at these details -- in particular,
I want to know what was conceptually changed from the older Interface
module in 2.5.1.

This seems to also be a problem with combining Zope 3 and Zope 2
interfaces, as was suggested by a post on the Zope3 mailing list:

http://mail.zope.org/pipermail/zope3-dev/2003-December/009023.html
(and following -- note that __interfaces__ should read __implements__
in the original post).

Martijn's suggestion was to use an alternate name for the __implements__
attribute.  I suppost I could do that -- call mine __narya_interfaces__, but
that sounds ugly.  In particular, I don't really want my interfaces module
to actually *conflict* with Zope's.

I also note that the post from the Zope3 list suggests that I shouldn't
really be directly assigning __implements__, but using something called
implements().  Hmm. That's different too -- is there any good starting
place for understanding Zope3's interface module?

And how different are the Zope 2.7 / Zope X3 interface modules?  If I
re-write my module to conform to Zope 2.7, will I just have to do it
again?

Could I instead leap ahead and use the Zope X3 interface module in
Zope 2.7?

Also, since I'm posting to Zope3-dev as well -- what do you think of the
SubInterface concept?  Should I be contributing code 

[Zope-dev] server for new protocol?

2004-02-26 Thread Nikolay Kim
is there any way create server for new protocol without changing ZServer
module?



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


Re: [Zope-dev] server for new protocol?

2004-02-26 Thread Chris Withers
Nikolay Kim wrote:

is there any way create server for new protocol without changing ZServer
module?
Nope, have you looked at Twisted?

cheers,

Chris

--
Simplistix - Content Management, Zope  Python Consulting
   - http://www.simplistix.co.uk
___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


[Zope-dev] Explicit acquisition and object context

2004-02-26 Thread Garito



Hi
I have these function

def Propiedad(self, 
Name): 
"""Propiedad""" Obj = 
self Maestro = getattr(Obj, 
'Maestro', None) Paso = 
1 while Maestro is not 
None: Obj 
= 
self.restrictedTraverse(Maestro.contenido).__of__(self) 
Maestro = getattr(Obj, 'Maestro', 
None) Paso 
+= 1 if 
Paso == 15: break if hasattr(Obj, 
Name): 
return getattr(Obj, Name) return 
getattr(self, Name)

these code try to get the object Maestro, and 
recursively search the forMaestro's until is notfound
Widththese code I try to use an object called 
Maestro to make soft links

My problem istoacquirethe real 
context of self

If I add inmy product 
thesefunction:

def __bobo_traverse__(self, Request, 
Name): return 
self.Propiedad(Name)

ZMI show me the soft link object and not the real 
self

Has anyone idea to help me, please?

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


Re: [Zope-dev] server for new protocol?

2004-02-26 Thread Jens Vagelpohl
write server itself not very hard, i simply don't want patch
ZServer/components.xml
is there any way don't touch Zserver?
probably not.

jens



smime.p7s
Description: S/MIME cryptographic signature
___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] server for new protocol?

2004-02-26 Thread Nikolay Kim

 You must implement the server for the new protocol
 and you will need some integration code.
 
 You have lots of examples at hand.

write server itself not very hard, i simply don't want patch 
ZServer/components.xml 
is there any way don't touch Zserver?




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


Re: [Zope-dev] server for new protocol?

2004-02-26 Thread Dieter Maurer
Nikolay Kim wrote at 2004-2-26 17:50 +0600:
is there any way create server for new protocol without changing ZServer
module?

You must implement the server for the new protocol
and you will need some integration code.

You have lots of examples at hand.

-- 
Dieter

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


[Zope-dev] Maybe Corrupted ZCatalog but ...

2004-02-26 Thread Eric Brun


Hi,

When we do a search on a ZCatalog we have the message below. We work with Zope 2.6.2 
and our Catalog have more than 200 000 objects referenced.

We think our catalog is corrupted but we would correct it.

Anybody have the same problem ?

An idea for fix it ?

Thank 

Eric Brun
 
Type d'erreur : KeyError 
Valeur : 182975046 


Trace : 
Traceback (innermost last): 

Module ZPublisher.Publish, line 98, in publish 
Module ZPublisher.mapply, line 88, in mapply 
Module ZPublisher.Publish, line 39, in call_object 
Module App.special_dtml, line 61, in __call__ 
Module DocumentTemplate.DT_String, line 474, in __call__ 
Module DocumentTemplate.DT_Let, line 76, in render 
Module DocumentTemplate.DT_In, line 465, in renderwb 
Module DocumentTemplate.DT_In, line 749, in sort_sequence 
Module Products.ZCatalog.Lazy, line 155, in __getitem__ 
Module Products.ZCatalog.Catalog, line 149, in __getitem__ 
KeyError: 182975046 

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