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

@ -49,7 +49,7 @@ class DocType:
res = sql("select name, employee_name from `tabEmployee` where status = 'Active' and docstatus !=2")
for d in dt:
for r in res:
for r in res:
lst.append([r[0],r[1],d,'',fy,comp,sr])
return lst
@ -69,7 +69,7 @@ class DocType:
else:
r = 1
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

View File

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

View File

@ -47,10 +47,6 @@ class DocType:
from webnotes.utils import file_manager
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:
content = self.doc.diff_info
@ -82,8 +78,11 @@ class DocType:
def get_reconciliation_data(self,submit = 1):
"""Read and validate csv data"""
import csv
data = csv.reader(self.get_csv_file_data(submit).splitlines())
import csv
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)
@ -186,7 +185,7 @@ class DocType:
# Diff between file and system
qty_diff = row[2] != '~' and flt(row[2]) - flt(sys_stock['actual_qty']) or 0
rate_diff = row[3] != '~' and flt(row[3]) - flt(sys_stock['val_rate']) or 0
# Make sl entry
if qty_diff:
self.make_sl_entry(is_submit, row, qty_diff, sys_stock)

View File

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

View File

@ -16,13 +16,12 @@
# You should have received a copy of the GNU General Public License
# 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
"""
return a dynamic page from website templates
all html pages except login-page.html get generated here
"""
import cgi, cgitb, os, sys
cgitb.enable()
@ -33,10 +32,8 @@ sys.path.append('../lib/py')
sys.path.append(conf.modules_path)
def init():
import webnotes
webnotes.form = cgi.FieldStorage(keep_blank_values=True)
for key in webnotes.form.keys():
webnotes.form_dict[key] = webnotes.form.getvalue(key)
import webnotes.handler
webnotes.handler.get_cgi_fields()
webnotes.connect()
def respond():
@ -50,10 +47,19 @@ def respond():
html = get_html('index')
except Exception, e:
html = get_html('404')
print "Content-Type: text/html"
print
print get_encoded_string(html)
content = []
import webnotes.handler
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):
import website.utils