Esos ejemplos ya los había visto, lo que hacen básicamente es utilizar la
raíz del sitio Plone como context, pero eso no me sirve. Necesito que el
context sea el padre del objeto que estoy editando ya que es este padre, y
no otro, el contiene unos datos relevantes para construir el vocabulario.


2014-03-06 10:18 GMT+01:00 Ruben Hidalgo [via Usarios Plone] <
[email protected]>:

> Debes definir el contexto en particular.
>
> Mirate estos dos ejemplos:
>  - http://developer.plone.org/forms/vocabularies.html#dynamic-vocabularies
>     * usa ISiteRoot
>  -
> https://github.com/collective/plone.contentratings/blob/master/plone/contentratings/vocabs.py#L18
>     * usa getSite
>
> un saludo,
>
> Rubén
>
>
>
> 2014-03-06 9:43 GMT+01:00 oggers <[hidden 
> email]<http://user/SendEmail.jtp?type=node&node=7572679&i=0>
> >:
>
>> Hola gente,
>>
>> Tengo el siguiente problema que creo que debería de estar resuelto, pero
>> no
>> encuentro la forma:
>>
>> Tengo un contenido creado con Dexterity en el cual he definido un campo
>> Dict:
>>
>> field = schema.Dict(
>>     title=_(u"Field"),
>>     key_type=schema.Choice(
>>         source=PossibleOptions()
>>     ),
>>     value_type=schema.Decimal()
>> )
>>
>> La definición del source es:
>>
>> class PossibleOptions(object):
>>     grok.implements(IContextSourceBinder)
>>
>>     def __call__(self, context):
>>         terms = []
>>
>>         # at this point context is None and therefore raises
>>         # an exception
>>         go = context.items()
>>         if go:
>>             for option in go.options():
>>                 terms.append(SimpleVocabulary.createTerm(
>>                     IUUID(option),
>>                     IUUID(option), option.title.encode('utf-8')))
>>
>>         return SimpleVocabulary(terms)
>>
>>
>> El problema es que el context que se pasa al __call__ del vocabulario es
>> None, por lo que el vocabulario falla.
>>
>> Alguien tiene alguna idea al respecto?
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://usarios-plone.2295514.n2.nabble.com/context-es-None-en-un-vocabulario-para-schema-Dict-tp7572678.html
>> Sent from the Usarios Plone mailing list archive at Nabble.com.
>> _______________________________________________
>> Usuarios-Plone mailing list
>> [hidden email] <http://user/SendEmail.jtp?type=node&node=7572679&i=1>
>> https://lists.plone.org/mailman/listinfo/plone-usuarios-plone
>>
>
>
> _______________________________________________
> Usuarios-Plone mailing list
> [hidden email] <http://user/SendEmail.jtp?type=node&node=7572679&i=2>
> https://lists.plone.org/mailman/listinfo/plone-usuarios-plone
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://usarios-plone.2295514.n2.nabble.com/context-es-None-en-un-vocabulario-para-schema-Dict-tp7572678p7572679.html
>  To unsubscribe from context es None en un vocabulario para schema.Dict, click
> here<http://usarios-plone.2295514.n2.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=7572678&code=b2dnZXJzQGdtYWlsLmNvbXw3NTcyNjc4fC0xNDk3NjQyODYw>
> .
> NAML<http://usarios-plone.2295514.n2.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>



-- 
Juan Carlos Coruña: Python, Zope, Plone, Navision.
http://oggers-blog.blogspot.com




--
View this message in context: 
http://usarios-plone.2295514.n2.nabble.com/context-es-None-en-un-vocabulario-para-schema-Dict-tp7572678p7572680.html
Sent from the Usarios Plone mailing list archive at Nabble.com.
_______________________________________________
Usuarios-Plone mailing list
[email protected]
https://lists.plone.org/mailman/listinfo/plone-usuarios-plone

Responder a