Maybe, I've found the culprit:

============== archetypes.schemaextender/usage.txt

This will not show up in the schema yet:

 >>> schema = taggable_doc.Schema()
 >>> 'schemaextender_test_tags' in schema
     False
 >>> 'schemaextender_test_highlighted' in schema
     False

But look!

 >>> zope.component.provideAdapter(TaggingSchemaExtender,
     ...                               
name=u"archetypes.schemaextender.tests")

 >>> self.clearSchemaCache()
 >>> schema = taggable_doc.Schema()
 >>> 'schemaextender_test_tags' in schema
     True
 >>> 'schemaextender_test_highlighted' in schema
     True

Please note that as long as we don't use a testbrowser, thereby triggering
new requests, the schema cache needs to be cleared explicitly in order to
make the test work as intended.  On a real instance, caching per request
shouldn't pose a problem, though.

==============

That would explain why doing a new "request" works, even if the detail 
are not clear to me...


Il 12/07/2010 09:02, Yuri ha scritto:
> Il 09/07/2010 18:12, cewing ha scritto:
>    
>> Yuri-11 wrote:
>>
>>      
>>> I can access the Schema of ris, but it misses the docid attribute, so I
>>> cannot get the field, the mutator or anything else. The funny thing is
>>> that If I run a similar script after this, I can take the schema with
>>> all the fields and have also the 'docid' field.
>>>
>>> Any idea? Is a problem of external methods, should I use a browser view?
>>>
>>>
>>>        
>> Read this thread:
>>
>> http://plone.293351.n2.nabble.com/Accessors-for-SchemaExtender-fields-in-BrowserViews-td4610706.html
>>
>> Sounds a lot like your problem.
>>
>> c
>>
>>
>>      
> I've already tried this, but don't works...
>
> It works ONLY if you create the object then you call the methods:
>
> browser.pt:
>
> <span tal:content="view/importa"  />
> <span tal:content="view/finisci" />
>
>
> browser.py:
>
>       def importa(self):
>           """ importa le risore metalib """
>           for i in docs:
>             iden = str(i)
>             _createObjectByType('Document', self.context, iden)
>             ris = self.context[iden]
>             ris.setTitle(iden)
>             ris.processForm()
>             ris.reindexObject()
>             subtype = 'ultradoc'
>             subtyper = getUtility(ISubtyper)
>             subtyper.change_type(ris,subtype)
>
>       def finisci(self):
>           """ end it!! """
>           for o in self.context.objectValues():
>             schema = o.Schema()
>             campo = schema['docid']
>             if campo == None:
>               return 'nothing!'
>             else:
>               campo.getMutator(o)(o.id)
>               o.reindexObject()
>
> If you do "finisci" in "importa", the schemaextender "docid" field is
> not found (I call the browser view over a folder, first to create N
> objects, then fill the docid field with the id of the object).
> _______________________________________________
> Product-Developers mailing list
> [email protected]
> http://lists.plone.org/mailman/listinfo/product-developers
>    

_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers

Reply via email to