blob: e59723937d2cd21007a783791fc4a79bed62dca5 [file] [log] [blame]
Rushabh Mehta03e87872012-04-14 15:02:17 +05301#!/usr/bin/env python
Rushabh Mehta3966f1d2012-02-23 12:35:32 +05302
Rushabh Mehta03e87872012-04-14 15:02:17 +05303# Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com)
Rushabh Mehta3966f1d2012-02-23 12:35:32 +05304#
Rushabh Mehta03e87872012-04-14 15:02:17 +05305# MIT License (MIT)
Rushabh Mehta3966f1d2012-02-23 12:35:32 +05306#
Rushabh Mehta03e87872012-04-14 15:02:17 +05307# Permission is hereby granted, free of charge, to any person obtaining a
8# copy of this software and associated documentation files (the "Software"),
9# to deal in the Software without restriction, including without limitation
10# the rights to use, copy, modify, merge, publish, distribute, sublicense,
11# and/or sell copies of the Software, and to permit persons to whom the
12# Software is furnished to do so, subject to the following conditions:
Rushabh Mehta3966f1d2012-02-23 12:35:32 +053013#
Rushabh Mehta03e87872012-04-14 15:02:17 +053014# The above copyright notice and this permission notice shall be included in
15# all copies or substantial portions of the Software.
16#
17# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
18# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
19# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
21# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
22# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23#
Rushabh Mehta3966f1d2012-02-23 12:35:32 +053024
Rushabh Mehta66ac2b02011-09-05 18:43:09 +053025
26import cgi, cgitb, os, sys
27cgitb.enable()
28
29# import libs
Rushabh Mehtacabfc652012-04-14 16:08:45 +053030sys.path.append('.')
Rushabh Mehta66ac2b02011-09-05 18:43:09 +053031sys.path.append('lib/py')
32sys.path.append('erpnext')
33
34import webnotes
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053035import webnotes.handler
36import webnotes.auth
Anand Doshib319d2c2012-02-17 12:47:36 +053037import webnotes.defs
Rushabh Mehta66ac2b02011-09-05 18:43:09 +053038
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053039def init():
40 # make the form_dict
41 webnotes.form = cgi.FieldStorage(keep_blank_values=True)
42 for key in webnotes.form.keys():
43 webnotes.form_dict[key] = webnotes.form.getvalue(key)
Rushabh Mehta66ac2b02011-09-05 18:43:09 +053044
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053045 # init request
Rushabh Mehta4167e2f2012-02-06 10:58:48 +010046 try:
47 webnotes.http_request = webnotes.auth.HTTPRequest()
Rushabh Mehtada27db42012-02-28 12:17:08 +010048 return True
Rushabh Mehtaafaac602012-02-14 11:44:13 +053049 except webnotes.AuthenticationError, e:
Rushabh Mehtaa38bbe22012-02-29 10:55:43 +053050 return True
Rushabh Mehta13531b72012-02-20 12:35:23 +053051 except webnotes.UnknownDomainError, e:
Anand Doshib319d2c2012-02-17 12:47:36 +053052 print "Location: " + (webnotes.defs.redirect_404)
Rushabh Mehtada27db42012-02-28 12:17:08 +010053 except webnotes.SessionStopped, e:
54 if 'cmd' in webnotes.form_dict:
55 webnotes.handler.print_json()
56 else:
57 print "Content-Type: text/html"
58 print
59 print """<html>
60 <body style="background-color: #EEE;">
61 <h3 style="width: 900px; background-color: #FFF; border: 2px solid #AAA; padding: 20px; font-family: Arial; margin: 20px auto">
62 Updating.
63 We will be back in a few moments...
64 </h3>
65 </body>
66 </html>"""
Rushabh Mehta66ac2b02011-09-05 18:43:09 +053067
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053068def respond():
69 import webnotes
70 if 'cmd' in webnotes.form_dict:
71 webnotes.handler.handle()
72 else:
Rushabh Mehta8ebf4e22012-02-07 13:31:09 +053073 import webnotes.cms.index
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053074 print "Content-Type: text/html"
75 webnotes.handler.print_cookies()
76 print
Rushabh Mehta8ebf4e22012-02-07 13:31:09 +053077 print webnotes.cms.index.get()
Rushabh Mehta5ede3e82011-09-08 14:16:34 +053078
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053079if __name__=="__main__":
Rushabh Mehtada27db42012-02-28 12:17:08 +010080 if init():
81 respond()