Re: [Zope3-Users] zope.schema.Object and custom widgets in formlib

2006-05-24 Thread Frank Burkhardt
Hi,

On Tue, May 23, 2006 at 11:21:54AM -0500, Jachin Rupe wrote:
> 
> On May 23, 2006, at 5:33 AM, Frank Burkhardt wrote:
> 
> [snip]
> 
> >
> >>
> >>
> >>

[snip]

Try removing the -statement for the Object()s.

Regards,

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


Re: [Zope3-Users] zope.schema.Object and custom widgets in formlib

2006-05-23 Thread Jachin Rupe


On May 23, 2006, at 5:33 AM, Frank Burkhardt wrote:

[snip]









[snip]

I bet '.interfaces.IABookEntry' doesn't cover the 'street'  
attribut. You should better use

'.interfaces.IStreetAddress' for your Object()-object.


[snip]

I'm not exactly sure what your getting at here, but I made a guess.   
I also found another error in my "widgets" package.  For some strange  
reason I was making an ObjectWIdget for entry.ABookEntry when I  
believe I should have been making one for entry.StreetAddress


Anyway I made some changes and I could add "entry.ABookEntry"s but  
editing them resulted in this error:  UnpickleableError: Cannot  
pickle  objects


There were a couple of other posts to the zope3-users message board  
about that problem and I read them.  The one that help was this one:


http://www.mail-archive.com/zope3-users@zope.org/msg00890.html

Now as far as I can tell everything is working.  I'll include all my  
code at the bottom in case anyone else is following along.  The  
changes from my last version are in entry.py, widges.py and  
configure.zcml


I'm working on a larger address book example, if anyone has any  
comments on how I'm going about this please share.


Also I'm still a little fuzzy on how  
objectwidgetdispatcher.ObjectInputWidget works.  I would really  
appreciate a little more explanation.


thanks

-jachin



http://namespaces.zope.org/zope";
xmlns:browser="http://namespaces.zope.org/browser";>



























# -=entry.py=-

from zope.security.proxy import removeSecurityProxy
from zope.interface import implements
from persistent import Persistent
from interfaces import IStreetAddress
from interfaces import IABookEntry


class StreetAddress(Persistent):
"""The Street Address object."""
implements(IStreetAddress)
street = u""


class ABookEntry(Persistent):
"""The Address Book Entry object."""
implements(IABookEntry)
firstName = u""

def get_streetAddress(self):
return self._streetAddress

def set_streetAddress(self, streetAddress):
self._streetAddress = removeSecurityProxy(streetAddress)

streetAddress = property(get_streetAddress, set_streetAddress, None)


# -=interfaces.py=-

from zope.interface import Interface
from zope.schema import TextLine, Object

class IStreetAddress(Interface):
"""A street address"""

street = TextLine(
title=u"street",
description=u"",
required=False)


class IABookEntry(Interface):
"""An address book entry"""
streetAddress = Object(
schema=IStreetAddress,
title=u"Street Address",
description=u"",
required=False)

firstName = TextLine(
title=u"First Name",
description=u"",
required=False)


# -=objectwidgetdispatcher.py=-

from zope.app import zapi
from zope.interface import implements

from zope.app.form.interfaces import IInputWidget

def ObjectInputWidget(context, request):
"""Dispatch widget for Object schema field to a widget that is
registered for (IObject, schema, IBrowserRequest) where schema
is the schema of the object."""

class Obj(object):
implements(context.schema)

widget=zapi.getMultiAdapter((context, Obj(), request), IInputWidget)
return widget


# -=widgets.py=-

from zope.app.form.browser import ObjectWidget
from entry import StreetAddress

def StreetAddressWidget(context, obj, request):
return ObjectWidget(context, request, StreetAddress)

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


Re: [Zope3-Users] zope.schema.Object and custom widgets in formlib

2006-05-23 Thread Frank Burkhardt
Hi,

On Mon, May 22, 2006 at 09:59:09AM -0500, Jachin Rupe wrote:

[snip]

> I am getting a "ForbiddenAttribute" error.  I can run the addform with out 
> any errors but if I editform the "street" 
> field is blank (even though I added some text to it when I added it).  Then 
> if I makes some changes to the fields and 
> try to save my changes I get one of these:

[snip]

>   
>   
>   

[snip]

I bet '.interfaces.IABookEntry' doesn't cover the 'street' attribut. You should 
better use
'.interfaces.IStreetAddress' for your Object()-object.

Regards,

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


Re: [Zope3-Users] zope.schema.Object and custom widgets in formlib

2006-05-22 Thread Jachin Rupe


On May 22, 2006, at 2:19 AM, Frank Burkhardt wrote:

[snip]



Yes, I'm using Zope-SVN but the ObjectWidget-Code was written for  
ZopeX3.
I can't see the Dispatcher-Widget. Are you sure, you implemented  
and registered it

as described in Part "Vorarbeit(Preparation)" of the Howto?


Ah... I was thinking that part was some sort of generic example.   
Alright, I added that code and now my component  
"ComponentLookupError" cleared up.  However I'm now having another  
problem.  When I add a new


I am getting a "ForbiddenAttribute" error.  I can run the addform  
with out any errors but if I editform the "street" field is blank  
(even though I added some text to it when I added it).  Then if I  
makes some changes to the fields and try to save my changes I get one  
of these:


ForbiddenAttribute: ('street', at 0x405d3b0>)


Anytime I've seen this in the past it means there's a permission  
problem.  So I played with the security setting in configure.zcml  
some but I could not find anything that helped.


Judging from the error message it looks like it's trying to look up  
the security settings for "street" in entry.ABookEntry.  Which would  
kinda makes sense, and then it should be looking instead in  
entry.StreetAddress, but I don't know how to make it do that.  I'll  
include my code again too.


thanks

-jachin




http://namespaces.zope.org/zope";
xmlns:browser="http://namespaces.zope.org/browser";>

























# -===interfaces.py===-

from zope.interface import Interface
from zope.schema import TextLine, Object

class IStreetAddress(Interface):
"""A street address"""

street = TextLine(
title=u"street",
description=u"",
required=False)


class IABookEntry(Interface):
"""An address book entry"""
streetAddress = Object(
schema=IStreetAddress,
title=u"Street Address",
description=u"",
required=False)

firstName = TextLine(
title=u"First Name",
description=u"",
required=False)

# -===entry.py===-

from zope.interface import implements
from persistent import Persistent
from interfaces import IStreetAddress
from interfaces import IABookEntry


class StreetAddress(Persistent):
"""The Street Address object."""
implements(IStreetAddress)


class ABookEntry(Persistent):
"""The Address Book Entry object."""
implements(IABookEntry)

# -===widgets.py===-

from zope.app.form.browser import ObjectWidget
from entry import ABookEntry

def ABookEntryWidget(context,obj,request):
return ObjectWidget(context, request, ABookEntry)

# -===objectwidgetdispatcher.py===-

from zope.app import zapi
from zope.interface import implements

from zope.app.form.interfaces import IInputWidget

def ObjectInputWidget(context, request):
"""Dispatch widget for Object schema field to a widget that is
registered for (IObject, schema, IBrowserRequest) where schema
is the schema of the object."""

class Obj(object):
implements(context.schema)

widget=zapi.getMultiAdapter((context, Obj(), request), IInputWidget)
return widget
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] zope.schema.Object and custom widgets in formlib

2006-05-22 Thread Joseph Method

I have to say, I had a lot of frustration this weekend with
inscrutable errors using the svn that disappeared when I went back to
3.3beta1. Things like views not registering.

On 5/22/06, Frank Burkhardt <[EMAIL PROTECTED]> wrote:

Hi,

On Fri, May 19, 2006 at 02:21:23PM -0500, Jachin Rupe wrote:

[snip]

> I'm still getting a "ComponentLookupError".  I'll just include the example 
I'm trying to make work
> at the bottom, it's pretty short.  I'm beginning to think there may be 
something in your
> explication that I need to understand.
>
> Also, from looking at your example I'm guessing your using the SVN version of 
zope3, is that true
> and do you happen to know if that would make a difference?  I'm currently 
using Zope-3.2.1.

Yes, I'm using Zope-SVN but the ObjectWidget-Code was written for ZopeX3.
I can't see the Dispatcher-Widget. Are you sure, you implemented and registered 
it
as described in Part "Vorarbeit(Preparation)" of the Howto?

Regards,

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




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


Re: [Zope3-Users] zope.schema.Object and custom widgets in formlib

2006-05-22 Thread Frank Burkhardt
Hi,

On Fri, May 19, 2006 at 02:21:23PM -0500, Jachin Rupe wrote:

[snip]

> I'm still getting a "ComponentLookupError".  I'll just include the example 
> I'm trying to make work 
> at the bottom, it's pretty short.  I'm beginning to think there may be 
> something in your 
> explication that I need to understand.
> 
> Also, from looking at your example I'm guessing your using the SVN version of 
> zope3, is that true 
> and do you happen to know if that would make a difference?  I'm currently 
> using Zope-3.2.1.

Yes, I'm using Zope-SVN but the ObjectWidget-Code was written for ZopeX3.
I can't see the Dispatcher-Widget. Are you sure, you implemented and registered 
it
as described in Part "Vorarbeit(Preparation)" of the Howto?

Regards,

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


Re: [Zope3-Users] zope.schema.Object and custom widgets in formlib

2006-05-19 Thread Jachin Rupe


[snip]

I still haven't gotten it working yet though.  I'm going to keep  
trying to figure out what

the problem is, I think I see what your basic strategy is.

However there are a few error I found in your example you may be  
interested in fixing:


in your interfaces.py file you probably want the IPhoneBookEntry  
interface to look like

this:


[...]

Sorry for the Typo - corrected it. But the whole concept works for  
me - I'm

using schema.Object, too.

Maybe I can help - what's the problem?



I'm still getting a "ComponentLookupError".  I'll just include the  
example I'm trying to make work at the bottom, it's pretty short.   
I'm beginning to think there may be something in your explication  
that I need to understand.


Also, from looking at your example I'm guessing your using the SVN  
version of zope3, is that true and do you happen to know if that  
would make a difference?  I'm currently using Zope-3.2.1.


thanks

-jachin

# -=interfaces.py=-

from zope.interface import Interface
from zope.schema import TextLine, Object

class IStreetAddress(Interface):
"""A street address"""

street = TextLine(
title=u"street",
description=u"",
required=False)


class IABookEntry(Interface):
"""An address book entry"""
streetAddress = Object(
schema=IStreetAddress,
title=u"Street Address",
description=u"",
required=False)

firstName = TextLine(
title=u"First Name",
description=u"",
required=False)



# -=entry.py=-

from zope.interface import implements
from persistent import Persistent
from interfaces import IStreetAddress
from interfaces import IABookEntry


class StreetAddress(Persistent):
"""The Street Address object."""
implements(IStreetAddress)


class ABookEntry(Persistent):
"""The Address Book Entry object."""
implements(IABookEntry)

from zope.app.form.browser import ObjectWidget
from entry import ABookEntry

def ABookEntryWidget(context,obj,request):
# We create an objectwidget which is aware of the correct object
# factory (here:PhoneNumber)
return ObjectWidget(context, request, ABookEntry)



# -=widgets.py=-

from zope.app.form.browser import ObjectWidget
from entry import ABookEntry

def ABookEntryWidget(context,obj,request):
return ObjectWidget(context, request, ABookEntry)





http://namespaces.zope.org/zope";
xmlns:browser="http://namespaces.zope.org/browser";>




















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


Re: [Zope3-Users] zope.schema.Object and custom widgets in formlib

2006-05-19 Thread Frank Burkhardt
Hi,

On Fri, May 19, 2006 at 11:37:51AM -0500, Jachin Rupe wrote:

[snip]

> I still haven't gotten it working yet though.  I'm going to keep trying to 
> figure out what 
> the problem is, I think I see what your basic strategy is.
> 
> However there are a few error I found in your example you may be interested 
> in fixing:
> 
> in your interfaces.py file you probably want the IPhoneBookEntry interface to 
> look like 
> this:

[...]

Sorry for the Typo - corrected it. But the whole concept works for me - I'm
using schema.Object, too.

Maybe I can help - what's the problem?

Regards,

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


Re: [Zope3-Users] zope.schema.Object and custom widgets in formlib

2006-05-19 Thread Frank Burkhardt
Hi,

On Thu, May 18, 2006 at 12:34:06PM -0500, Jachin Rupe wrote:
> hi there
> 
> I am having trouble getting form's generated for zope.schema.Object.  After 
> doing some more 
> reading it looks like I should be using formlib instead of 
> zope.app.form.browser.add.AddView and 
> zope.app.form.browser.editview.EditView

I completed the schema.Object-howto:

 http://zope3.mpg.de/cgi-bin/twiki/view/Zope/KomplexerContent

Regards,

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


Re: [Zope3-Users] zope.schema.Object and custom widgets in formlib

2006-05-19 Thread Frank Burkhardt
Hi,

On Thu, May 18, 2006 at 12:34:06PM -0500, Jachin Rupe wrote:
> hi there
> 
> I am having trouble getting form's generated for zope.schema.Object.  After 
> doing some more 
> reading it looks like I should be using formlib instead of 
> zope.app.form.browser.add.AddView and 
> zope.app.form.browser.editview.EditView

I'm currently writing a step-by-step-howto describing how to use the 
Object-schema and
how to write Widgets for it. It will be in german but all the code examples are
documented in english. URL is:

 http://zope3.mpg.de/cgi-bin/twiki/view/Zope/KomplexerContent

It's still work in progres but most of the work should be done within 6 hours.

Regards,

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


[Zope3-Users] zope.schema.Object and custom widgets in formlib

2006-05-18 Thread Jachin Rupe

hi there

I am having trouble getting form's generated for zope.schema.Object.   
After doing some more reading it looks like I should be using formlib  
instead of zope.app.form.browser.add.AddView and  
zope.app.form.browser.editview.EditView


(my new code will be at the bottom)

Which is fine because I was really having trouble getting  
zope.schema.Object to work properly.  Of course, now I am running  
into the same basic problem with formlib.  It looks like I need to  
specify some sort of custom widget for my zope.schema.Object.  If I  
don't I get the same ComponentLookupError I was getting with the old  
system.


I tried the zope.app.form.CustomWidgetFactory, and that actually got  
that part of the form to show up but it didn't work right.  If  
someone could tell me what I should be doing that would be great.


Also one other kinda bizarre thing, in my formlib form all the  
button text and messages where in German (I think, my German is a  
little rusty).


An aside... I have been really surprised by the lack of other people  
having the same problems or working examples else where.  I think I'm  
trying to do something very basic that would come up in lots of  
applications.  This makes me think that I'm going about this the  
wrong way, or the solution is very simple and I'm just being too  
dense to get it.  So basically, if anyone out there has some  
commentary on my approach to this problem I would really appreciate it.


thanks.

-jachin

# -=interfaces.py=-

from zope.interface import Interface
from zope.schema import TextLine, Int, Object

class IStreetAddress(Interface):
"""A street address"""

street = TextLine(
title=u"street",
description=u"",
required=False)


class IABookEntry(Interface):
"""An address book entry"""
streetAddress = Object(
schema=IStreetAddress,
title=u"Street Address",
description=u"",
required=False)


firstName = TextLine(
title=u"First Name",
description=u"",
required=False)


# -=entry.py=-

from zope.interface import implements
from zope.formlib import form
from zope.schema.fieldproperty import FieldProperty
from zope.app.form import CustomWidgetFactory
from zope.app.form.browser import ObjectWidget
from persistent import Persistent
from interfaces import IStreetAddress
from interfaces import IABookEntry


class StreetAddress(Persistent):
"""The Street Address object."""

implements(IStreetAddress)



class ABookEntry(Persistent):
"""The Address Book Entry object."""
implements(IABookEntry)
streetAddress = StreetAddress
firstName = u""

class ABookEntryEditView(form.EditForm):
form_fields = form.Fields(IABookEntry)
form_fields["streetAddress"].custom_widget =



what should go here?



http://namespaces.zope.org/zope";
xmlns:browser="http://namespaces.zope.org/browser";>








































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