Discussion:
[tryton] copying simple text field to richtext field
Francisco Maria Moyano Casco
2018-01-25 13:40:22 UTC
Permalink
Hi,
I'm having problems trying to copying text from a text field to a richtext field.

I had success with normal characters, but when I try with special characters and some others (ñ,Ñ,áéíóú), it starts to behave unnormal.

Some example of the code I'm using is:

@classmethod
def prepare_richtext(cls,message=''):
from BeautifulSoup import BeautifulStoneSoup
import cgi
res = ''
message = message.decode('utf-8')
message = unicode(message)
message = cgi.escape(message).encode('ascii', 'xmlcharrefreplace')
res += "<div><b>"\
+(datetime.now()+timedelta(hours=-3)).strftime("%d-%m-%Y %H:%M:%S")\
+" - "
res += message+" </b></div>"
res = unicode(BeautifulStoneSoup(res,
convertEntities=BeautifulStoneSoup.ALL_ENTITIES))
return res

For example: i wrote one single "ñ" on the text field and goes unnormal (doesn't copy the character, just add some other; and tryton ask me once and again to save the form when I want to reload/close it). But, when I wrote two ("ññ"), it goes well.

Regards.
Francisco
--
You received this message because you are subscribed to the Google Groups "tryton" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/tryton/b5304aae-1b35-4ab7-926c-45b589b88cf9%40googlegroups.com.
Cédric Krier
2018-01-25 14:29:53 UTC
Permalink
Post by Francisco Maria Moyano Casco
Hi,
I'm having problems trying to copying text from a text field to a richtext field.
I had success with normal characters, but when I try with special characters and some others (ñ,Ñ,áéíóú), it starts to behave unnormal.
@classmethod
from BeautifulSoup import BeautifulStoneSoup
import cgi
res = ''
message = message.decode('utf-8')
message = unicode(message)
message = cgi.escape(message).encode('ascii', 'xmlcharrefreplace')
res += "<div><b>"\
+(datetime.now()+timedelta(hours=-3)).strftime("%d-%m-%Y %H:%M:%S")\
+" - "
res += message+" </b></div>"
res = unicode(BeautifulStoneSoup(res,
convertEntities=BeautifulStoneSoup.ALL_ENTITIES))
return res
For example: i wrote one single "ñ" on the text field and goes unnormal (doesn't copy the character, just add some other; and tryton ask me once and again to save the form when I want to reload/close it). But, when I wrote two ("ññ"), it goes well.
Probably https://bugs.tryton.org/issue5182
--
Cédric Krier - B2CK SPRL
Email/Jabber: ***@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/
--
You received this message because you are subscribed to the Google Groups "tryton" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/tryton/20180125142953.GH23162%40kei.
Francisco Maria Moyano Casco
2018-01-25 17:51:39 UTC
Permalink
Post by Cédric Krier
Post by Francisco Maria Moyano Casco
Hi,
I'm having problems trying to copying text from a text field to a richtext field.
I had success with normal characters, but when I try with special characters and some others (ñ,Ñ,áéíóú), it starts to behave unnormal.
@classmethod
from BeautifulSoup import BeautifulStoneSoup
import cgi
res = ''
message = message.decode('utf-8')
message = unicode(message)
message = cgi.escape(message).encode('ascii', 'xmlcharrefreplace')
res += "<div><b>"\
+(datetime.now()+timedelta(hours=-3)).strftime("%d-%m-%Y %H:%M:%S")\
+" - "
res += message+" </b></div>"
res = unicode(BeautifulStoneSoup(res,
convertEntities=BeautifulStoneSoup.ALL_ENTITIES))
return res
For example: i wrote one single "ñ" on the text field and goes unnormal (doesn't copy the character, just add some other; and tryton ask me once and again to save the form when I want to reload/close it). But, when I wrote two ("ññ"), it goes well.
Probably https://bugs.tryton.org/issue5182
It looks like it is. It's there anyway to force/set the encoding to chardet?

There is a hook to solve it. Simple using the comment tag <!-- -->, and write inside 2 or 3 ñ, but the richtext doesn't recognize the <!-- -_> comment tags.

Thanks
Francisco
--
You received this message because you are subscribed to the Google Groups "tryton" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/tryton/d0d789a7-7f53-4395-9e96-1d5b36027754%40googlegroups.com.
Cédric Krier
2018-01-25 18:00:28 UTC
Permalink
Post by Francisco Maria Moyano Casco
Post by Cédric Krier
Post by Francisco Maria Moyano Casco
Hi,
I'm having problems trying to copying text from a text field to a richtext field.
I had success with normal characters, but when I try with special characters and some others (ñ,Ñ,áéíóú), it starts to behave unnormal.
@classmethod
from BeautifulSoup import BeautifulStoneSoup
import cgi
res = ''
message = message.decode('utf-8')
message = unicode(message)
message = cgi.escape(message).encode('ascii', 'xmlcharrefreplace')
res += "<div><b>"\
+(datetime.now()+timedelta(hours=-3)).strftime("%d-%m-%Y %H:%M:%S")\
+" - "
res += message+" </b></div>"
res = unicode(BeautifulStoneSoup(res,
convertEntities=BeautifulStoneSoup.ALL_ENTITIES))
return res
For example: i wrote one single "ñ" on the text field and goes unnormal (doesn't copy the character, just add some other; and tryton ask me once and again to save the form when I want to reload/close it). But, when I wrote two ("ññ"), it goes well.
Probably https://bugs.tryton.org/issue5182
It looks like it is. It's there anyway to force/set the encoding to chardet?
I guess you could escape all non-ascii chars.
--
Cédric Krier - B2CK SPRL
Email/Jabber: ***@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/
--
You received this message because you are subscribed to the Google Groups "tryton" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/tryton/20180125180028.GL23162%40kei.
Francisco Maria Moyano Casco
2018-01-30 13:08:34 UTC
Permalink
Post by Cédric Krier
Post by Francisco Maria Moyano Casco
Post by Cédric Krier
Post by Francisco Maria Moyano Casco
Hi,
I'm having problems trying to copying text from a text field to a richtext field.
I had success with normal characters, but when I try with special characters and some others (ñ,Ñ,áéíóú), it starts to behave unnormal.
@classmethod
from BeautifulSoup import BeautifulStoneSoup
import cgi
res = ''
message = message.decode('utf-8')
message = unicode(message)
message = cgi.escape(message).encode('ascii', 'xmlcharrefreplace')
res += "<div><b>"\
+(datetime.now()+timedelta(hours=-3)).strftime("%d-%m-%Y %H:%M:%S")\
+" - "
res += message+" </b></div>"
res = unicode(BeautifulStoneSoup(res,
convertEntities=BeautifulStoneSoup.ALL_ENTITIES))
return res
For example: i wrote one single "ñ" on the text field and goes unnormal (doesn't copy the character, just add some other; and tryton ask me once and again to save the form when I want to reload/close it). But, when I wrote two ("ññ"), it goes well.
Probably https://bugs.tryton.org/issue5182
It looks like it is. It's there anyway to force/set the encoding to chardet?
I guess you could escape all non-ascii chars.
Thanks for the answer, but got nothing.
I guess is the chardet and the auto/heuristic determination of the encoding.On a python console, importing got the same behaviour.
Once again, thanks
Francisco
--
You received this message because you are subscribed to the Google Groups "tryton" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/tryton/32b9da4d-c1de-4562-a478-a2428e81855f%40googlegroups.com.
Loading...