Edgewall Software
Modify

Opened 9 years ago

Last modified 8 years ago

#10059 new defect

prop.rendered not properly set in browser.html

Reported by: anonymous Owned by:
Priority: normal Milestone: next-major-releases
Component: version control/browser Version: 0.12.2
Severity: normal Keywords: wikiproperties
Cc: Branch:
Release Notes:
API Changes:

Description

Hi,

despite having the wiki_properties set to a property that is rendered correctly as wiki syntax, the prop.rendered in browser.html is not set. This causes everything to be displayed not in the py:when case of a span and a div.

Attachments (0)

Change History (5)

comment:1 by anonymous, 9 years ago

I am not quite sure, but it seems that in WikiPropertyRendered when I set in the function render_property this code in the if case:

value = format_to_html(self.env, context, props[name]) return RenderedProperty(name=name,content=value)

then everything is fine… maybe there are also other places where it has been set in a wrong way? maybe also the oneliner case should return that?

comment:2 by Remy Blank, 9 years ago

Mmh… I'm afraid I don't understand what this is about. Would you mind explaining in a bit more detail, and giving a bit more context? Thanks.

comment:3 by Christian Boos, 9 years ago

Component: generalversion control/browser

Well, it seems to work for me:

  • what is the name of the property you're using?
  • what is the value of your [browser] wiki_properties?

Also, are you sure you're using the correct browser.html template? (TracUpgrade#CustomizedTemplates)

comment:4 by anonymous, 9 years ago

The relevant part from browser.html (I have freshly installed a 0.12.2) is:

the property is naemd trac:description and is contained in the wiki_properties setting (and it also is correctly rendered as wiki syntax, however not in the span+div where it should be)

        <tr py:if="properties">
          <td colspan="2">
            <ul class="props">
              <py:def function="prop_value(prop)">
                <py:choose>
                  <py:when test="istext(prop.value)"><em><code>$prop.value</code></em></py:when>
                  <py:otherwise>$prop.value</py:otherwise>
                </py:choose>
              </py:def>
              <li py:for="prop in properties" py:choose="">
                <py:when test="prop.rendered">
                   <span py:if="prop.rendered.name"
                         py:attrs="prop.rendered.name_attributes" py:content="prop.rendered.name" />
                   <div py:attrs="prop.rendered.content_attributes" py:content="prop.rendered.content" />
                </py:when>
                <py:otherwise>
                  <i18n:msg params="name, value">Property <strong>$prop.name</strong> set to ${prop_value(prop)}</i18n:msg>
                </py:otherwise>
              </li>
            </ul>
          </td>
        </tr>

If I understand this correct, the li item is output as a span + div when prop.rendered is populated. However it is not populated here, causing the html output to be:

<li>
                  Property <strong>trac:description</strong> set to
                  <p>
Test description property should be rendered in wiki syntax
</p>
<ul><li>top 1

<strong> tops2
</strong></li></ul>
              </li><li>

for me. I think is is caused by browser.py having the function

     def render_property(self, name, mode, context, props):
         if name in self.wiki_properties:                 
             return format_to_html(self.env, context, props[name])
         else:                                                   
             return format_to_oneliner(self.env, context, props[name]) 

I think this function should return a RenderedProperty because only in that case the render_property method of class BrowserModule sets prop.rendered :

                 rendered = renderer.render_property(name, mode, context, props)
                 if not rendered:
                     return rendered
                 if isinstance(rendered, RenderedProperty):
                     value = rendered.content
                 else:
                     value = rendered
                     rendered = None

So I think this function should be like:

     def render_property(self, name, mode, context, props):      
         if name in self.wiki_properties:                       
             value = format_to_html(self.env, context, props[name])
             return RenderedProperty(name=name,content=value)     
         else:                                                   
             return format_to_oneliner(self.env, context, props[name])  

or probably even return a RenderedProperty in the else case. Otherwise it is not possible to distinguish between normal properties, and properties that have been rendered as wiki markup in the browser.html template.

Here is the html that is returned after doing this change on my side:

<li>

                   <span>trac:description</span>
                   <div><p>
Test description property should be rendered in wiki syntax
</p>
<ul><li>top 1
<strong> tops2
</strong></li></ul></div>

As you can see, this now does the span+div for the property that the browser.html is doing when the property is rendered…

comment:5 by Christian Boos, 8 years ago

Keywords: wikiproperties added
Milestone: next-major-0.1X

Ok, see what you mean now. Thanks for the details!

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The ticket will remain with no owner.
The ticket will be disowned. Next status will be 'new'.
as The resolution will be set. Next status will be 'closed'.
The owner will be changed from (none) to anonymous. Next status will be 'assigned'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.