save special character in Database using Grails - grails

new Trainingcamp(name:"Höhentraining", region:"Alpen").save()
tr1 = Trainingcamp.findByName("Höhentraining")
tr2 = Trainingcamp.findByRegion("Alpen")
println("Tr1: " + tr1?.name)
println("Tr2: " + tr2?.name)
Output on console is:
Tr1:
Tr2: H?hentraining
So it seems to me that by saving the domainobject something happens that replaces the Special character "ö" with a questionmark "?". How do I get rid of this problem?
Thanks in advanced!
Using Grails 1.3.7
__edit1:
I started the application with prod run-app and then checked the pordDb.log. I found the following insert:
INSERT INTO TRAININGCAMP VALUES('H\ufffdhentraining','Alpen')
No matter I write an "ö" or "ü or "ä" it allways replace it with "\ufffd"
So, any suggestions to solve this problem?
__edit2:
New insight: The Problem only occur when I save the domain in BootStrap.groovy. By saving the domain in a controller the output on the console is as expected:
Tr2: Höhentraining

Related

How to fix an 'Invalid tag name' in WSDL request using Zeep?

When trying to access a WSDL service, I get the following error:
ValueError: Invalid tag name 'Foo\\Bar\\Baz\\Etc\\V3Port'
The port which is provided through the WSDL-link actually has single backslashes: 'Foo\Bar\Baz\Etc\V3Port'
The ValueError gets raised when zeep calls the apihelpers.pxi method in the lxml library.
Any idea how I can fix this?
(BTW: the script worked fine when I used it 2 months ago. The WSDL-link hasn't changed)
I have found a solution
Before, it was sufficient to do:
from zeep import Client
Now, apparently, I need to explicitly add:
from lxml import etree
Everything works as before now.
Zeep does not like like "/" in values also. It gives invalid tag name error any time it finds any character in value that it does not like. For all such errors, you need to modify as_qname function in utils.py located in root folder of zeep library.
In my case, it was complaining for "/" in value, which is a valid value. I had to add below line to as_qname function.
value = value.replace("/", "-")
Below are first few lines of as_qname after modification
def as_qname(value: str, nsmap, target_namespace=None) -> etree.QName:
"""Convert the given value to a QName"""
value = value.strip() # some xsd's contain leading/trailing spaces
value = value.replace("/", "-") # Added by me.
if ":" in value:
prefix, local = value.split(":")

How to prevent single quote in th:onclick getting escaped when using thymeleaf

I want to get onclick="alert('myvar')" in the browser.
I tried
th:onclick="'alert(\'' + ${myVar} + '\');'"
and I got
onclick="alert('null');"
I tried
th:onclick="|alert('${myVar}');|"
and I still got
onclick="alert('null');"
How can I let the single quote not be escaped?
The following snipped worked for me:
th:onclick="|alert('${myVar}');|"
That looks like your second attemp but I'm getting:
onclick="alert('null');"
That makes me thinking and I tested your first attemp:
th:onclick="'alert(\'' + ${myVar} + '\');'"
and again I'm getting:
onclick="alert('null');"
Spooky! I searched for similar questions in the thymleaf-forum afterwards and that's the way how to to this.

Error when converting form Python 2. to Python 3

can you help me to convert this to python 3.5 ? I tried but it don't work. I did the following steps:
I change the package md5 to hashlib
I change all the id = md5.new("%s"%str(clf.get_params())).hexdigest() to id = hashlib.md5(("%s"%str(clf.get_params())).encode('utf-8') ).hexdigest()
but I still have somme problems when I put a directory to these parameters
save_preds="",
save_params=""
save_test_only=""
clf_name="XX"
I have the folowing error when I put something in thise parameters:
TypeError: a bytes-like object is required, not 'str'
Please see the code here:
blend_proba.py
Thanks,
cdk
Replacing
clf_name="XX"
by
clf_name=b"XX"
would convert the strings into objects of type bytes. Whether those changes will be enough, I honestly have no idea.

S22.Imap.BadServerResponseException - IMAP xm003 BAD [CLIENTBUG] Command syntax error

Problem with the S22.Imap:
xm003 BAD [CLIENTBUG] Command syntax error
my Search Condition from the Example:
IEnumerable<uint> uids = client.Search(SearchCondition.SentSince(new DateTime(2015, 10, 20)));
oll other SearchCondition's work fine. Pls Help.
The problem is that S22.Imap is sending an incorrectly formatted date string in the SENTSINCE search query.
Since S22.Imap is a dead project, I would recommend switching to my open source MailKit library instead.
Hope that helps.

Double closure fails in GSP

In a GSP file I write something like this:
${tgs.singleGameSheets.find{it.matchnumber==1}.awayPlayer.fullname()}
But I receive the following error:
org.codehaus.groovy.control.MultipleCompilationErrorsException:
startup failed:
C__STS_Projekte_TischtennisManager_grails_app_views_league__showGameSheet_gsp:
49:expecting '}', found ')' # line 49, column 134.
heets.find{it.matchnumber==1 })
The problem seems to be the double closure as I've found a bug report here.
Unfortunately the solution from the bugreport with the %= and % at the beginning and the end of the tag is not working for me.
Are there any other workarounds or solutions for this double closure problem?
I'm using Grails 1.3.7.
You may have to split this up in to two lines.
Try assigning the find results to a separate var first
<% def r = tgs.singleGameSheets.find{it.matchnumber==1} %>
${r*.awayPlayer.fullname()}
I would recommend firstly to do this sort of data processing in the controller and hand data that is as well prepared as possible down to the view.
If you are unable to do that, I would recommend trying to use parenthesis:
${tgs.singleGameSheets.find{it.matchnumber==1}.awayPlayer.fullname()}
becomes
${(tgs.singleGameSheets.find{it.matchnumber==1}.awayPlayer.fullname())}
That has worked for me on past occasions where I had to do ${(someCollection.findAll { someClause })}

Resources