fixes for unicode

This commit is contained in:
Anand Doshi
2012-07-20 18:11:30 +05:30
parent 1703cc89b4
commit 76ec66dd65
5 changed files with 32 additions and 33 deletions

View File

@@ -69,7 +69,7 @@ class DocType:
else: else:
r = 1 r = 1
dateList = [getdate(self.doc.att_fr_date)+datetime.timedelta(days=i) for i in range(0,r)] dateList = [getdate(self.doc.att_fr_date)+datetime.timedelta(days=i) for i in range(0,r)]
dt=([str(date) for date in dateList]) dt=([formatdate(cstr(date)) for date in dateList])
return dt return dt

View File

@@ -52,8 +52,9 @@ class DocType:
# update prices in Price List # update prices in Price List
def update_prices(self): def update_prices(self):
import csv from core.page.data_import_tool.data_import_tool import read_csv_content
data = csv.reader(self.get_csv_data().splitlines())
data = read_csv_content(self.get_csv_data())
updated = 0 updated = 0
@@ -99,8 +100,4 @@ class DocType:
webnotes.msgprint("Unable to open attached file. Please try again.") webnotes.msgprint("Unable to open attached file. Please try again.")
raise e raise e
# NOTE: Don't know why this condition exists
if not isinstance(content, basestring) and hasattr(content, 'tostring'):
content = content.tostring()
return content return content

View File

@@ -47,10 +47,6 @@ class DocType:
from webnotes.utils import file_manager from webnotes.utils import file_manager
fn, content = file_manager.get_file(filename[1]) fn, content = file_manager.get_file(filename[1])
# NOTE: Don't know why this condition exists
if not isinstance(content, basestring) and hasattr(content, 'tostring'):
content = content.tostring()
else: else:
content = self.doc.diff_info content = self.doc.diff_info
@@ -83,7 +79,10 @@ class DocType:
def get_reconciliation_data(self,submit = 1): def get_reconciliation_data(self,submit = 1):
"""Read and validate csv data""" """Read and validate csv data"""
import csv import csv
data = csv.reader(self.get_csv_file_data(submit).splitlines()) from webnotes.utils import get_encoded_string
from core.page.data_import_tool.data_import_tool import read_csv_content
csv_content = get_encoded_string(self.get_csv_file_data(submit))
data = read_csv_content(csv_content)
self.convert_into_list(data, submit) self.convert_into_list(data, submit)

View File

@@ -42,10 +42,7 @@ import webnotes.auth
from webnotes.utils import cstr from webnotes.utils import cstr
def init(): def init():
# make the form_dict webnotes.handler.get_cgi_fields()
webnotes.form = cgi.FieldStorage(keep_blank_values=True)
for key in webnotes.form.keys():
webnotes.form_dict[key] = cstr(webnotes.form.getvalue(key))
# init request # init request
try: try:

View File

@@ -16,13 +16,12 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
return a dynamic page from website templates
all html pages related to website are generated here
"""
from __future__ import unicode_literals from __future__ import unicode_literals
"""
return a dynamic page from website templates
all html pages except login-page.html get generated here
"""
import cgi, cgitb, os, sys import cgi, cgitb, os, sys
cgitb.enable() cgitb.enable()
@@ -33,10 +32,8 @@ sys.path.append('../lib/py')
sys.path.append(conf.modules_path) sys.path.append(conf.modules_path)
def init(): def init():
import webnotes import webnotes.handler
webnotes.form = cgi.FieldStorage(keep_blank_values=True) webnotes.handler.get_cgi_fields()
for key in webnotes.form.keys():
webnotes.form_dict[key] = webnotes.form.getvalue(key)
webnotes.connect() webnotes.connect()
def respond(): def respond():
@@ -51,9 +48,18 @@ def respond():
except Exception, e: except Exception, e:
html = get_html('404') html = get_html('404')
print "Content-Type: text/html" content = []
print import webnotes.handler
print get_encoded_string(html) html = get_encoded_string(html)
html, content = webnotes.handler.gzip_response(html, content)
content += [
"Content-Type: text/html",
"",
]
webnotes.handler.print_content(content)
print html
def get_html(page_name): def get_html(page_name):
import website.utils import website.utils