Re: marksafe

2009-08-25 Thread Daniel Roseman

On Aug 25, 2:07 pm, luca72  wrote:
> Hello i have this:
> errore = """
>                     { alert('test_js')};
>                     """
> return mark_safe(errore)
> I get this error : AttributeError: 'SafeString' object has no
> attribute 'status_code'
> can you help me to write the correct one?
> Thanks
>
> Luca

You don't say where you're using this, but if it's in a view, you must
always return an HttpResponse, not just a string. So try:
return HttpResponse(mark_safe(errore))
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: marksafe

2009-08-25 Thread luca72

Thanks now it works
Luca


On 25 Ago, 15:12, Daniel Roseman  wrote:
> On Aug 25, 2:07 pm, luca72  wrote:
>
> > Hello i have this:
> > errore = """
> >                     { alert('test_js')};
> >                     """
> > return mark_safe(errore)
> > I get this error : AttributeError: 'SafeString' object has no
> > attribute 'status_code'
> > can you help me to write the correct one?
> > Thanks
>
> > Luca
>
> You don't say where you're using this, but if it's in a view, you must
> always return an HttpResponse, not just a string. So try:
>     return HttpResponse(mark_safe(errore))
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: MarkSafe and widget rendering "/" disapeared

2008-12-15 Thread Malcolm Tredinnick


On Mon, 2008-12-15 at 06:22 -0800, coulix wrote:
> Hello Djangonauts,
> I have a custom widget to create a kind of group list which ommits the
> last "/" at the end of an input field.
> Making html validation to fail.
> 
> The important code is here:
> 
>rendered_cb = cb.render(name, option_value)
> print rendered_cb
> output.append(u'%s %s' % (
> option_label,
> rendered_cb,
> option_label)
> )
> ...
>return mark_safe(u'\n'.join(output))
> 
> The shell output gives me
>  name="competences" />
>  >
> 
>  >
> 
> 
> Thats all good
> 
> But then HTML output after mark_safe takes this input "/" away

This seems to be an enormously large assumption. How have you worked out
that mark_safe() is doing this? A quick glance at the relevant pieces of
source (mark_safe() and the SafeUnicode class) will show it doesn't care
one wit about a slash character.

> Langues
>  name="competences" type="checkbox"> Anglais
> 
>  value="3" name="competences" type="checkbox"> Espagnol
>  value="4" name="competences" type="checkbox"> Japonais

The shell output you show doesn't look at all like the final output you
show, so it's not from the same run. I'm cautious about comparing apples
to oranges here. Since you print "rendered_cb" in the above code
fragment, that would be the relevant output to be comparing. Does it
have a trailing slash?

In short, there's information missing here. mark_safe() isn't doing
anything special that would affect this, as far as I know. I think you
need to take a few steps back and compare the output at each stage.

Regards,
Malcolm



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---