comparison libervia.tac @ 308:0ca441ba4317

server_side: removed unecessary debug info during a file upload
author souliane <souliane@mailoo.org>
date Fri, 27 Dec 2013 13:59:06 +0100
parents 4f221f34bdc7
children 05e264e96a1c
comparison
equal deleted inserted replaced
307:44b46db7dfef 308:0ca441ba4317
859 Render method with some hacks: 859 Render method with some hacks:
860 - if login is requested, try to login with form data 860 - if login is requested, try to login with form data
861 - except login, every method is jsonrpc 861 - except login, every method is jsonrpc
862 - user doesn't need to be authentified for isRegistered, but must be for all other methods 862 - user doesn't need to be authentified for isRegistered, but must be for all other methods
863 """ 863 """
864 #start = time.time()
865 filename = self._getFileName(request) 864 filename = self._getFileName(request)
866 filepath = os.path.join(self.upload_dir, filename) 865 filepath = os.path.join(self.upload_dir, filename)
867 #FIXME: the uploaded file is fully loaded in memory at form parsing time so far 866 #FIXME: the uploaded file is fully loaded in memory at form parsing time so far
868 # (see twisted.web.http.Request.requestReceived). A custom requestReceived should 867 # (see twisted.web.http.Request.requestReceived). A custom requestReceived should
869 # be written in the futur. In addition, it is not yet possible to get progression informations 868 # be written in the futur. In addition, it is not yet possible to get progression informations
871 870
872 with open(filepath,'w') as f: 871 with open(filepath,'w') as f:
873 f.write(request.args[self.NAME][0]) 872 f.write(request.args[self.NAME][0])
874 873
875 def finish(d): 874 def finish(d):
876 #end = time.time()
877 #print "time spent in render: %fs" % (end - start)
878 error = isinstance(d, Exception) or isinstance (d, Failure) 875 error = isinstance(d, Exception) or isinstance (d, Failure)
879 request.write('KO' if error else 'OK') 876 request.write('KO' if error else 'OK')
880 # TODO: would be great to re-use the original Exception class and message 877 # TODO: would be great to re-use the original Exception class and message
881 # but it is lost in the middle of the backtrace and encapsulated within 878 # but it is lost in the middle of the backtrace and encapsulated within
882 # a DBusException instance --> extract the data from the backtrace? 879 # a DBusException instance --> extract the data from the backtrace?
916 @param filepath: full filepath on the server 913 @param filepath: full filepath on the server
917 @return: a tuple with the name of the async bridge method 914 @return: a tuple with the name of the async bridge method
918 to be called followed by its arguments. 915 to be called followed by its arguments.
919 """ 916 """
920 profile = ISATSession(request.getSession()).profile 917 profile = ISATSession(request.getSession()).profile
921 debug("fichier écrit:", filepath) # /!\ unicode output raises UnicodeDecodeError
922 return ("setAvatar", filepath, profile) 918 return ("setAvatar", filepath, profile)
923 919
924 920
925 class Libervia(service.Service): 921 class Libervia(service.Service):
926 922