blob: ed766eb11fecbdae2aff63ccbaa2364fcf82ea97 [file] [log] [blame]
Rushabh Mehta66ac2b02011-09-05 18:43:09 +05301#!/usr/bin/python
Rushabh Mehta3966f1d2012-02-23 12:35:32 +05302
3# ERPNext - web based ERP (http://erpnext.com)
4# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18
Rushabh Mehta66ac2b02011-09-05 18:43:09 +053019
20import cgi, cgitb, os, sys
21cgitb.enable()
22
23# import libs
24sys.path.append('lib/py')
25sys.path.append('erpnext')
26
27import webnotes
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053028import webnotes.handler
29import webnotes.auth
Anand Doshib319d2c2012-02-17 12:47:36 +053030import webnotes.defs
Rushabh Mehta66ac2b02011-09-05 18:43:09 +053031
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053032def init():
33 # make the form_dict
34 webnotes.form = cgi.FieldStorage(keep_blank_values=True)
35 for key in webnotes.form.keys():
36 webnotes.form_dict[key] = webnotes.form.getvalue(key)
Rushabh Mehta66ac2b02011-09-05 18:43:09 +053037
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053038 # init request
Rushabh Mehta4167e2f2012-02-06 10:58:48 +010039 try:
40 webnotes.http_request = webnotes.auth.HTTPRequest()
Rushabh Mehtada27db42012-02-28 12:17:08 +010041 return True
Rushabh Mehtaafaac602012-02-14 11:44:13 +053042 except webnotes.AuthenticationError, e:
Rushabh Mehtaa38bbe22012-02-29 10:55:43 +053043 return True
Rushabh Mehta13531b72012-02-20 12:35:23 +053044 except webnotes.UnknownDomainError, e:
Anand Doshib319d2c2012-02-17 12:47:36 +053045 print "Location: " + (webnotes.defs.redirect_404)
Rushabh Mehtada27db42012-02-28 12:17:08 +010046 except webnotes.SessionStopped, e:
47 if 'cmd' in webnotes.form_dict:
48 webnotes.handler.print_json()
49 else:
50 print "Content-Type: text/html"
51 print
52 print """<html>
53 <body style="background-color: #EEE;">
54 <h3 style="width: 900px; background-color: #FFF; border: 2px solid #AAA; padding: 20px; font-family: Arial; margin: 20px auto">
55 Updating.
56 We will be back in a few moments...
57 </h3>
58 </body>
59 </html>"""
Rushabh Mehta66ac2b02011-09-05 18:43:09 +053060
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053061def respond():
62 import webnotes
63 if 'cmd' in webnotes.form_dict:
64 webnotes.handler.handle()
65 else:
Rushabh Mehta8ebf4e22012-02-07 13:31:09 +053066 import webnotes.cms.index
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053067 print "Content-Type: text/html"
68 webnotes.handler.print_cookies()
69 print
Rushabh Mehta8ebf4e22012-02-07 13:31:09 +053070 print webnotes.cms.index.get()
Rushabh Mehta5ede3e82011-09-08 14:16:34 +053071
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053072if __name__=="__main__":
Rushabh Mehtada27db42012-02-28 12:17:08 +010073 if init():
74 respond()