Kátia,
antes de fazer esse script vc fez o mapeamento da propriedade fullname com o 
campo cn do AD?
fazendo esse mapeamento, o nome completo é preenchido automaticamente e vc não 
precisa fazer alteração no comentario.

Para fazer o mapeamento acesse:
seu plugin AD (provavelmente é AD-SF) -> contents -> acl_users -> LDAP Schema
- no campo "LDAP Attribute Name" vc adiciona o campo do nome completo do 
usuario no AD, provavelmente é o campo "CN". No meu caso, eu preencho esse 
campo com "Name"
- no campo "Map to Name (optional)" vc coloca "fullname"
- no campo "Friendly Name" vc coloca o que quiser.
- clica em Add

pronto, com esse mapeamento feito, aparecerá o nome completo nos comentários e 
nas informações de quem criou os objetos.

Espero que funcione para vc, pois pra mim funciona.

Abraços

PH



  ----- Original Message ----- 
  From: F.katia 
  To: zope-pt@yahoogrupos.com.br 
  Sent: Wednesday, February 17, 2010 5:04 PM
  Subject: Re: Res: [zope-pt] Alteração no Comentário


    
  Resumindo o que foi feito
  Foi editado o template viewThreadsAtBottom que é responsável pelo layout dos 
comentários nas noticias..

  ele se encontra no /portal_skins/plone_templates/viewThreadsAtBottom

  Na Div "documentByLine", que é responsável pela exibição do nome do usuário 
que criou o comentário.

  Foram substituidas 2 linhas do código abaixo

  mi python:not anonymous_creator and mtool.getMemberInfo(creator);

  fullname python: mi and mi['fullname'] or creator;" >

  por esta linha:

  fullname python:container['fullname.py'](username = creator);" >

  Essa nova linha chamará o método "fullname.py" enviando como parâmetro o id 
do usuário, e este método retornará o nome completo do usuário.

  "fullname.py" :

  '''Pesquisa no AD se existe um usuário com o login fornecido e

  retorna o nome completo. Não esqueca de acrescentar o parâmetro "username"'''

  nome_completo = None

  if username is not None:

  user_folder = context.acl_users['AD-SF'].acl_users

  usuario = user_folder.getUserById(username)

  if usuario is not None:

  nome_completo = usuario.cn

  return nome_completo

  Após, você deve setar a role MANAGER na aba PROXY DO SCRIPT fullname.py, para 
que não haja problemas de privilégios para o usuário comum. 

  =)

  --- Em zope-pt@yahoogrupos.com.br, "F.katia" <fkat...@...> escreveu
  >
  > Olá Jeferson,
  > 
  > 
  > Essa alteração criou um novo campo no formulário, o nome que você disse.. =)
  > Mas não modificou o login pelo nome de quem enviou o comentário.
  > Então o Lucas Aquino também me deu uma ajudinha, então vou repassar..
  > 
  > 
  > Ele me informou o nome tem que estar preenchido se não ela pega o ID, e no 
meu caso os usuários não tem esse campo preenchido.
  > 
  > Obrigada pela ajuda
  > 
  > =)
  > 
  > 
  > -- Em zope-pt@yahoogrupos.com.br, "Jeferson Lelis C. dos Santos" 
<jeferlelis@> escreveu
  > >
  > > Olá,
  > > 
  > > se não me engano existe um campo no discussion_reply_ form:
  > > 
  > > <input type="hidden" name="Creator" value=""
  > > tal:attributes="value member/getUserName" />
  > > 
  > > altera por este:
  > > <input name="Creator" id="Creator" value="" tal:attributes="value 
request/Creator|request/title_override|nothing;" />
  > > 
  > > Ai o usuário tera que preencher o campo com seu nome. Desta forma ele 
estará pegando o nome da pessoa que está comentando.
  > > 
  > > Se for da forma que entendi funcionará.
  > > 
  > > Atenciosamente, 
  > > 
  > > Jeferson Lelis.
  > > 
  > > 
  > > 
  > > 
  > > ________________________________
  > > De: F.katia <fkatiag@>
  > > Para: zope-pt@yahoogrupos.com.br
  > > Enviadas: Segunda-feira, 1 de Fevereiro de 2010 16:34:10
  > > Assunto: [zope-pt] Alteração no Comentário 
  > > 
  > > 
  > > Boa tarde, 
  > > Trabalho na Intranet Senado e Prodasen e preciso alterar o comentário do 
Plone, em vez de aparecer o login gostaria que aparecesse o nome de que fez o 
comentário.
  > > Fui ao template discussion_reply_ form e troquei o fullname pelo 
displayName porém essa troca não funcionou.
  > > Alguém poderia me auxiliar?
  > > 
  > > Utilizo o Plone 2.5.5, Zope (Zope 2.9.9-final, python 2.4.5)
  > > 
  > > Codigo fonte do discussion_reply_ form
  > > <html xmlns:tal="http://xml.zope. org/namespaces/ tal"
  > > xmlns:metal= "http://xml.zope. org/namespaces/ metal"
  > > metal:use-macro= "here/main_ template/ macros/master"
  > > i18n:domain= "plone">
  > > 
  > > 
  > > <body>
  > > 
  > > <metal:block fill-slot="top_ slot"
  > > tal:define=" dummy python:request. set('disable_ border',1) " />
  > > 
  > > <metal:block fill-slot="sub" />
  > > 
  > > <div metal:fill-slot= "main"
  > > tal:define=" errors options/state/ getErrors;
  > > thread python:putils. getDiscussionThr ead(here) ;
  > > discussable python:thread[ 0];
  > > replies python:thread[ 1:]">
  > > 
  > > <tal:discussable define="template python:getattr( here, discussable. 
getLayout( ), None);
  > > macros template/macros | nothing;
  > > main_macro macros/main | nothing;
  > > showDiscussable python:main_ macro;
  > > template template_id"
  > > >
  > > 
  > > <div class="comment" 
  > > tal:condition= "showDiscussable "
  > > tal:define=" here python:discussable" >
  > > <div metal:use-macro= "main_macro" />
  > > </div>
  > > </tal:discussable>
  > > 
  > > <tal:thread tal:repeat=" reply replies">
  > > <tal:block tal:define=" level repeat/reply/ index">
  > > <div class="comment"
  > > tal:attributes= "style python:'margin- left:'+str( (int(level) 
+1)*2)+'em' ">
  > > <h3>
  > > <tal:block replace="structure portal/discussionit em_icon.gif" />
  > > <span tal:replace= "reply/pretty_ title_or_ id">Comment title</span>
  > > </h3>
  > > <div class="documentByLi ne"
  > > tal:define=" creator reply/Creator;
  > > anonymous_creator python:creator= ='Anonymous User';
  > > mi python:not anonymous_creator and mtool.getMemberInfo (creator) ;
  > > fullname python: mi and mi['fullname' ] or creator;" >
  > > <span i18n:translate= "label_comment_ by">Posted by</span>
  > > <span tal:content= "fullname"
  > > tal:condition= "not:anonymous_ creator"> Poster Name</span>
  > > <span i18n:translate= "label_anonymous _user"
  > > tal:condition= "anonymous_ creator"> Anonymous User</span>
  > > <span i18n:translate= "label_commented _at">at</ span> 
  > > <span tal:replace= "python:toLocali zedTime(reply. ModificationDate (),
  > > long_format= 1)">8/23/ 2001 12:40:44 PM</span>
  > > </div>
  > > <div class="commentBody"
  > > tal:content= "structure reply/CookedBody" >
  > > This is the body text of the comment.
  > > </div>
  > > </div> 
  > > 
  > > </tal:block>
  > > </tal:thread>
  > > 
  > > <form name="edit_form"
  > > method="post"
  > > action="talkback"
  > > tal:attributes= "action string:$here_ url/$template_ id">
  > > 
  > > <fieldset>
  > > 
  > > <legend i18n:translate= "legend_add_ comment"> Add comment</legend>
  > > <p i18n:translate= "description_ add_comment" >
  > > You can add a comment by filling out the form below. Plain text
  > > formatting.
  > > </p>
  > > 
  > > <input type="hidden" name="Creator" value=""
  > > tal:attributes= "value member/getUserName" />
  > > 
  > > <div class="portalMessag e"
  > > tal:condition= "isAnon">
  > > 
  > > <tal:block replace="structure here/info.gif" />
  > > 
  > > <p i18n:translate= "legend_note_ reply_anonymous" >
  > > Note: you are not logged in. You may optionally enter your
  > > username and password below. If you don't enter your
  > > username and password below, this comment will be posted as
  > > the 'Anonymous User'.
  > > </p>
  > > 
  > > <div class="field" >
  > > 
  > > <label for="username" i18n:translate= "label_name" >Name</label>
  > > 
  > > <input name="username"
  > > id="username"
  > > value="" alt="Username" title="Name"
  > > size="40"
  > > tabindex=""
  > > i18n:attributes= "title label_name; alt label_username; "
  > > tal:attributes= "tabindex tabindex/next; " />
  > > 
  > > </div>
  > > 
  > > <div class="field" >
  > > 
  > > <label for="password" i18n:translate= "label_password" >Password< /label>
  > > 
  > > <input type="password"
  > > id="password"
  > > name="password"
  > > tabindex=""
  > > value="" alt="Password" title="Password"
  > > size="40"
  > > i18n:attributes= "title label_password; alt label_password; "
  > > tal:attributes= "tabindex tabindex/next; " />
  > > 
  > > </div>
  > > 
  > > </div>
  > > 
  > > <div class="field"
  > > tal:define=" error errors/subject| nothing;"
  > > tal:attributes= "class python:test( error, 'field error', 'field')">
  > > 
  > > <label for="subject" i18n:translate= "label_subject" >Subject< /label>
  > > 
  > > <span class="fieldRequire d" title="Required"
  > > i18n:attributes= "title title_required; "
  > > i18n:translate= "label_required" >(Required) </span>
  > > 
  > > <div tal:content= "error">Validati on error output</div>
  > > 
  > > <input name="subject"
  > > id="subject"
  > > value=""
  > > size="40"
  > > tabindex=""
  > > tal:attributes= "value request/subject| request/title_ override| nothing;
  > > tabindex tabindex/next" />
  > > 
  > > </div>
  > > 
  > > <div class="field"
  > > tal:define=" error errors/body_ text|nothing; "
  > > tal:attributes= "class python:test( error, 'field error', 'field')">
  > > 
  > > <label for="body_text" i18n:translate= "label_comment" >Comment< /label>
  > > 
  > > <span class="fieldRequire d" title="Required"
  > > i18n:attributes= "title title_required; "
  > > i18n:translate= "label_required" >(Required) </span>
  > > 
  > > <div tal:content= "error">Validati on error output</div>
  > > 
  > > <textarea name="body_text"
  > > id="body_text"
  > > cols="40"
  > > rows="8"
  > > maxlength="1500" 
  > > onkeyup="return ismaxlength( this)"
  > > tabindex="" 
  > > tal:content= "request/ body_text| request/text_ override | nothing"
  > > tal:attributes= "tabindex tabindex/next" 
  > > ></textarea>
  > > 
  > > </div>
  > > 
  > > <div class="formControls ">
  > > 
  > > <input class="context"
  > > tabindex=""
  > > type="submit"
  > > value="Save"
  > > name="form.button. Save"
  > > i18n:attributes= "value label_save;"
  > > tal:attributes= "tabindex tabindex/next;
  > > name string:discussion_ reply:method; " />
  > > 
  > > </div>
  > > <input type="hidden" name="form.submitte d" value="1" />
  > > 
  > > </fieldset>
  > > 
  > > </form>
  > > 
  > > </div>
  > > 
  > > </body>
  > > </html>
  > > 
  > > 
  > > 
  > > 
  > > 
  > > __________________________________________________________
  > > Veja quais são os assuntos do momento no Yahoo! +Buscados
  > > http://br.maisbuscados.yahoo.com
  > >
  >



  

Responder a