[Zope3-Users] Re: Re : Re : formlib problem

jürgen Kartnaller juergen at kartnaller.at
Wed Apr 19 12:05:10 EDT 2006


Stéphane Brault wrote:
> Hi Jim, 
>  the Items object is my object, linked to my items, table which implements the IItems interface I use for my form:
>  
>  from neteven.interfaces.items import IItems
>  from zope.formlib import form    
>  
>  class ItemsForm(form.EditForm):
>      form_fields = form.Fields(IItems)
>      form_fields = form_fields.omit('dateLastUpdate')
>  
>  Items is defined this way:
>  
>  from zope.interface import implements
>  from sqlobject import *
>  from sqlos import SQLOS
>  from neteven.interfaces.items import IItems
>  
>  class Items(SQLOS):
>      implements(IItems)
>      
>      class sqlmeta:
>          table = 'items'
>  ....
>  
>   When I add this zcml declaration :
>  <browser:page
>        for=".interfaces.items.IItems"
>        name="edit.html"
>        class=".forms.items.ItemsForm"
>        menu="zmi_views"
>        title="Edit a Item"
>        permission="zope.ManageContent"
>        />
>  everything works fine from the ZMI (I created simple containers to test that).
>  
>  My JSON server side code is:
>  
>  def getItemEdit(self, itemId):
>          item = Items.get(itemId) #a sqlos function to get an Item instance from the table given its Id
>          return ItemsForm(item, self.request)()

After the request from the database your item has no location and is
therefore not physically locatable.
If you use it from within an SQLOS container the container puts the item
into a location proxy.
That's the difference between your test in the ZMI and this code.

Jürgen

>  
> The fact is I don't use any page template right now ( though I might do this later to have a nice GUI).
>  
>  Thanks,
>  
>  Stéphane
>  
> ----- Message d'origine ----
> De : Jim Washington <jwashin at vt.edu>
> À : Stéphane Brault <stephane_brault at yahoo.fr>
> Cc : zope3-users at zope.org
> Envoyé le : Mercredi, 19 Avril 2006, 5h01mn 09s
> Objet : Re: Re : [Zope3-Users] formlib problem
> 
> Stéphane Brault wrote:
>> Hi again,
>>  sorry to be a bore ;-)
>>  I keep on trying to use formlib, I no longer have a problem of adapters for my fields but I get this error:
>>  2006-04-19T16:13:32 ERROR root C:\Python24\Lib\site-packages\zope\publisher\publish.py line 138 in publish
>>  => 'result = publication.callObject(request, object)'
>>  ** exceptions.TypeError: ('Could not adapt', <Items at 0x3d7ce30>, <InterfaceClass zope.app.traversing.interfaces.IPhysicallyLocatable>)
>>  C:\Python24\Lib\site-packages\zope\app\publication\zopepublication.py line 161 in callObject
>>  => 'return mapply(ob, request.getPositionalArguments(), request)'
>>  ** exceptions.TypeError: ('Could not adapt', <Items at 0x3d7ce30>, <InterfaceClass zope.app.traversing.interfaces.IPhysicallyLocatable>)
>>  C:\Python24\Lib\site-packages\zope\publisher\publish.py line 113 in mapply
>>  => 'return debug_call(object, args)'
>>  ** exceptions.TypeError: ('Could not adapt', <Items at 0x3d7ce30>, <InterfaceClass zope.app.traversing.interfaces.IPhysicallyLocatable>)
>>  C:\Python24\Lib\site-packages\zope\publisher\publish.py line 119 in debug_call
>>  => 'return object(*args)'
>>  ** exceptions.TypeError: ('Could not adapt', <Items at 0x3d7ce30>, <InterfaceClass zope.app.traversing.interfaces.IPhysicallyLocatable>)
>>  c:\ZopeInst\lib\python\neteven\database\items.py line 43 in getItemEdit
>>  => 'return ItemsForm(item, self.request).render()'
>>  ** exceptions.TypeError: ('Could not adapt', <Items at 0x3d7ce30>, <InterfaceClass zope.app.traversing.interfaces.IPhysicallyLocatable>)
>>  C:\Python24\Lib\site-packages\zope\formlib\form.py line 733 in render
>>  => 'self.form_result = self.template()'
>>  ** exceptions.TypeError: ('Could not adapt', <Items at 0x3d7ce30>, <InterfaceClass zope.app.traversing.interfaces.IPhysicallyLocatable>)
>>  C:\Python24\Lib\site-packages\zope\app\pagetemplate\viewpagetemplatefile.py line 83 in __call__
>>  => 'return self.im_func(im_self, *args, **kw)'
>>  ** exceptions.TypeError: ('Could not adapt', <Items at 0x3d7ce30>, <InterfaceClass zope.app.traversing.interfaces.IPhysicallyLocatable>)
>>  C:\Python24\Lib\site-packages\zope\app\pagetemplate\viewpagetemplatefile.py line 51 in __call__
>>  => "sourceAnnotations=getattr(debug_flags, 'sourceAnnotations', 0),"
>>  ** exceptions.TypeError: ('Could not adapt', <Items at 0x3d7ce30>, <InterfaceClass zope.app.traversing.interfaces.IPhysicallyLocatable>)
>>  C:\Python24\Lib\site-packages\zope\pagetemplate\pagetemplate.py line 117 in pt_render
>>  => 'strictinsert=0, sourceAnnotations=sourceAnnotations)()'
>>  ** exceptions.TypeError: ('Could not adapt', <Items at 0x3d7ce30>, <InterfaceClass zope.app.traversing.interfaces.IPhysicallyLocatable>)
>>  C:\Python24\Lib\site-packages\zope\tal\talinterpreter.py line 277 in __call__
>>  => 'self.interpret(self.program)'
>>  ** exceptions.TypeError: ('Could not adapt', <Items at 0x3d7ce30>, <InterfaceClass zope.app.traversing.interfaces.IPhysicallyLocatable>)
>>  C:\Python24\Lib\site-packages\zope\tal\talinterpreter.py line 352 in interpret
>>  => 'handlers[opcode](self, args)'
>>  ** exceptions.TypeError: ('Could not adapt', <Items at 0x3d7ce30>, <InterfaceCla
>>  ss zope.app.traversing.interfaces.IPhysicallyLocatable>)
>>  C:\Python24\Lib\site-packages\zope\tal\talinterpreter.py line 878 in do_defineMacro
>>  => 'self.interpret(macro)'
>>  ** exceptions.TypeError: ('Could not adapt', <Items at 0x3d7ce30>, <InterfaceClass zope.app.traversing.interfaces.IPhysicallyLocatable>)
>>  C:\Python24\Lib\site-packages\zope\tal\talinterpreter.py line 352 in interpret
>>  => 'handlers[opcode](self, args)'
>>  ** exceptions.TypeError: ('Could not adapt', <Items at 0x3d7ce30>, <InterfaceClass zope.app.traversing.interfaces.IPhysicallyLocatable>)
>>  C:\Python24\Lib\site-packages\zope\tal\talinterpreter.py line 926 in do_extendMacro
>>  => 'definingName, extending)'
>>  ** exceptions.TypeError: ('Could not adapt', <Items at 0x3d7ce30>, <InterfaceClass zope.app.traversing.interfaces.IPhysicallyLocatable>)
>>  C:\Python24\Lib\site-packages\zope\tal\talinterpreter.py line 908 in do_useMacro
>>  => 'self.interpret(macro)'
>>  ** exceptions.TypeError: ('Could not adapt', <Items at 0x3d7ce30>, <InterfaceClass zope.app.traversing.interfaces.IPhysicallyLocatable>)
>>  C:\Python24\Lib\site-packages\zope\tal\talinterpreter.py line 352 in interpret
>>  => 'handlers[opcode](self, args)'
>>  ** exceptions.TypeError: ('Could not adapt', <Items at 0x3d7ce30>, <InterfaceClass zope.app.traversing.interfaces.IPhysicallyLocatable>)
>>  C:\Python24\Lib\site-packages\zope\tal\talinterpreter.py line 538 in do_optTag_tal
>>  => 'self.do_optTag(stuff)'
>>  ** exceptions.TypeError: ('Could not adapt', <Items at 0x3d7ce30>, <InterfaceClass zope.app.traversing.interfaces.IPhysicallyLocatable>)
>>  C:\Python24\Lib\site-packages\zope\tal\talinterpreter.py line 523 in do_optTag
>>  => 'return self.no_tag(start, program)'
>>  ** exceptions.TypeError: ('Could not adapt', <Items at 0x3d7ce30>, <InterfaceClass zope.app.traversing.interfaces.IPhysicallyLocatable>)
>>  C:\Python24\Lib\site-packages\zope\tal\talinterpreter.py line 518 in no_tag
>>  => 'self.interpret(program)'
>>  ** exceptions.TypeError: ('Could not adapt', <Items at 0x3d7ce30>, <InterfaceClass zope.app.traversing.interfaces.IPhysicallyLocatable>)
>>  C:\Python24\Lib\site-packages\zope\tal\talinterpreter.py line 352 in interpret
>>  => 'handlers[opcode](self, args)'
>>  ** exceptions.TypeError: ('Could not adapt', <Items at 0x3d7ce30>, <InterfaceClass zope.app.traversing.interfaces.IPhysicallyLocatable>)
>>  C:\Python24\Lib\site-packages\zope\tal\talinterpreter.py line 976 in do_defineSlot
>>  => 'self.interpret(block)'
>>  ** exceptions.TypeError: ('Could not adapt', <Items at 0x3d7ce30>, <InterfaceClass zope.app.traversing.interfaces.IPhysicallyLocatable>)
>>  C:\Python24\Lib\site-packages\zope\tal\talinterpreter.py line 352 in interpret
>>  => 'handlers[opcode](self, args)'
>>  ** exceptions.TypeError: ('Could not adapt', <Items at 0x3d7ce30>, <InterfaceClass zope.app.traversing.interfaces.IPhysicallyLocatable>)
>>  C:\Python24\Lib\site-packages\zope\tal\talinterpreter.py line 625 in do_insertText_tal
>>  => 'text = self.engine.evaluateText(stuff[0])'
>>  ** exceptions.TypeError: ('Could not adapt', <Items at 0x3d7ce30>, <InterfaceClass zope.app.traversing.interfaces.IPhysicallyLocatable>)
>>  C:\Python24\Lib\site-packages\zope\app\pagetemplate\engine.py line 101 in evaluateText
>>  => 'text = self.evaluate(expr)'
>>  ** exceptions.TypeError: ('Could not adapt', <Items at 0x3d7ce30>, <InterfaceClass zope.app.traversing.interfaces.IPhysicallyLocatable>)
>>  C:\Python24\Lib\site-packages\zope\tales\tales.py line 696 in evaluate
>>  => 'return expression(self)'
>>  ** exceptions.TypeError: ('Could not adapt', <Items at 0x3d7ce30>, <InterfaceClass zope.app.traversing.interfaces.IPhysicallyLocatable>)
>>  C:\Python24\Lib\site-packages\zope\tales\expressions.py line 249 in __call__
>>  => 'v = var(econtext)'
>>  ** exceptions.TypeError: ('Could not adapt', <Items at 0x3d7ce30>, <InterfaceClass zope.app.traversing.interfaces.IPhysicallyLocatable>)
>>  C:\Python24\Lib\site-packages\zope\tales\expressions.py line 205 in __call__
>>  => 'return self._eval(econtext)'
>>  ** exceptions.TypeError: ('Could not adapt', <Items at 0x3d7ce30>, <InterfaceClass zope.app.traversing.interfaces.IPhysicallyLocatable>)
>>  C:\Python24\Lib\site-packages\zope\tales\expressions.py line 199 in _eval
>>  => 'return ob()'
>>  ** exceptions.TypeError: ('Could not adapt', <Items at 0x3d7ce30>, <InterfaceClass zope.app.traversing.interfaces.IPhysicallyLocatable>)
>>  C:\Python24\Lib\site-packages\zope\app\pagetemplate\talesapi.py line 73 in title_or_name
>>  => "return getattr(self, 'title', '') or zapi.name(self.context)"
>>  ** exceptions.TypeError: ('Could not adapt', <Items at 0x3d7ce30>, <InterfaceClass zope.app.traversing.interfaces.IPhysicallyLocatable>)
>>  C:\Python24\Lib\site-packages\zope\app\traversing\api.py line 149 in getName
>>  => 'return IPhysicallyLocatable(obj).getName()'
>>  ** exceptions.TypeError: ('Could not adapt', <Items at 0x3d7ce30>, <InterfaceClass zope.app.traversing.interfaces.IPhysicallyLocatable>)
>>  C:\Python24\Lib\site-packages\zope\interface\interface.py line 682 in __call__
>>  => 'raise TypeError("Could not adapt", obj, self)'
>>  ** exceptions.TypeError: ('Could not adapt', <Items at 0x3d7ce30>, <InterfaceClass zope.app.traversing.interfaces.IPhysicallyLocatable>)
>>  127.0.0.1 - - [19/Apr/2006:16:13:32 +0200] "POST /netevenTest/test/neteven.Accounts.1/ HTTP/1.1" 200 163 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; fr-FR; rv:1.7.12) Gecko/20050919 Firefox/1.0.7"
>>  
>>  It seems that retrieving my object from code doesn't give me an address for it, which would cause the problem with IPhysicallyLocatable (my uninformed guess).
>>  Is there a way to solve the problem, knowing that my object is retrieved through sqlos, and thus has no true address ? There might be something else but being
>>  quite new to zope 3 (and enjoying it, thanks to you all guys), I can't figure it out.
>>   
> Maybe these questions will help.
> 
> What is an Items object? 
> Why are you calling a page template that needs title_or_name with an 
> Items object as the context?
> 
> -Jim Washington


-- 

---------------------------------------------------
Jürgen Kartnaller   mailto:juergen_at_kartnaller.at
                    http://www.kartnaller.at
                    http://www.mcb-bregenz.at
---------------------------------------------------



More information about the Zope3-users mailing list