What I want is to have a document for every member of the directory members,
this document should have mirrors for some fields of members entries.
It's something like a wrapper so that users can modify their own directory
entries directly from that document, without having to go to directories.
The identifier of the document is the same as the identifier of the user, and
the document is created in the member's directory just after the first login.
In the schema of that type of content I have a field "surname" which should be
a mirror of "sn" field in members directory entries.
For that field I checked R/W ignore storage. The value of "Write: expression"
is:
python:util.setEntryField('members', 'sn', data[field.getFieldId()],
object.aq_parent.getId())
Where setEntryField is:
{{{
def setEntryField(self, dir_id, field_id, value, entry_id):
""" Update the field 'field_id' of the entry with 'entry_id' identifier
so that its value has 'value' as content.
"""
dtool = getToolByName(self, 'portal_directories')
dir = dtool[dir_id]
new_entry = {dir.id_field: entry_id,
field_id: value,
}
entry = dir._editEntry(new_entry)
}}}
The value of "Read: expression" is:
python:portal.portal_directories.members[context.aq_parent.getId()].sn
Where context.aq_parent.getId() is the identifier of the current document (i.e.
the identifier of a member)
This solution works fine for documents that have already been created, but it's
not good when documents are being created, as context is None.
I'm gonna try the advices of Yves. But, why the R/W expressions are called in
content creation? I though they would be used in view or edit modes only.
Thank you very much.
JoseLuis de la Rosa Triviño
Becario Área de Sistemas de Información
FUNDACIÓN IAVANTE
[EMAIL PROTECTED]
Tel. 951 015 300
Este correo electrónico y, en su caso, cualquier fichero anexo, contiene
información confidencial exclusivamente dirigida a su(s) destinatario(s). Toda
copia o divulgación deberá ser autorizada por IAVANTE.
This e-mail and any attachments are confidential and exclusively directed to
its adressee(s). Any copy or distribution will have to be authorized by IAVANTE.
-----Mensaje original-----
De: Florent Guillaume [mailto:[EMAIL PROTECTED]
Enviado el: jueves, 15 de junio de 2006 16:14
Para: JoseLuis de la Rosa Triviño
CC: List CPS-devel
Asunto: Re: [CPS-devel] Re: context not available in read expression
forcreation of documents
You haven't told us what you want to *do*.
What's context.aq_parent.getId() supposed to do?
Florent
On 15 Jun 2006, at 13:18, JoseLuis de la Rosa Triviño wrote:
> I modified the expression to
>
> {{{python:portal.portal_directories.members[context.aq_parent.getId
> ()].center}}}
>
> I have problems to get the folder where this content was just
> created in. For this statement context.aq_parent.getId(), context
> is None. Even object and proxy are None too.
>
> I've also tried to create a new field "id" in the same schema to
> set it (when the content is created) to the value I need. In that
> case, the statement would look like this
>
> {{{python:portal.portal_directories.members[id].center}}}
>
> but even here id is None.
>
> This expression is assessed in the same transaction that the
> content is created, may that be a problem?
>
> Thank you very much.
>
> JoseLuis de la Rosa Triviño
> Becario Área de Sistemas de Información
> FUNDACIÓN IAVANTE
> [EMAIL PROTECTED]
> Tel. 951 015 300
>
>
> Este correo electrónico y, en su caso, cualquier fichero anexo,
> contiene información confidencial exclusivamente dirigida a su(s)
> destinatario(s). Toda copia o divulgación deberá ser autorizada por
> IAVANTE.
>
> This e-mail and any attachments are confidential and exclusively
> directed to its adressee(s). Any copy or distribution will have to
> be authorized by IAVANTE.
>
>
>
> -----Mensaje original-----
> De: Florent Guillaume [mailto:[EMAIL PROTECTED]
> Enviado el: jueves, 15 de junio de 2006 1:10
> Para: List CPS-devel
> Asunto: Re: [CPS-devel] Re: context not available in read
> expression forcreation of documents
>
>
> On 14 Jun 2006, at 21:08, Yves Bastide wrote:
>
>> JoseLuis de la Rosa Triviño wrote:
>>> I'm using this expression
>>> {{{python:context.portal_directories.members
>>> [context.aq_parent.getId()].center}}} as "Read: Expression" for a
>>> schema field. It works fine when the document is already created,
>>> but when I create a new content an exception is raised because
>>> context is None and it can't get portal_directories.
>> [...]
>>> The question is: what can I use instead of context to get that
>>> field from members entry?
>>
>> What's your expression returning? Can it use user? The namespace
>> is defined in CPSSchemas.Field._createStorageExpressionContext, I
>> think.
>>
>
> And documented in CPSShemas/doc/fields.txt (maybe not completely up
> to date).
>
> Florent
>
> --
> Florent Guillaume, Nuxeo (Paris, France) Director of R&D
> +33 1 40 33 71 59 http://nuxeo.com [EMAIL PROTECTED]
>
>
>
> _______________________________________________
> cps-devel mailing list
> http://lists.nuxeo.com/mailman/listinfo/cps-devel
--
Florent Guillaume, Nuxeo (Paris, France) Director of R&D
+33 1 40 33 71 59 http://nuxeo.com [EMAIL PROTECTED]
_______________________________________________
cps-devel mailing list
http://lists.nuxeo.com/mailman/listinfo/cps-devel