[Zope3-Users] Re: How to make content object return a view?

2006-05-26 Thread Philipp von Weitershausen
David Johnson wrote:
 I have a content object, that I want to return a view.  How is this
 done?

It usually isn't.

 This situation seems to come up frequently for me.  What do you
 do?

Content objects are usually dull. The only thing they do is store data.
If you're using ZODB persistency, then a content object can be two lines
of code:

class MyContent(persistent.Persistent):
pass

In particular, content objects often have no methods and they definitely
don't deal with the request. This is left to views. So, somethign in
your app needs to deal with a request, write a view.

 In this case, the content object is a fax.  The fax will include browser
 views as part of it's body.

That seems like a backward approach. The fax body will probably be
rendered using other views. The body rendering view should pull in other
views. Not the fax object itself.

 I tried zapi.getView(), but this has been deprecated, and I don't quite
 understand the best approach.

Don't mix storage and presentation :).

Philipp

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


[Zope3-Users] getUtility outside of the zope.app

2006-05-26 Thread David Pratt
Hi. For the use of interfaces outside of zope.app, does getUtility have 
any value? Many thanks.


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


Re: [Zope3-Users] Re: How to make content object return a view?

2006-05-26 Thread David Johnson

Thanks!  You are right.  After a re-read of your book last night, I
think my problem is that I have not understood or dealt with adapters as
of yet.  It seems that is the proper solution to expressing content in
the way I intended and seems to solve all my problems in this area.

--
David
  





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


Re: [Zope3-Users] How to make content object return a view?

2006-05-26 Thread Benji York

TAHARA Yusei wrote:

You need to use zapi.getMultiAdapter.
(this is a alias for zope.component.getMultiAdapter)


I suggest not using zapi aliases, use the canonical name for things 
instead.  There is a growing dislike for zapi, and I suspect it will be 
deprecated in the future.

--
Benji York
Senior Software Engineer
Zope Corporation
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Re: getUtility outside of the zope.app

2006-05-26 Thread Philipp von Weitershausen
David Pratt wrote:
 Hi. For the use of interfaces outside of zope.app, does getUtility have
 any value? Many thanks.

I don't understand this question. getUtility finds utilities that have
been registered somewhere. It finds them by interface and optionally a
name. Where this interface comes from doesn't matter at all.

Philipp

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


Re: [Zope3-Users] Reference to a COM object (or other external resource) in a Zope object

2006-05-26 Thread Alek Kowalczyk

Achim Domma napisaƂ(a):

[EMAIL PROTECTED] wrote:

I am creating a kind of Zope proxy to a 3rd party COM object (I'm 
accessing it using Pywin32 facilities). I have to store a reference 
to this object somewhere in my Zope object.
But, for obvious reasons, this COM object cannot be serialized so I 
cannot put it in any attribute of my Zope object. On the other side, 
initialisation of the object on each request is too timecost-consuming. 


With my still somewhat limited Zope knowledge, I would say it sounds 
like you should have a look at utilities.


regards,
Achim


Do you mean: Global Utilities?
Then I have a question: global utility is not persistent. But can the 
G.U. create the object, return it to the local object (some container), 
and local object inserts it somewhere into it?
In other words: can this global utility serve as factory of objects 
which then are added to a container and persisted?
Sorry for such a naive question... I still cannot feel fully Zope's 
persistence mechanism...





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


[Zope3-Users] Re: getUtility outside of the zope.app

2006-05-26 Thread David Pratt
Hi Philip. Sorry for the oblique question. I am using zope interfaces in 
a project outside of zope and looking at how I might use some of other 
bits of zope's functionality. Many thanks.


Regards,
David

Philipp von Weitershausen wrote:

 David Pratt wrote:
 Hi. For the use of interfaces outside of zope.app, does getUtility have
 any value? Many thanks.

 I don't understand this question. getUtility finds utilities that have
 been registered somewhere. It finds them by interface and optionally a
 name. Where this interface comes from doesn't matter at all.

 Philipp

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


Re: [Zope3-Users] There isn't enough context to get URL information.

2006-05-26 Thread Ron Bickers
On Thu May 25 2006 05:50, Achim Domma wrote:

 I try to figure out how to make attributes holding content objects
 accessible via the browser.

I'm working on the same thing, but I don't know how to make a view for the 
contents of the containers in the ZMI.

I have an Item object with 'prices' and 'options' attributes that are both 
BTreeContainer.  I'd like to have two menu items for Item (named Prices and 
Options) and have each display the contents of the respective attribute.  
How can I do that?

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


Re: [Zope3-Users] How do I get formlib to play nice with NameChooser

2006-05-26 Thread mats.nordgren
Never mind it was a user error on my part.

I was stuffing the data variables in the create function into the context not
the object being created.  Oooops :)

On Fri, 26 May 2006 13:02:42 -0500, mats.nordgren wrote
 I've been trying to use NameChooser with formlibs AddForm and it 
 always tells me An empty name was provided. Names cannot be empty.
 
 I suspect it has to do with set_before_add as my object comes in to the
 NameChooser without data.  Problem is that you define formlib forms 
 with page and set_before_add is in addform.
 
 Anyone got this to work?
 
 Sincerely,
 
 Mats
 ___
 Zope3-users mailing list
 Zope3-users@zope.org
 http://mail.zope.org/mailman/listinfo/zope3-users

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


[Zope3-Users] MultiCheckBoxWidget and formlib

2006-05-26 Thread Mats Nordgren
Could anyone give me a hint on setting up a MultiCheckBoxWidget with
formlib?


This is what I got:

class IMySchema(Interface):
  multichoice = Set(
title=_('Pick one or many'),
value_type = Choice(values=['one', 'two', 'three']))

class MyEditForm(form.EditForm):
  form_fields = form.Fields(IMySchema)
  form_fields['multichoice'].custom_widget = 


What in the world do I do to get this to work?

Any help greatly appreciated.

Sincerely,

Mats

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


Re: [Zope3-Users] MultiCheckBoxWidget and formlib

2006-05-26 Thread Tom Dossis
Mats Nordgren wrote:
 Could anyone give me a hint on setting up a MultiCheckBoxWidget with
 formlib?
 
 
 This is what I got:
 
 class IMySchema(Interface):
   multichoice = Set(
 title=_('Pick one or many'),
 value_type = Choice(values=['one', 'two', 'three']))
 
 class MyEditForm(form.EditForm):
   form_fields = form.Fields(IMySchema)
   form_fields['multichoice'].custom_widget = 
 
 
 What in the world do I do to get this to work?

I've done something similar along the lines of...

class IMySchema(Interface):
  multichoice = Set(
title=_('Pick one or many'),
value_type=SimpleVocabulary.fromItems([
  (_(One), one),
  (_(Two), two),
  (_(Three, three),
  ])
Maybe try zope.app.form.browser.MultiSelectWidget ..
It requires 3 args in its constructor which you can wrap for formlib, e.g.

class MyMultiSelectWidget(MultiSelectWidget):

  def __init__(self, field, request):
super(MyMultiSelectWidget, self).__init__(
  field, field.value_type.vocabulary, request)

Then ..

  form_fields['multichoice'].custom_widget=MyMultiSelectWidget

You could also look at the alternative widget..

  zope.app.form.browser.itemswidgets.MultiCheckBoxWidget



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