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]




content class=.entry.StreetAddress
allow interface=.interfaces.IABookEntry /
/content


[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.ABookEntrys but  
editing them resulted in this error:  UnpickleableError: Cannot  
pickle type 'zope.security._proxy._Proxy' 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

!-- -=configure.zcml=- --

configure
xmlns=http://namespaces.zope.org/zope;
xmlns:browser=http://namespaces.zope.org/browser;

content class=.entry.ABookEntry
factory
id = entry.ABookEntry
title = An address book entry
/
require
permission=zope.View
interface=.interfaces.IABookEntry
/
require
permission=zope.ManageContent
set_schema=.interfaces.IABookEntry
/
/content
!--
content class=.entry.StreetAddress
allow interface=.interfaces.IABookEntry /
/content
--

content class=.entry.StreetAddress
factory
id = entry.StreetAddress
title = An street address
/
require
permission=zope.View
interface=.interfaces.IStreetAddress
/
require
permission=zope.ManageContent
set_schema=.interfaces.IStreetAddress
/
/content

view type=zope.publisher.interfaces.browser.IBrowserRequest
for=zope.schema.interfaces.IObject
provides=zope.app.form.interfaces.IInputWidget
factory=.objectwidgetdispatcher.ObjectInputWidget
permission=zope.Public
/

view
type=zope.publisher.interfaces.browser.IBrowserRequest
for=zope.schema.interfaces.IObject .interfaces.IStreetAddress
provides=zope.app.form.interfaces.IInputWidget
factory=.widgets.StreetAddressWidget
permission=zope.Public
/

browser:addform
label = New address book entry
name = add_address_book_entry.html
schema = .interfaces.IABookEntry
content_factory = .entry.ABookEntry
permission = zope.ManageContent
/

browser:editform
label = Change address book entry
name = edit.html
schema = .interfaces.IABookEntry
permission = zope.ManageContent
menu=zmi_views
title=Edit
/

browser:addMenuItem
title=ABook Entry
class=.entry.ABookEntry
permission=zope.ManageContent
view = add_address_book_entry.html
/

/configure


# -=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):

Re: [Zope3-Users] subpages with formlib

2006-05-23 Thread Jachin Rupe

hi there

I would like to put in another request for this.

I also put in some requests for stuff like this at:

http://zope-cookbook.org

They got back to me and said they would put my requests on their todo  
list.  If you haven't seen the site yet, they haven't got a whole lot  
of the recipes done yet but they defiantly have a bunch planed I'm  
looking forward to reading.


-jachin

On May 22, 2006, at 11:24 AM, Rocky Burt wrote:



I'm currently working my way through learning formlib and came across
subpages which I can't seem to figure out.  Would someone mind
describing to me how subpages work in formlib or send me a link to  
some

good docs or a good example?

To express my use-case, I have a default view for my content type  
mapped

as index.html (it extends form.DisplayForm).  On that view I currently
display all of the relevant data regarding my content object which is
the context.  What I would like to do is add a sub-form to that  
page for

quickly adding child objects so that the user doesn't have to click to
another tab or something similar to add their content.  Basically a
shortcut add form.  This *seems* like where subpages might come into
play, but alas I do not understand subpages.

But perhaps I'm looking down the wrong hole?  Maybe there's a better
solution to my problem? (regardless if there is a better solution, I'd
still like to understand formlib subpages).


- Rocky

--
Rocky Burt
ServerZen Software -- http://www.serverzen.com
News About The Server (blog) -- http://www.serverzen.net

___
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


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', simple_abook.entry.ABookEntry object  
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


!-- -===configure.zcml===- --

configure
xmlns=http://namespaces.zope.org/zope;
xmlns:browser=http://namespaces.zope.org/browser;

content class=.entry.ABookEntry
factory
id = entry.ABookEntry
title = An address book entry
/
require
permission=zope.View
interface=.interfaces.IABookEntry
/
require
permission=zope.ManageContent
set_schema=.interfaces.IABookEntry
/
/content

content class=.entry.StreetAddress
allow interface=.interfaces.IABookEntry /
/content

view type=zope.publisher.interfaces.browser.IBrowserRequest
for=zope.schema.interfaces.IObject
provides=zope.app.form.interfaces.IInputWidget
factory=.objectwidgetdispatcher.ObjectInputWidget
permission=zope.Public
/

view
type=zope.publisher.interfaces.browser.IBrowserRequest
for=zope.schema.interfaces.IObject .interfaces.IStreetAddress
provides=zope.app.form.interfaces.IInputWidget
factory=.widgets.ABookEntryWidget
permission=zope.Public
/

browser:addform
label = New address book entry
name = add_address_book_entry.html
schema = .interfaces.IABookEntry
content_factory = .entry.ABookEntry
permission = zope.ManageContent
/

browser:editform
label = Change address book entry
name = edit.html
schema = .interfaces.IABookEntry
permission = zope.ManageContent
menu=zmi_views
title=Edit
/

browser:addMenuItem
title=ABook Entry
class=.entry.ABookEntry
permission=zope.ManageContent
view = add_address_book_entry.html
/

/configure



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

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

class IStreetAddress(Interface):
A street address

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


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

firstName = TextLine(
title=uFirst 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 

Re: [Zope3-Users] Changes on object not persistent if server is restarted.

2006-05-22 Thread Jachin Rupe


On May 22, 2006, at 2:40 PM, Achim Domma wrote:


Hi,

I have written this simple content object:

class IArticle(Interface):
title = TextLine(
title=uTitle,
description=uThe title,
default=u,
required=True)

body = Text(
title=uBody,
description=uArticle Body,
default=u,
required=True)

class Article(object):
implements(IArticle)
title=u''
body=u''

The body of the article is rendered as restructured text. I can  
create and edit articles via the automatically generated forms.  
Everything worked fine, but currently my changes are not persistent  
if I restart the server.
The body is not empty after restart, but holds an older version.  
I'm working with the SVN version of Zope 3.


Any hint what I might be doing wrong?


hi there

You could try making Acrticle inherit from Persistent.  That  
would would involve something like this:


from persistent import Persistent

class Article(Persistent):
implements(IArticle)
title=u''
body=u''

hope that helps

-jachin




regards,
Achim

___
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


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=ustreet,
description=u,
required=False)


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

firstName = TextLine(
title=uFirst 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)



!-- -=configure.zcml=- --

configure
xmlns=http://namespaces.zope.org/zope;
xmlns:browser=http://namespaces.zope.org/browser;

content class=.entry.ABookEntry
factory
id = entry.ABookEntry
title = An address book entry
/
require
permission=zope.View
interface=.interfaces.IABookEntry
/
require
permission=zope.ManageContent
set_schema=.interfaces.IABookEntry
/
/content

content class=.entry.StreetAddress
allow interface=.interfaces.IABookEntry /
/content

view
type=zope.publisher.interfaces.browser.IBrowserRequest
for=zope.schema.interfaces.IObject .interfaces.IStreetAddress
provides=zope.app.form.interfaces.IInputWidget
factory=.widgets.ABookEntryWidget
permission=zope.Public
/

browser:addform
label = New address book entry
name = add_address_book_entry.html
schema = .interfaces.IABookEntry
content_factory = .entry.ABookEntry
permission = zope.ManageContent
/

browser:editform
label = Change address book entry
name = edit.html
schema = .interfaces.IABookEntry
permission = zope.ManageContent
menu=zmi_views
title=Edit
/

browser:addMenuItem
title=ABook Entry
class=.entry.ABookEntry
permission=zope.ManageContent
view = add_address_book_entry.html
/

/configure
___
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=ustreet,
description=u,
required=False)


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


firstName = TextLine(
title=uFirst 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?

!-- -=configure.zcml=- --

configure
xmlns=http://namespaces.zope.org/zope;
xmlns:browser=http://namespaces.zope.org/browser;

content class=.entry.StreetAddress
require
permission=zope.View
interface=.interfaces.IStreetAddress
/
require
permission=zope.ManageContent
set_schema=.interfaces.IStreetAddress
/
/content

content class=.entry.ABookEntry
require
permission=zope.View
interface=.interfaces.IABookEntry
/
require
permission=zope.ManageContent
set_schema=.interfaces.IABookEntry
/
/content

browser:page
for=.entry.IABookEntry
name=index.html
template=entry.pt

class=.entry.ABookEntry
permission=zope.Public

/

browser:page
for=.entry.IABookEntry
name=edit.html
template=edit.pt
class=.entry.ABookEntryEditView
menu=zmi_views
title=Edit
permission=zope.ManageContent
/

browser:addMenuItem
title=ABook Entry
class=.entry.ABookEntry
permission=zope.ManageContent
/

/configure


!-- -=entry.pt=- --

html metal:use-macro=context/@@standard_macros/view
body
div metal:fill-slot=body tal:content=view
/div
/body
/html

!-- -=edit.pt=- --

html 

Re: [Zope3-Users] Composing content objects

2006-05-16 Thread Jachin Rupe


On May 16, 2006, at 3:20 AM, Achim Domma wrote:


mats.nordgren wrote:

def __init__(self, schema, **kw):  you need to pass a  
schema as a non

key-word



Thanks! That solved my problem. Now I get a component lookup error,  
but I think this is, because there is no default widget for the  
object. So I have to register one via zcml. Am I right?


maybe you can use zcml... if someone knows how to do that, that would  
be cool.


I'm trying to do something similar.

Here's an example of how to solve the component look up error:

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

I had to make my own EditView and AddView.  However as you'll see I'm  
running into a 'Could not adapt' error.  So this solution appears to  
need more work, but I think it is progress.


-jachin



regards,
Achim

PS.: Also thanks to Dominik, which pointed me to the same solution.
___
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] ForbiddenAttribute

2006-05-16 Thread Jachin Rupe

hi there

I keep running into problems with my Address Book example.  This one  
should be simple but I can't find the problem.  I may have spent too  
much time looking at it.  I get this error after I add an entry and  
then try to edit it:


--
2006-05-16T17:09:39 ERROR SiteError http://localhost:8080/Jachin% 
20Rupe/@@edit.html

Traceback (most recent call last):
  File /usr/local/Zope-3.2.1/lib/python/zope/publisher/publish.py,  
line 138, in publish

result = publication.callObject(request, object)
  File /usr/local/Zope-3.2.1/lib/python/zope/app/publication/ 
zopepublication.py, line 161, in callObject

return mapply(ob, request.getPositionalArguments(), request)
  File /usr/local/Zope-3.2.1/lib/python/zope/publisher/publish.py,  
line 113, in mapply

return debug_call(object, args)
  File /usr/local/Zope-3.2.1/lib/python/zope/publisher/publish.py,  
line 119, in debug_call

return object(*args)
  File /usr/local/Zope-3.2.1/lib/python/zope/app/pagetemplate/ 
simpleviewclass.py, line 44, in __call__

return self.index(*args, **kw)
  File /usr/local/Zope-3.2.1/lib/python/zope/app/pagetemplate/ 
viewpagetemplatefile.py, line 83, in __call__

return self.im_func(im_self, *args, **kw)
  File /usr/local/Zope-3.2.1/lib/python/zope/app/pagetemplate/ 
viewpagetemplatefile.py, line 51, in __call__

sourceAnnotations=getattr(debug_flags, 'sourceAnnotations', 0),
  File /usr/local/Zope-3.2.1/lib/python/zope/pagetemplate/ 
pagetemplate.py, line 117, in pt_render

strictinsert=0, sourceAnnotations=sourceAnnotations)()
  File /usr/local/Zope-3.2.1/lib/python/zope/tal/ 
talinterpreter.py, line 277, in __call__

self.interpret(self.program)
  File /usr/local/Zope-3.2.1/lib/python/zope/tal/ 
talinterpreter.py, line 352, in interpret

handlers[opcode](self, args)
  File /usr/local/Zope-3.2.1/lib/python/zope/tal/ 
talinterpreter.py, line 871, in do_condition

if not self.tal or self.engine.evaluateBoolean(condition):
  File /usr/local/Zope-3.2.1/lib/python/zope/tales/tales.py, line  
701, in evaluateBoolean

return not not self.evaluate(expr)
  File /usr/local/Zope-3.2.1/lib/python/zope/tales/tales.py, line  
696, in evaluate

return expression(self)
  File /usr/local/Zope-3.2.1/lib/python/zope/tales/expressions.py,  
line 205, in __call__

return self._eval(econtext)
  File /usr/local/Zope-3.2.1/lib/python/zope/tales/expressions.py,  
line 199, in _eval

return ob()
  File /usr/local/Zope-3.2.1/lib/python/zope/app/form/browser/ 
editview.py, line 98, in update

target=content, names=self.fieldNames)
  File /usr/local/Zope-3.2.1/lib/python/zope/app/form/utility.py,  
line 303, in applyWidgetsChanges

changed = widget.applyChanges(target) or changed
  File /usr/local/Zope-3.2.1/lib/python/zope/app/form/browser/ 
objectwidget.py, line 162, in applyChanges

names=self.names)
  File /usr/local/Zope-3.2.1/lib/python/zope/app/form/utility.py,  
line 303, in applyWidgetsChanges

changed = widget.applyChanges(target) or changed
  File /usr/local/Zope-3.2.1/lib/python/zope/app/form/__init__.py,  
line 86, in applyChanges

field.set(content, value)
  File /usr/local/Zope-3.2.1/lib/python/zope/schema/ 
_bootstrapfields.py, line 183, in set

setattr(object, self.__name__, value)
ForbiddenAttribute: ('street', simple_abook.entry.ABookEntry  
instance at 0x3afa828)


-

No data seems to get saved in the street field when I use the addform  
either.


I'll put the code I'm working with at the bottom.

I have been trying to get a good understanding of ObjectWidget and  
have been have a really hard time.  I got most of the code layout for  
this from here:  http://www.mail-archive.com/zope3-users@zope.org/ 
msg00917.html


I'm using Zope 3.2.1

It seems like since it's a security problem I should be able to fix  
it by changing something in configuration.zcml but I just can not see  
anything I'm missing.  Any help would be appreciated.


thanks.

-jachin

--
configure.zcml
--

configure
xmlns=http://namespaces.zope.org/zope;
xmlns:browser=http://namespaces.zope.org/browser;

content class=.entry.StreetAddress
require
permission=zope.View
interface=.interfaces.IStreetAddress
/
require
permission=zope.ManageContent
set_schema=.interfaces.IStreetAddress
/
/content

content class=.entry.ABookEntry
require
permission=zope.View
interface=.interfaces.IABookEntry
/
require
permission=zope.ManageContent
set_schema=.interfaces.IABookEntry
/
/content

browser:editform

Re: [Zope3-Users] ComponentLookupError

2006-05-15 Thread Jachin Rupe

hi there

thanks for the help... but I have a new problem.  Now the addForm  
show up but if I try to actually add a person I get the following error:


2006-05-15T17:19:42 ERROR SiteError http://localhost:8080/+/ 
AddPerson.html%3D

Traceback (most recent call last):
  File /usr/local/Zope-3.2.1/lib/python/zope/publisher/publish.py,  
line 138, in publish

result = publication.callObject(request, object)
  File /usr/local/Zope-3.2.1/lib/python/zope/app/publication/ 
zopepublication.py, line 161, in callObject

return mapply(ob, request.getPositionalArguments(), request)
  File /usr/local/Zope-3.2.1/lib/python/zope/publisher/publish.py,  
line 113, in mapply

return debug_call(object, args)
  File /usr/local/Zope-3.2.1/lib/python/zope/publisher/publish.py,  
line 119, in debug_call

return object(*args)
  File /usr/local/Zope-3.2.1/lib/python/zope/app/pagetemplate/ 
simpleviewclass.py, line 44, in __call__

return self.index(*args, **kw)
  File /usr/local/Zope-3.2.1/lib/python/zope/app/pagetemplate/ 
viewpagetemplatefile.py, line 83, in __call__

return self.im_func(im_self, *args, **kw)
  File /usr/local/Zope-3.2.1/lib/python/zope/app/pagetemplate/ 
viewpagetemplatefile.py, line 51, in __call__

sourceAnnotations=getattr(debug_flags, 'sourceAnnotations', 0),
  File /usr/local/Zope-3.2.1/lib/python/zope/pagetemplate/ 
pagetemplate.py, line 117, in pt_render

strictinsert=0, sourceAnnotations=sourceAnnotations)()
  File /usr/local/Zope-3.2.1/lib/python/zope/tal/ 
talinterpreter.py, line 277, in __call__

self.interpret(self.program)
  File /usr/local/Zope-3.2.1/lib/python/zope/tal/ 
talinterpreter.py, line 352, in interpret

handlers[opcode](self, args)
  File /usr/local/Zope-3.2.1/lib/python/zope/tal/ 
talinterpreter.py, line 908, in do_useMacro

self.interpret(macro)
  File /usr/local/Zope-3.2.1/lib/python/zope/tal/ 
talinterpreter.py, line 352, in interpret

handlers[opcode](self, args)
  File /usr/local/Zope-3.2.1/lib/python/zope/tal/ 
talinterpreter.py, line 538, in do_optTag_tal

self.do_optTag(stuff)
  File /usr/local/Zope-3.2.1/lib/python/zope/tal/ 
talinterpreter.py, line 523, in do_optTag

return self.no_tag(start, program)
  File /usr/local/Zope-3.2.1/lib/python/zope/tal/ 
talinterpreter.py, line 518, in no_tag

self.interpret(program)
  File /usr/local/Zope-3.2.1/lib/python/zope/tal/ 
talinterpreter.py, line 352, in interpret

handlers[opcode](self, args)
  File /usr/local/Zope-3.2.1/lib/python/zope/tal/ 
talinterpreter.py, line 878, in do_defineMacro

self.interpret(macro)
  File /usr/local/Zope-3.2.1/lib/python/zope/tal/ 
talinterpreter.py, line 352, in interpret

handlers[opcode](self, args)
  File /usr/local/Zope-3.2.1/lib/python/zope/tal/ 
talinterpreter.py, line 976, in do_defineSlot

self.interpret(block)
  File /usr/local/Zope-3.2.1/lib/python/zope/tal/ 
talinterpreter.py, line 352, in interpret

handlers[opcode](self, args)
  File /usr/local/Zope-3.2.1/lib/python/zope/tal/ 
talinterpreter.py, line 966, in do_defineSlot

self.interpret(slot)
  File /usr/local/Zope-3.2.1/lib/python/zope/tal/ 
talinterpreter.py, line 352, in interpret

handlers[opcode](self, args)
  File /usr/local/Zope-3.2.1/lib/python/zope/tal/ 
talinterpreter.py, line 878, in do_defineMacro

self.interpret(macro)
  File /usr/local/Zope-3.2.1/lib/python/zope/tal/ 
talinterpreter.py, line 352, in interpret

handlers[opcode](self, args)
  File /usr/local/Zope-3.2.1/lib/python/zope/tal/ 
talinterpreter.py, line 878, in do_defineMacro

self.interpret(macro)
  File /usr/local/Zope-3.2.1/lib/python/zope/tal/ 
talinterpreter.py, line 352, in interpret

handlers[opcode](self, args)
  File /usr/local/Zope-3.2.1/lib/python/zope/tal/ 
talinterpreter.py, line 588, in do_setLocal_tal

self.engine.setLocal(name, self.engine.evaluateValue(expr))
  File /usr/local/Zope-3.2.1/lib/python/zope/tales/tales.py, line  
696, in evaluate

return expression(self)
  File /usr/local/Zope-3.2.1/lib/python/zope/tales/expressions.py,  
line 205, in __call__

return self._eval(econtext)
  File /usr/local/Zope-3.2.1/lib/python/zope/tales/expressions.py,  
line 199, in _eval

return ob()
  File /usr/local/Zope-3.2.1/lib/python/zope/app/form/browser/ 
add.py, line 62, in update

self.createAndAdd(data)
  File /usr/local/Zope-3.2.1/lib/python/zope/app/form/browser/ 
add.py, line 115, in createAndAdd

adapted = self.schema(content)
  File /usr/local/Zope-3.2.1/lib/python/zope/interface/ 
interface.py, line 682, in __call__

raise TypeError(Could not adapt, obj, self)
TypeError: ('Could not adapt', simple_abook.person.Person object at  
0x3b3a6f0, InterfaceClass simple_abook.interfaces.IPerson)


I think this is saying that it can't adapt my Person object to the  
IPerson interface.


Am I still missing something?

Now for the sake of completeness here's the rest of the example so  
everyone can be on the same page:



[Zope3-Users] ComponentLookupError

2006-05-11 Thread Jachin Rupe

hi there

here's a smaller, hopefully more clearer example of a problem I have  
been stuck on.  I should probably also lead off by saying that I  
think what I am asking is basically this question.


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

However I have read objectwidget.txt( http://svn.zope.org/Zope3/trunk/ 
src/zope/app/form/browser/objectwidget.txt ) several times and I  
don't see where a custom widget gets created.  I also suspect that  
because the object I need to create a custom widget for has more  
than just one field I have to do something different.


If there's a short fix for the problem that would be great, otherwise  
a little explanation to point me in the right direction would be  
greatly appreciated too.


thanks.

-jachin

Here's the error I'm getting any my code:

2006-05-11T11:56:47 ERROR SiteError http://localhost:8080/@@+/ 
action.html

Traceback (most recent call last):
  File /usr/local/Zope-3.2.1/lib/python/zope/publisher/publish.py,  
line 138, in publish

result = publication.callObject(request, object)
  File /usr/local/Zope-3.2.1/lib/python/zope/app/publication/ 
zopepublication.py, line 161, in callObject

return mapply(ob, request.getPositionalArguments(), request)
  File /usr/local/Zope-3.2.1/lib/python/zope/publisher/publish.py,  
line 113, in mapply

return debug_call(object, args)
  File /usr/local/Zope-3.2.1/lib/python/zope/publisher/publish.py,  
line 119, in debug_call

return object(*args)
  File /usr/local/Zope-3.2.1/lib/python/zope/app/container/browser/ 
adding.py, line 128, in action

name=view_name) is not None:
  File /usr/local/Zope-3.2.1/lib/python/zope/component/ 
__init__.py, line 165, in queryMultiAdapter
return sitemanager.queryMultiAdapter(objects, interface, name,  
default)
  File /usr/local/Zope-3.2.1/lib/python/zope/component/site.py,  
line 75, in queryMultiAdapter

default)
  File /usr/local/Zope-3.2.1/lib/python/zope/interface/adapter.py,  
line 475, in queryMultiAdapter

return factory(*objects)
  File /usr/local/Zope-3.2.1/lib/python/zope/app/form/browser/ 
editview.py, line 64, in __init__

self._setUpWidgets()
  File /usr/local/Zope-3.2.1/lib/python/zope/app/form/browser/ 
add.py, line 49, in _setUpWidgets
setUpWidgets(self, self.schema, IInputWidget,  
names=self.fieldNames)
  File /usr/local/Zope-3.2.1/lib/python/zope/app/form/utility.py,  
line 153, in setUpWidgets

context=context)
  File /usr/local/Zope-3.2.1/lib/python/zope/app/form/utility.py,  
line 97, in setUpWidget

widget = _createWidget(context, field, viewType, view.request)
  File /usr/local/Zope-3.2.1/lib/python/zope/app/form/utility.py,  
line 65, in _createWidget

return zapi.getMultiAdapter((field, request), viewType)
  File /usr/local/Zope-3.2.1/lib/python/zope/component/ 
__init__.py, line 154, in getMultiAdapter

raise ComponentLookupError(objects, interface, name)
ComponentLookupError: ((zope.schema._field.Object object at  
0x4282b70, zope.publisher.browser.BrowserRequest instance  
URL=http://localhost:8080/@@+/action.html), InterfaceClass  
zope.app.form.interfaces.IInputWidget, u'')
127.0.0.1 - - [11/May/2006:11:56:47 -0500] GET /@@+/action.html? 
type_name=AddPerson.html HTTP/1.1 500 84 http://localhost:8080/ 
@@contents.html Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en- 
US; rv:1.8.0.3) Gecko/20060427 Camino/1.0.1


interfaces.py

from zope.interface import Interface
import zope.schema

class IStreetAddress(Interface):
A vine street address

street = zope.schema.Text (
title=uStreet 1,
description=uThe street address,
required = False
)

city = zope.schema.TextLine (
title=uCity,
description=uThe city.,
required = False
)

state = zope.schema.TextLine (
title=uState,
description=uThe state.,
required = False
)

zipcode = zope.schema.TextLine (
title=uZip Code,
description=uThe zip code,
required = False,
min_length = 5
)


class IPerson(Interface):
firstName = zope.schema.TextLine (
title=uFirst Name,
description=uThe person's first name,
required=False
)

lastName = zope.schema.TextLine (
title=uLast Name,
description=uThe person's last name,
required=False
)

address = zope.schema.Object (
title=uAddress,
description=uThe person's adderess,
required=False,
schema = IStreetAddress
)


person.py

from persistent import Persistent
from zope.interface import implements

from 

Re: [Zope3-Users] ComponentLookupError

2006-05-11 Thread Jachin Rupe

hi there

opps I forgot:

streetAddress.py

from persistent import Persistent
from zope.interface import implements

from abook.interfaces import IStreetAddress


class StreetAddress(Persistent):

implements(IStreetAddress)

street = u
city = u
state = u
zipcode = u



On May 11, 2006, at 2:02 PM, Egon Frerich wrote:


-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi Jachin,


Jachin Rupe schrieb am 11.05.2006 19:12:


interfaces.py

from zope.interface import Interface
import zope.schema

class IStreetAddress(Interface):
A vine street address

street = zope.schema.Text (
title=uStreet 1,
description=uThe street address,
required = False
)

city = zope.schema.TextLine (
title=uCity,
description=uThe city.,
required = False
)

state = zope.schema.TextLine (
title=uState,
description=uThe state.,
required = False
)

zipcode = zope.schema.TextLine (
title=uZip Code,
description=uThe zip code,
required = False,
min_length = 5
)





Can you please me your implementation for this?

Egon

- --
Egon Frerich, Freudenbergstr. 16, 28213 Bremen

E-Mail: [EMAIL PROTECTED]
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.2.2 (MingW32)
Comment: GnuPT 2.7.2
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEY4pDuTzybIiyjvURAlPqAJ4tupOdpsCvIK7SBco58WJ7rQEpGwCfdl+u
poVz3T26Wfap0sRx8X0Ed7A=
=KQ3V
-END PGP SIGNATURE-


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


Re: [Zope3-Users] has a relationships

2006-05-09 Thread Jachin Rupe

hi there

Alright... I'm working on implementing IPerson in the class Person  
and I'm not sure exactly what has to happen.  I kinda have two ideas  
but I suspect I need to some how combine them but I don't know how to  
do that.  A big part of the problem is that I do not know what  
zope.schema.fieldproperty.FieldProperty does.  The only reason I'm  
working it in, is because it appears to be necessary to get this  
whole thing to work:


http://svn.zope.org/Zope3/trunk/src/zope/app/form/browser/ 
objectwidget.txt


Here are my ideas:

--

from persistent import Persistent
from zope.interface import implements

from abook.interfaces import IPerson

class Person(Persistent):

implements(IPerson)

firstName = u
lastName = u
phoneNumbers = persistent.dict.PersistentDict()
emails = persistent.dict.PersistentDict()
addresses = persistent.dict.PersistentDict()

--

from persistent import Persistent
from zope.interface import implements
from zope.schema.fieldproperty import FieldProperty

from abook.interfaces import IStreetAddress
from abook.interfaces import IPerson

class Person(Persistent):

implements(IPerson)

phoneNumbers = FieldProperty(IPerson['phoneNumbers'])
emails = FieldProperty(IPerson['emails'])
addresses = FieldProperty(IPerson['addresses'])

def __init__(self,
firstName = u, lastName = u,
phoneNumbers = None, emails = None,
addresses = None):

self.firstName = firstName
self.lastName = lastName
self.phoneNumbers = phoneNumbers
self.emails = emails
self.addresses = addresses


--

I guess my question is, how should I be implementing Person?  Is one  
of those right or are they both wrong?


thanks

-jachin




#abook/interfaces.py

from zope.interface import Interface
import zope.schema

class IStreetAddress(Interface):
A vine street address

street = zope.schema.Text (
title=uStreet 1,
description=uThe street address,
required = False
)

city = zope.schema.TextLine (
title=uCity,
description=uThe city.,
required = False
)

state = zope.schema.TextLine (
title=uState,
description=uThe state.,
required = False
)

zipcode = zope.schema.TextLine (
title=uZip Code,
description=uThe zip code,
required = False,
min_length = 5
)

class IABookEntry(Interface):
phoneNumbers = zope.schema.Dict(
title=uPhone Numbers,
description=uThe phone numbers for this entry,
required=False,
key_type=zope.schema.TextLine (
title=uType,
description=uThe type of phone number,
required=True
),
value_type=zope.schema.TextLine (
title=uNumber,
description=uThe phone number.,
required=True
)
)

emails = zope.schema.Dict(
title=uEmail Addresses,
description=uThe email addresses for this entry,
required=False,
key_type=zope.schema.TextLine (
title=uType,
description=uThe type of email address,
required=True
),
value_type=zope.schema.TextLine (
title=uEmail Address,
description=uThe email address.,
required=True
)
)

addresses = zope.schema.Dict(
title=uAddresses,
description=uStreet address,
required=False,
key_type=zope.schema.TextLine(
title=uType,
description=uThe type of street address,
required=True
),
value_type=zope.schema.Object (
title=uStreet Address,
description=uA street address,
required=True,
schema=IStreetAddress
)
)


class 

[Zope3-Users] has a relationships

2006-05-04 Thread Jachin Rupe

hi there

I have another zope theory question.  I am working on designing a  
application in zope.  I've been looking at a lot of examples and I am  
wondering how people are implementing different types of  
relationships between different persistent objects.


For instance I am going to be doing a lot with addresses.  Naturally  
it would be nice to have persistent Address class.  Then I would say  
that a Person has an Address and a Company has an Address.


My two different ideas are as follows:

1.  Make Person and and Company containers that can each contain an  
Address.  I don't really like this idea because it seems like  
container objects are for things like folders.  This could be the  
best way though and I'm just not zoppie enough yet.


2.  Add an Object for the Address to the schema for IPerson and  
ICompany (assuming I only need one address) or a List / Dict (if I  
want more than one address for each person or company).  I like this  
idea better but I have yet to see any examples where someone does  
that which is making me a little nervous.   Among other things I'd  
like to be able to see what happens when addforms and editforms  
get generated for things like this or at least be assured that's the  
way it is supposed to work.


I just got my very own copies of the Zope 3 Developers Handbook and  
Web Component Development with Zope 3 (I'd suggest these books to  
anyone by the way).  I have given each a once over as well as looking  
at lots of shorter tutorials / examples online and have not noticed  
any example projects doing anything like my second idea.


So in your answer please feel free to point out something in either  
of those books (I may have missed) or refer me to some other online  
example where something like this is going on.


thanks

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


Re: [Zope3-Users] error headache: __init__() takes exactly 1 argument (3 given)

2006-04-27 Thread Jachin Rupe

hi there

Thanks for the reply.  Removing the class attribute from the page  
directive got rid of the error.  However I'm not overriding the  
VinePackage class.


class VinePackage(BTreeContainer):

implements(IVinePackage)

title = u


Since it is inheriting from BTreeContainer, perhaps that overrides  
the constructor?  I'll look into it and if I find an answer before  
someone else offers one I'll post it.


-jachin

On Apr 27, 2006, at 3:35 PM, Bernd Dorn wrote:

did you override the constructor in vine.vinePackage.VinePackage or  
one of its superclasses?


iv yes, then you need

def __init__(self,context,request):
...

as constructor, you can test it by just removing the class  
attribute of your page directive




On 27.04.2006, at 21:08, Jachin Rupe wrote:


hi there

I've got an error I've been stuck on for several hours now and I  
know the problem has got to be a very simple one but the error  
message I'm getting is not helping.  I'm just trying to create a  
view for a very simple object.  Here's the error I'm getting:


2006-04-27T13:58:09 ERROR SiteError http://localhost:8080/ 
VinePackage/@@details.html

Traceback (most recent call last):
  File /usr/local/Zope-3.2.1/lib/python/zope/publisher/ 
publish.py, line 135, in publish

object = request.traverse(object)
  File /usr/local/Zope-3.2.1/lib/python/zope/publisher/ 
browser.py, line 500, in traverse

ob = super(BrowserRequest, self).traverse(object)
  File /usr/local/Zope-3.2.1/lib/python/zope/publisher/http.py,  
line 451, in traverse

ob = super(HTTPRequest, self).traverse(object)
  File /usr/local/Zope-3.2.1/lib/python/zope/publisher/base.py,  
line 289, in traverse

subobject = publication.traverseName(
  File /usr/local/Zope-3.2.1/lib/python/zope/app/publication/ 
publicationtraverse.py, line 46, in traverseName

ob2 = namespaceLookup(ns, nm, ob, request)
  File /usr/local/Zope-3.2.1/lib/python/zope/app/traversing/ 
namespace.py, line 121, in namespaceLookup

return traverser.traverse(name, ())
  File /usr/local/Zope-3.2.1/lib/python/zope/app/traversing/ 
namespace.py, line 363, in traverse

name=name)
  File /usr/local/Zope-3.2.1/lib/python/zope/component/ 
__init__.py, line 165, in queryMultiAdapter
return sitemanager.queryMultiAdapter(objects, interface, name,  
default)
  File /usr/local/Zope-3.2.1/lib/python/zope/component/site.py,  
line 75, in queryMultiAdapter

default)
  File /usr/local/Zope-3.2.1/lib/python/zope/interface/ 
adapter.py, line 475, in queryMultiAdapter

return factory(*objects)
TypeError: __init__() takes exactly 1 argument (3 given)

None of code I have written is in that trace so I have no idea  
where the problem is.  Everything else I try to do with the object  
I'm trying to create a new view for works so I'm assuming the  
problem is in the ZCML for the view:


page
name=details.html
for=vine.interfaces.IVinePackage
class=vine.vinePackage.VinePackage
template=vinePackage.pt
permission=zope.Public
menu=zmi_views
title=Preview
/

The only other file I can think of that might be the cause of the  
problem is vinePackage.pt   I took out all of the parts that refer  
to the Content Object in case the problem was there so I removed  
stuff until it was just a static html page and I was still getting  
the error.  As far as I can tell I'm following the message board  
example in the Zope book pretty closely.  If anyone has any  
suggestions on where I should look for the problem I would really  
appreciate it.


thanks

-jachin
___
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] Container base classes

2006-04-26 Thread Jachin Rupe

hi there

I am new to Zope.  I have been spending the last several days reading  
everything I can find on Zope.  So far a lot of the larger examples  
I've seen use zope.app.container.btree.BTreeContainer any time it is  
necessary to hold a bunch of other objects.  Yet when I looked at the  
documentation for BTreeContainer it says that I probably shouldn't be  
using it and should be doing something else.


Assuming I know enough now to start working on a real project,  
should I be sticking with the stuff in the persistent package?  Are  
there other persistent objects hiding somewhere else in the API I  
should be aware of?


thanks

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


[Zope3-Users] Security Question

2006-04-22 Thread Jachin Rupe

hi there

Is there a good example out there of setting up security based on  
some sort of ownership system?


I'm working my way though the Zope book.  What I would like to be  
able to do is allow the User who created a message to edit only  
their messages (the messages they created).  I think I've read all  
the relevant chapters of the Zope book and I can't find a place where  
it explains that.  Did I miss is somewhere?


Could some one point me in the right direction for figuring this out?

If this isn't in the Zope book it may make a good addition.  There  
are lots of instances I can think of in application where someone  
would want to grant privileges based on ownership.


thanks

-jachin

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