AW: [Zope3-dev] Re: AW: Re: edit view of a object unknown?

Roger ineichen dev at projekt01.ch
Sat Mar 6 19:43:30 EST 2004


> jim wrote:
> > Jim, if you're lurking :-) could you fill in some of the 
> pieces here? 
> > We
> > had briefly covered some of the factory/initialization issues 
> > surrounding the add form, but I've already forgotten the details :-o
> 
> I don't think they are relevent.
> 
> Roger, I can't really tell what you want to do.  It seems as 
> though you want to be able to create objects from Python 
> without knowing anything about their constructors.  This 
> really only works, in general if the constructors take no arguments.

Yes. But if somebody write a product this implementation is
like a chief implementation and other write just a second
implementation, because they don't whant to use the original.
And in this way they have to relay on the contructors of them.


I know that's sounds not very well, but see the example below
and specialy my fear to get components with a lot of dependence
to other components.
  
> 
> Roger, could you explain what you are trying to do?

I try:
First I describe a uscase:
Let's say we whant use the Object(fields) for to store a class instance
as a child of a content class. This child is also a content class.
Both classes have add and edit views. 
Let's call they question and priority class.

example:
class IQuestion
----
class IQuestion(Interface):
    """aDoc.."""
    
    priorities = Tuple(title=_(u'...'),
        value_type=Object(IPriority, title=u'...'))
---

class Question
---
class Question(Persistent, object):
    """aDoc.."""
    priorities = property(get_priorities, set_priorities, None, 'list of
priorities') 
---

class QuestionEditView
--- 
priority_w = CustomWidgetFactory(ObjectWidget, Priority)
priorities_w = CustomWidgetFactory(SequenceWidget, subwidget=priority_w)

class QuestionEditView(EditView):
    __used_for__ = IQuestion

    priorities_widget = priorities_w
---


In this case we can't add a question in a python method,
because we don't know which class is used for to add in the 
property priorities as the value_type. In the example above
declared with the interface IPriority.

Let's do a little bit more and write a import/export 
tool which is importing Questions to the Zope3 server
from a xml file. That's not possible with this information. 
You have to hard code Priority class in the import/export 
tool. Here we should call Zope and ask which content object 
implements IPriority. But this could be more then one 
implementation on this server. ???


I think, this system configuration logic which should be
defined in zcml. 
For me it's not a problem to implement and import the right
Priority class if I whould add a Question in a python method. 
But I whould write more general products and let other
people decide if the whould implement another Priority class.
We declare just the interface of IPriority and implement a
sample Priotity class.

I think if we don't solve this we whant see many good 
content objects/classes developed by other developer,
but they will have realy hardcoded relation to other
content classes if the use Object(fields). At least we
have to write new edit views with the own CustomWidgetFactory.
And also they have to implement a own import/export tool for 
to create the right Priority class in the Question object.

I'm shure if the scripters come to zope we get a lot of nice
products and the widget framework is really powerfull. 
They will do creazy things with different content classes in
a custom widget or in widget wizzards. But you don't have access
to this information from python methods.

A solution could be;
----------------
Define a interface 
Define a class implementation
Define a edit and add factory
Define add/edit views (which use the add or edit factory)
----------------
The add and view factories should be accessible from python
and TTW views. This way you can add or edit the object on each 
different implemenetation in a general way.

I hoppe I'm not totally wrong with this.

> Jim
> 
> -- 
> Jim Fulton           mailto:jim at zope.com       Python Powered!
> CTO                  (540) 361-1714            http://www.python.org
> Zope Corporation     http://www.zope.com       http://www.zope.org
> 
> 
> _______________________________________________
> Zope3-dev mailing list
> Zope3-dev at zope.org http://mail.zope.org/mailman/listinfo/zope3-dev
> 




More information about the Zope3-dev mailing list