Permalink
Browse files

utf8

  • Loading branch information...
enki committed Jun 18, 2010
1 parent 82627ec commit 22368dec8739ebcfaae5feae774e9f55ba249904
Showing with 7 additions and 4 deletions.
  1. +4 −1 tragedy/columns.py
  2. +3 −3 tragedy/rows.py
View
@@ -30,6 +30,8 @@ def key_to_internal(self, column_key): # called for userinput (before adding)
return column_key
def value_to_internal(self, value): # called for userinput (before adding)
+ if isinstance(value, unicode):
+ value = value.encode('utf-8')
return value
def to_display(self, column_key, value):
@@ -81,7 +83,8 @@ def key_to_internal(self, column_key):
class UnicodeField(Field):
def key_to_internal(self, column_key):
- return unicode(column_key)
+ if isinstance(column_key, unicode):
+ return column_key.encode('utf-8')
class TimeField(Field):
def __init__(self, *args, **kwargs):
View
@@ -426,7 +426,7 @@ def _real_save(self, save_row_key=None, *args, **kwargs):
newtimestamp = self._timestamp_func()
import time
print 'STORING WITH NEWTIMESTAMP', self.__class__, column_key, newtimestamp #time.ctime( int(newtimestamp) )
- column = Column(name=column_key, value=value.encode('utf-8'), clock=Clock(timestamp=newtimestamp))
+ column = Column(name=column_key, value=value, clock=Clock(timestamp=newtimestamp))
save_columns.append( ColumnOrSuperColumn(column=column) )
save_mutations = [Mutation(column_or_supercolumn=sc) for sc in save_columns]
@@ -437,8 +437,8 @@ def _real_save(self, save_row_key=None, *args, **kwargs):
# consistency_level= self._wcl(kwargs['write_consistency_level']),
# )
mumap = {save_row_key: {self._column_family: save_mutations} }
- print u'PREMUMAP', unicode(save_mutations).encode('ascii', 'replace')
- print u'MUMAP', repr(mumap).encode('ascii', 'replace')
+ # print u'PREMUMAP', unicode(save_mutations).encode('ascii', 'replace')
+ # print u'MUMAP', repr(mumap).encode('ascii', 'replace')
self.getclient().batch_mutate(
mutation_map=mumap,
consistency_level=self._wcl(kwargs['write_consistency_level']),

0 comments on commit 22368de

Please sign in to comment.