[Zope] Problem with zope and long strings - SOS

Jim Washington jwashin at vt.edu
Mon Aug 9 07:36:46 EDT 2004


fowlertrainer wrote:

> kepes.krisztian wrote at 2004-8-6 14:41 +0200:
>
> >>My problem is that:
> >>I want to js.alert with long strings.
> >>I create these strings, and the complete js code.
> >>But zope is wrapping my strings like that:
> >>
> >><script>
> >>function aaa{
> >>jscode...
> >>s="xxxxxxx ........
> >>";
> >>jscode...
> >>};
> >></script>
>
> >
> >Usually, Zope does not break lines even when they get long.
> >
> >Note, however, that in some cases you must prevent newlines
> >around DTML constructs as they may end up in the generated code.
> >You can do something like:
> >
> >    <dtml-XXXX ...
> >    ><dtml-YYYY...>
> >
> >I.e., you put the newline into the DTML construct.
> >The DTML parser does not allow newlines at all places
> >but before the ">" is at least possible.
>
> Sorry, but you are misundertanding me.
> My problem is that:
> I have a webpage that is show the data in table (grid).
> Every data that have error is get a sign with error message.
> Sometimes this message is more than 255 character, so the <img title> is
> cannot show all chars in message.
>
> This is cause that I need to show the error in other format. So I want to
> alert it with javascript (img onclick).
>
> And this time I crashed in zope's "string handling speciality":
>
> When I write this:
>
> jsscript="alert('a long string with many spaces');"
> context.page(param=jsscript)
>
> that zope is separate the lines in ending ' sign like that:
>
> jsscript=alert('a long string with many spaces
> ');
>
>
> In this time the js interpeter is makes errors.
>
> How to I prevent this "wrong working mode" of zope ?
>
> I'm not sure, but I think that short strings are showed/generated also 
> like
> the example.
>
> The only solution that I find to I create hidden items without form, 
> and the
> items are containing the long strings.
> The JS is get the item that I need, and get the .value, and show it with
> alert.
> But with zope js generating the zope is wrap the lines in ending ' sign.
>
> So that is the problem.
>
Does it do the same thing when you strip() the string before passing it?

long_string = 'a long string with many spaces'

jsscript="alert('%s');" % long_string.strip()
context.page(param=jsscript)

-Jim Washington


More information about the Zope mailing list