Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #409 (closed defect: fixed)

Opened 13 years ago

Last modified 12 years ago

Kid's formatting puts blank space in a textarea

Reported by: kevin Owned by: anonymous
Priority: normal Milestone: 1.5
Component: Kid Version:
Severity: normal Keywords: develix
Cc:

Description (last modified by jorge.vargas) (diff)

I believe there is a ticket in the Kid trac for this as well, but I wanted to highlight the problem here. The solution to this likely involves a change to the HTMLSerializer.

please see  http://kid.lesscode.org/trac/ticket/144

Attachments

textarea-demo.tar.gz Download (16.8 KB) - added by rob@… 13 years ago.
Quickstarted project demoing broken textareas with xHTML output in 0.9a4

Change History

comment:1 Changed 13 years ago by kevin

  • Description modified (diff)

comment:2 Changed 13 years ago by oavtal@…

Could you be reffering to the problem fixed in this changeset and bug?  http://lesscode.org/projects/kid/ticket/83  http://lesscode.org/projects/kid/changeset/208

The textarea's closing tag was indented as the opening tag, but textarea's are sensitive to the whitespace inside them. This is no longer the case.

comment:3 Changed 13 years ago by oavtal@…

  • Status changed from new to closed
  • Resolution set to worksforme

And to be more specific, the fix was included in Kid 0.8, which is already part of turbogears - before this ticket was opened.

I tested it with the wiki20 tutorial and that pesky whitespace is no longer included in empty <textarea>'s.

comment:4 Changed 13 years ago by kevin

  • Status changed from closed to reopened
  • Resolution worksforme deleted

It appears to be only partially fixed. Here's a stripped down sample of using turbogears.widgets.TextArea? (without any of the surrounding widgets code)

In [20]:template = """
   ....:    <div xmlns:py="http://purl.org/kid/ns#" py:strip="True">
   ....:        <textarea name="${widget.name}" id="${widget.name}" class="textarea_field" py:attrs="widget.attrs">${widget_value}</textarea>
   ....:        <span class="field_error" py:if="widget_error">${str(widget_error)}</span>
   ....:        </div>
   ....:        """

In [22]:t = kid.Template(template)

In [23]:class Thing:    
   ....:    name = "foo"
   ....:    attrs = {}
   ....:    
   ....:    

In [24]:t.widget = Thing()

In [25]:t.widget_value = ""

In [26]:t.widget_error = None

In [27]:t.serialize(output="html")
Out[27]:'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">\n\n    <TEXTAREA CLASS="textarea_field" NAME="foo" ID="foo">\n    </TEXTAREA>'

comment:5 Changed 13 years ago by kevin

Here's a shorter example that uses the widget directly:

In [1]:from turbogears import widgets

In [2]:w = widgets.TextArea()

In [3]:w.render("")
Out[3]:'\n    <TEXTAREA CLASS="textarea_field" NAME="widget" ID="widget">\n    </TEXTAREA>'

comment:6 Changed 13 years ago by kevin

  • Status changed from reopened to closed
  • Resolution set to fixed

Ori Avtalion tracked this down to a place where there were tabs instead of spaces (!). I converted the tabs to spaces and all seems well.

comment:7 Changed 13 years ago by anonymous

Can anyone confirm, that it works also with xhtml output?

comment:8 Changed 13 years ago by rob@…

  • Status changed from closed to reopened
  • Resolution fixed deleted

I can confirm that it DOES NOT work with xHTML output.

Bug still exhibiting in 0.9a2.

Any patches? I kinda need to fix this :-)

<tr>
                <th>
                    <label class="fieldlabel" for="form_copy">Copy</label>
                </th>
                <td>

                    <textarea id="form_copy" rows="7" cols="50" name="copy" class="textarea requiredfield">
                    </textarea>
                    
                    
                </td>
            </tr>

Changed 13 years ago by rob@…

Quickstarted project demoing broken textareas with xHTML output in 0.9a4

comment:9 Changed 13 years ago by rob@…

As requested I have attached a quickstarted project demoing broken textareas. I don't know how to diff two directories, so this is what I did:

  1. Changed config/app.cfg to set xHTML output:

kid.outputformat="xhtml"

  1. Added a test form to controllers.py:
rob@ubuntu:~/textarea-demo/textareademo$ cat controllers.py
import cherrypy
import turbogears
from turbogears import controllers, expose, redirect
from turbogears import identity
from turbogears.widgets import *

class TestForm(WidgetsList):
        ta = TextArea(label="Me broken:")

class Root(controllers.RootController):
    @expose(template="textareademo.templates.welcome")
    def index(self):
        form = TableForm(fields=TestForm(), submit_text="Don't click me")
        return dict(form=form)
  1. Changed templates/welcome.kid to display the form:
rob@ubuntu:~/textarea-demo/textareademo$ cat templates/welcome.kid 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#"
    py:extends="'master.kid'">

<head>
    <meta content="text/html; charset=UTF-8" http-equiv="content-type" py:replace="''"/>
    <title>Welcome to TurboGears</title>
</head>

<body>
    <p>Me broken:</p>
    <div py:replace="form(action='/something')"></div>
</body>
</html>
rob@ubuntu:~/textarea-demo/textareademo$

And the xHTML output is:

    <form action="/something" method="post" class="tableform" name="form">
        
        <table cellpadding="2" cellspacing="0" border="0">

            <tr class="even">
                <th>
                    <label class="fieldlabel" for="form_ta">Me broken:</label>
                </th>
                <td>
                    <textarea id="form_ta" rows="7" cols="50" name="ta" class="textarea">
                    </textarea>
                    
                    
                </td>
            </tr>

            <tr>
                <td> </td>
                <td>
                <input type="submit" class="submitbutton" value="Don't click me">
                </input>
                </td>
            </tr>
        </table>

    </form>

comment:10 Changed 13 years ago by salty-horse

OK, this is easy to fix but ugly: In turbogears/widgets/forms.py, the TextArea? template should include xmlns="http://www.w3.org/1999/xhtml".

This is nessecary because treats uses different namespaces for HTML and XHTML, and kid's serialization.py uses namespaces to catch the TEXTAREA spacing problems. (Perhaps other 'special' elements have the same problem!)

The reason I think this is because the xmlns="" string appears in the output.

So, this requires committing. I tested it with kid's html and xhtml output. works both cases. (prints out the xmlns only in the xhtml output mode)

I think the xmlns issue is worth bringing up to the Kid developers.

comment:11 Changed 13 years ago by rob@…

I can confirm this works, but as you said, ugly. Tag appears with the xmlns attribute. I would classify this as more of a workaround than a fix, but yes it defintiely needs committing until a real fix is available in Kid. Surely specifying output as "xhtml" should imply xmlns=" http://www.w3.org/1999/xhtml" in Kid?

Thanks for your help :-)

-Rob

comment:12 Changed 13 years ago by michele

salty-horse, can you open a ticket on the kid trac with the description of the issue you've found?

comment:13 Changed 13 years ago by dstanek

I have mixed feelings about how Kid would need to change. If fragments are no longer required to have namespaces we would have to have a default. This could be as simple as saying the default is the containing document's namespace. But this imposes two restrictions: you cannot use the fragment as a full document and processing specific to a namespace cannot be done at compile time.

If the concern is simply the xmlns attribute in the output then the problem is easier to solve. Kid should be able to not output the default namespace on fragments if the container document has the same default namespace.

What is the real issue that we are looking to solve in Kid?

comment:14 Changed 13 years ago by salty-horse

comment:15 Changed 13 years ago by jorge.vargas

  • Milestone changed from 0.9 to 1.0

comment:16 Changed 13 years ago by jorge.vargas

  • Description modified (diff)

comment:17 Changed 13 years ago by salty-horse

According to  kid ticket #114, there is no longer need to specify the xmlns namespace in the TextArea? template (and many other widgets).

I have not tested it.

Please close this bug when turbogears uses the Kid version with this fix.

comment:18 Changed 12 years ago by alberto

  • Milestone changed from 1.0 to 1.1

comment:19 Changed 12 years ago by jorge.vargas

  • Status changed from reopened to closed
  • Resolution set to fixed

kid's ticket was commited in 0.9.4

Note: See TracTickets for help on using tickets.