@AndCycle:

I believe Massimo's suggestion should solve the problem.

One more tips. If you put this line at the beginning of your source
code,
  # coding: utf8
and making sure your source code file itself is in utf8, then you can
simply try:
  Field('rating', type='string', default='普遍')
Much straightforward. Isn't it?

PS: I use Chinese too. ;-)

On Oct2, 9:28pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
> Can you try
>
>   Field('rating', type='string', default=u'普遍'.encode('utf8'))
>
> On Oct 2, 5:44 am, AndCycle <andcycle-goo...@andcycle.idv.tw> wrote:
>
>
>
> > I simply hit the unicode issue here,
>
> > I know I can do this by manual access lol
>
> > what I did
>
> >     Field('rating', type='string', default=u'普遍')
>
> > at db definition
>
> > then tried to create crud form (yup, I am a lazy guy)
>
> > def post():
> >     return dict(form=crud.create(db.uploads))
>
> > boom,
>
> > it hit a str func at line 91
>
> > 79 -class StringWidget(FormWidget):
> > 80
> > 81 @staticmethod
> > 82 - def widget(field, value, **attributes):
> > 83 """
> > 84 generates an INPUT text tag.
> > 85
> > 86 see also: :meth:`FormWidget.widget`
> > 87 """
> > 88
> > 89 default = dict(
> > 90 _type = 'text',
> > 91 value = (value!=None and str(value)) or '',
> > 92 )
> > 93 attr = StringWidget._attributes(field, default, **attributes) 94 95
> > return INPUT(**attr)
>
> > here is the traceback
>
> > Traceback (most recent call last):
> >   File "gluon/restricted.py", line 178, in restricted
> >   File "C:/Users/AndCycle/Documents/work/corelight/case/web2py/
> > applications/eland/controllers/upload.py", line 15, in <module>
> >   File "gluon/globals.py", line 102, in <lambda>
> >   File "C:/Users/AndCycle/Documents/work/corelight/case/web2py/
> > applications/eland/controllers/upload.py", line 9, in post
> >   File "gluon/tools.py", line 1892, in create
> >   File "gluon/tools.py", line 1830, in update
> >   File "gluon/sqlhtml.py", line 624, in __init__
> >   File "gluon/sqlhtml.py", line 91, in widget
> > UnicodeEncodeError: 'ascii' codec can't encode characters in position
> > 0-1: ordinal not in range(128)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to