Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
kid questions.
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  12 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Fred C  
View profile  
 More options Jun 11 2006, 8:59 am
From: Fred C <bsdh...@gmail.com>
Date: Sun, 11 Jun 2006 08:59:05 -0400
Local: Sun, Jun 11 2006 8:59 am
Subject: kid questions.

Hello,

In my kid template I have this following line:  <div  
class="reviewitem" py:content="XML(review.Content)" />.
My problem is when the XML() argument is not a very clean html  
string, XML fail miserably.
How can I manage to roughly clean that string (in the template) or at  
least return the string not formated, instead of having an exception  
thrown.

Thanks

-fred-


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Ramm  
View profile  
 More options Jun 11 2006, 10:54 am
From: "Mark Ramm" <mark.mchristen...@gmail.com>
Date: Sun, 11 Jun 2006 10:54:30 -0400
Local: Sun, Jun 11 2006 10:54 am
Subject: Re: [TurboGears] kid questions.
You could put an ajax call on your page, retrieve that string through
an seprate request and then render your string using innerHTML from
javascript.

But if the HTML isn't valid, you may have trouble rendering it no
matter what you do.

On 6/11/06, Fred C <bsdh...@gmail.com> wrote:

--
Mark Ramm-Christensen
email: mark at compoundthinking dot com
blog: www.compoundthinking.com/blog

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sven H.  
View profile  
 More options Jun 11 2006, 3:29 pm
From: "Sven H." <ff...@gmx.de>
Date: Sun, 11 Jun 2006 21:29:05 +0200
Local: Sun, Jun 11 2006 3:29 pm
Subject: Re: [TurboGears] Re: kid questions.
Mark Ramm schrieb:
> You could put an ajax call on your page, retrieve that string through
> an seprate request and then render your string using innerHTML from
> javascript.

um.. that sounds like a terribly bad idea.
a) it produces a webpage where the content is only availble with
javascript and a AJAX-enabled browser.
b) What sense does it make to use kid and then try to circumvent one of
kid's main features, ensuring correctness of output?

-- Sven


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sven H.  
View profile  
 More options Jun 11 2006, 3:39 pm
From: "Sven H." <ff...@gmx.de>
Date: Sun, 11 Jun 2006 21:39:18 +0200
Local: Sun, Jun 11 2006 3:39 pm
Subject: Re: [TurboGears] kid questions.
Fred C schrieb:
> Hello,

> In my kid template I have this following line:  <div  
> class="reviewitem" py:content="XML(review.Content)" />.
> My problem is when the XML() argument is not a very clean html  
> string, XML fail miserably.
> How can I manage to roughly clean that string (in the template) or at  
> least return the string not formated, instead of having an exception  
> thrown.

I think the only way apart from horribly circumventing kid is to have
clean (X)HTML markup.
I'm currently using a validator like this to validate XHTML markup..

class XHTMLValidator(validators.FancyValidator):
    def _to_python(self, value, state = None):
        try:
            template = kid.Template(
                """<html xmlns:py="http://purl.org/kid/ns#">%s</html>"""
% value)
        except Exception, e:
            raise validators.Invalid( e.args[0], value, state)

        s = template.serialize( output = "xml")
        return s[s.index("<html>")+6:-7]

It uses a temporary template to check the XHTML code for correctness,
feeds errors back as
validation errors and extracts the cleaned-up XHTML markup from the
serialized output.

-- Sven


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Fred C  
View profile  
 More options Jun 11 2006, 4:13 pm
From: Fred C <bsdh...@gmail.com>
Date: Sun, 11 Jun 2006 16:13:44 -0400
Local: Sun, Jun 11 2006 4:13 pm
Subject: Re: [TurboGears] Re: kid questions.

Sorry, I can't use AJAX. I know AJAX is very fashionable right now  
but it is not an option for this page. Also I think I would have the  
same problem.

On Jun 11, 2006, at 10:54 AM, Mark Ramm wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Ramm  
View profile  
 More options Jun 11 2006, 4:55 pm
From: "Mark Ramm" <mark.mchristen...@gmail.com>
Date: Sun, 11 Jun 2006 16:55:43 -0400
Local: Sun, Jun 11 2006 4:55 pm
Subject: Re: [TurboGears] Re: kid questions.
On 6/11/06, Fred C <bsdh...@gmail.com> wrote:

> Sorry, I can't use AJAX. I know AJAX is very fashionable right now
> but it is not an option for this page. Also I think I would have the
> same problem.

My suggestion was a bit tongue in cheek ;)   It's the only way I know
of to 100% avoid KID while using KID.   And while you can get around
Kid's validation that way, I don't particularly think it's a good idea
either.   But I thought I'd throw it out there in case you were
looking for an ugly hack.

What I should have mentioned is that an easier way to get around KID
in a situation like this is not to use KID at all.  You can use
Cheetah instead, and get around KID's validity requirement.   Cheetah
shouldn't care a bit about how broken your HTML is.

Automatic HTML repair sounds like it would be nice, and perhaps it's
possible for some subset of HTML errors, but I doubt it's really
feasible unless your HTML is already almost right, and is broken an
easy to detect way.  It seems like your best choice is to go to the
source, and see if you can fix that.

--Mark


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Ramm  
View profile  
 More options Jun 11 2006, 4:59 pm
From: "Mark Ramm" <mark.mchristen...@gmail.com>
Date: Sun, 11 Jun 2006 16:59:09 -0400
Local: Sun, Jun 11 2006 4:59 pm
Subject: Re: [TurboGears] Re: kid questions.

> um.. that sounds like a terribly bad idea.

I agree.  I never said it was good, and I even said that it probably
wouldn't work!   But it's the only ugly hack I could think of to get
done what Fred was asking for.

The right answer is exactly what you say.  Don't use KID when you want
to have invalid output.   The right thing to do is to create valid
output, but if that's not possible the second best thing is to  use
Cheetah, or one of the other available templates with TurboGears
plugins that doesn't care about validity.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jorge Vargas  
View profile  
 More options Jun 11 2006, 5:37 pm
From: "Jorge Vargas" <jorge.var...@gmail.com>
Date: Sun, 11 Jun 2006 17:37:08 -0400
Local: Sun, Jun 11 2006 5:37 pm
Subject: Re: [TurboGears] kid questions.

On 6/11/06, Fred C <bsdh...@gmail.com> wrote:

> Hello,

> In my kid template I have this following line:  <div
> class="reviewitem" py:content="XML(review.Content)" />.
> My problem is when the XML() argument is not a very clean html
> string, XML fail miserably.

why not make that string valid xhtml?  XML is evil inside kid and should be
avoid

How can I manage to roughly clean that string (in the template) or at

> least return the string not formated, instead of having an exception
> thrown.

is that data coming from the db or a user? why not clean it up at insertion
time?

Thanks


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Fred C  
View profile  
 More options Jun 11 2006, 8:15 pm
From: Fred C <bsdh...@gmail.com>
Date: Sun, 11 Jun 2006 20:15:47 -0400
Local: Sun, Jun 11 2006 8:15 pm
Subject: Re: [TurboGears] Re: kid questions.

On Jun 11, 2006, at 4:55 PM, Mark Ramm wrote:

I think you are right and I am going to use Cheetah instead of kid. I  
like kid and I like the fact that it forces you to write clean code,  
but it can be a pain when you get part of your html content from a  
third party with a lot of small errors.

I have try to cleanup this code with ElementTidy, but this tool is  
not design to clean up a single string. It did not gave me the result  
expected. For fixing the source this is impossible, the only thing I  
can do with the source is read it. And I don't think the people who  
are producing that source gonna start closing the </p> , </li> or  
other tags who are not really affecting the presentation on their  
browsers.

Thanks for you answer.
-fred-


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Fred C  
View profile  
 More options Jun 11 2006, 8:18 pm
From: Fred C <bsdh...@gmail.com>
Date: Sun, 11 Jun 2006 20:18:03 -0400
Local: Sun, Jun 11 2006 8:18 pm
Subject: Re: [TurboGears] Re: kid questions.

On Jun 11, 2006, at 5:37 PM, Jorge Vargas wrote:

Just because this data is coming from a database from a third party  
and they don't feel the need to produce a clean html since it is  
displayed well in their browsers.

-fred-


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael P. Soulier  
View profile  
 More options Jun 11 2006, 8:24 pm
From: "Michael P. Soulier" <msoul...@digitaltorque.ca>
Date: Sun, 11 Jun 2006 20:24:15 -0400
Local: Sun, Jun 11 2006 8:24 pm
Subject: Re: [TurboGears] Re: kid questions.
On 11/06/06 Fred C said:

> I think you are right and I am going to use Cheetah instead of kid. I  
> like kid and I like the fact that it forces you to write clean code,  
> but it can be a pain when you get part of your html content from a  
> third party with a lot of small errors.

Not to mention when it mangles your code by putting spaces between images when
you don't want them. How does one change templates? I think I'm more
interested in Myghty.

Mike
--
Michael P. Soulier <msoul...@digitaltorque.ca>
"Any intelligent fool can make things bigger and more complex... It
takes a touch of genius - and a lot of courage to move in the opposite
direction." --Albert Einstein


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ed Singleton  
View profile  
 More options Jun 12 2006, 4:32 am
From: "Ed Singleton" <singleto...@gmail.com>
Date: Mon, 12 Jun 2006 09:32:08 +0100
Local: Mon, Jun 12 2006 4:32 am
Subject: Re: [TurboGears] kid questions.
A possible solution is to use BeautifulSoup.

It's quite good at producing valid markup out of invalid markup (in
terms of matching tags and stuff).

It's not very quick, but it can handle very bad markup.

Ed

On 6/11/06, Fred C <bsdh...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »