Rushabh Mehta | 03e8787 | 2012-04-14 15:02:17 +0530 | [diff] [blame] | 1 | #!/usr/bin/env python |
Rushabh Mehta | 3966f1d | 2012-02-23 12:35:32 +0530 | [diff] [blame] | 2 | |
Rushabh Mehta | 03e8787 | 2012-04-14 15:02:17 +0530 | [diff] [blame] | 3 | # Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com) |
Rushabh Mehta | 3966f1d | 2012-02-23 12:35:32 +0530 | [diff] [blame] | 4 | # |
Rushabh Mehta | 03e8787 | 2012-04-14 15:02:17 +0530 | [diff] [blame] | 5 | # MIT License (MIT) |
Rushabh Mehta | 3966f1d | 2012-02-23 12:35:32 +0530 | [diff] [blame] | 6 | # |
Rushabh Mehta | 03e8787 | 2012-04-14 15:02:17 +0530 | [diff] [blame] | 7 | # 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 Mehta | 3966f1d | 2012-02-23 12:35:32 +0530 | [diff] [blame] | 13 | # |
Rushabh Mehta | 03e8787 | 2012-04-14 15:02:17 +0530 | [diff] [blame] | 14 | # 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 Mehta | 3966f1d | 2012-02-23 12:35:32 +0530 | [diff] [blame] | 24 | |
Rushabh Mehta | 66ac2b0 | 2011-09-05 18:43:09 +0530 | [diff] [blame] | 25 | |
| 26 | import cgi, cgitb, os, sys |
| 27 | cgitb.enable() |
| 28 | |
| 29 | # import libs |
| 30 | sys.path.append('lib/py') |
| 31 | sys.path.append('erpnext') |
| 32 | |
| 33 | import webnotes |
Rushabh Mehta | 9ef63f9 | 2012-02-01 14:47:29 +0530 | [diff] [blame] | 34 | import webnotes.handler |
| 35 | import webnotes.auth |
Anand Doshi | b319d2c | 2012-02-17 12:47:36 +0530 | [diff] [blame] | 36 | import webnotes.defs |
Rushabh Mehta | 66ac2b0 | 2011-09-05 18:43:09 +0530 | [diff] [blame] | 37 | |
Rushabh Mehta | 9ef63f9 | 2012-02-01 14:47:29 +0530 | [diff] [blame] | 38 | def init(): |
| 39 | # make the form_dict |
| 40 | webnotes.form = cgi.FieldStorage(keep_blank_values=True) |
| 41 | for key in webnotes.form.keys(): |
| 42 | webnotes.form_dict[key] = webnotes.form.getvalue(key) |
Rushabh Mehta | 66ac2b0 | 2011-09-05 18:43:09 +0530 | [diff] [blame] | 43 | |
Rushabh Mehta | 9ef63f9 | 2012-02-01 14:47:29 +0530 | [diff] [blame] | 44 | # init request |
Rushabh Mehta | 4167e2f | 2012-02-06 10:58:48 +0100 | [diff] [blame] | 45 | try: |
| 46 | webnotes.http_request = webnotes.auth.HTTPRequest() |
Rushabh Mehta | da27db4 | 2012-02-28 12:17:08 +0100 | [diff] [blame] | 47 | return True |
Rushabh Mehta | afaac60 | 2012-02-14 11:44:13 +0530 | [diff] [blame] | 48 | except webnotes.AuthenticationError, e: |
Rushabh Mehta | a38bbe2 | 2012-02-29 10:55:43 +0530 | [diff] [blame] | 49 | return True |
Rushabh Mehta | 13531b7 | 2012-02-20 12:35:23 +0530 | [diff] [blame] | 50 | except webnotes.UnknownDomainError, e: |
Anand Doshi | b319d2c | 2012-02-17 12:47:36 +0530 | [diff] [blame] | 51 | print "Location: " + (webnotes.defs.redirect_404) |
Rushabh Mehta | da27db4 | 2012-02-28 12:17:08 +0100 | [diff] [blame] | 52 | except webnotes.SessionStopped, e: |
| 53 | if 'cmd' in webnotes.form_dict: |
| 54 | webnotes.handler.print_json() |
| 55 | else: |
| 56 | print "Content-Type: text/html" |
| 57 | print |
| 58 | print """<html> |
| 59 | <body style="background-color: #EEE;"> |
| 60 | <h3 style="width: 900px; background-color: #FFF; border: 2px solid #AAA; padding: 20px; font-family: Arial; margin: 20px auto"> |
| 61 | Updating. |
| 62 | We will be back in a few moments... |
| 63 | </h3> |
| 64 | </body> |
| 65 | </html>""" |
Rushabh Mehta | 66ac2b0 | 2011-09-05 18:43:09 +0530 | [diff] [blame] | 66 | |
Rushabh Mehta | 9ef63f9 | 2012-02-01 14:47:29 +0530 | [diff] [blame] | 67 | def respond(): |
| 68 | import webnotes |
| 69 | if 'cmd' in webnotes.form_dict: |
| 70 | webnotes.handler.handle() |
| 71 | else: |
Rushabh Mehta | 8ebf4e2 | 2012-02-07 13:31:09 +0530 | [diff] [blame] | 72 | import webnotes.cms.index |
Rushabh Mehta | 9ef63f9 | 2012-02-01 14:47:29 +0530 | [diff] [blame] | 73 | print "Content-Type: text/html" |
| 74 | webnotes.handler.print_cookies() |
| 75 | print |
Rushabh Mehta | 8ebf4e2 | 2012-02-07 13:31:09 +0530 | [diff] [blame] | 76 | print webnotes.cms.index.get() |
Rushabh Mehta | 5ede3e8 | 2011-09-08 14:16:34 +0530 | [diff] [blame] | 77 | |
Rushabh Mehta | 9ef63f9 | 2012-02-01 14:47:29 +0530 | [diff] [blame] | 78 | if __name__=="__main__": |
Rushabh Mehta | da27db4 | 2012-02-28 12:17:08 +0100 | [diff] [blame] | 79 | if init(): |
| 80 | respond() |