And you can also set the default (if you set text_factory, it will
override this) by doing:
from pysqlite2 import dbapi2 as dbapi
dbapi.register_adapter(unicode, lambda s: unicode(s, self._encoding,
"replace"))
Couldn't this be added to the sqlite backend?
def _setEncoding(self, enc):
self._encoding = enc
self.dbapi.register_adapter(unicode, lambda x: x.encode(enc))
This is perhaps better than adding special code to dapp like I suggested
below...
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Simen Haugen
Sent: 5. oktober 2006 18:06
To: Dabo Users list
Subject: RE: [dabo-users] dDataSet and encoding
Actually, the exact same thing could be done on connecting to a sqlite
database.
I have not tested this as I'm using my own connection pooling, but it
should work.
--- dapp_old.py 2006-09-21 18:49:16.280121700 +0200
+++ dapp.py 2006-10-05 18:04:02.574643700 +0200
@@ -445,7 +445,11 @@
if not self.dbConnections.has_key(connName):
if self.dbConnectionDefs.has_key(connName):
ci = self.dbConnectionDefs[connName]
- self.dbConnections[connName] =
dabo.db.dConnection(ci)
+ conn = dabo.db.dConnection(ci)
+ if ci.DbType == u"SQLite":
+ decoder = lambda s: unicode(s,
self._encoding, "replace")
+ conn._connection.text_factory =
decoder
+ self.dbConnections[connName] = conn
try:
ret = self.dbConnections[connName]
except KeyError:
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Ed Leafe
Sent: 5. oktober 2006 17:39
To: Dabo Users list
Subject: Re: [dabo-users] dDataSet and encoding
On Oct 4, 2006, at 4:15 PM, Simen Haugen wrote:
> How can I set the encoding on the datasets? I use a lot of datasets
> individually (without bizobjs etc) in my application, and want them
> in a different encoding. Can you put in an Encoding parameter on
> the datasets like this:
That looks like a good idea. I've added the code and committed
it to
Subversion. Thanks!
-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users