Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#575 closed New Feature (fixed)

Python quick upload

Reported by: reingart Owned by: alfonsoml
Priority: Normal Milestone: FCKeditor 2.5 Beta
Component: Server : Python Version: FCKeditor 2.4.2
Keywords: Cc:

Description

As said in mailing list, I submit this patch with the python quick upload.

It based on upload.php, but rewritten in python as a WSGI app to be fully compatible with the latest python frameworks and servers, and faster than a standard cgi script.

It can run:

  • On any WSGI compilant server,
  • Over apache + mod_python, using modpython_gateway.py to expose wsgi from apache, optionally with a modified handler (wsgihandler.py) to get "php-like" functionality* (both files included),
  • Over apache + mod_wsgi, fastcgi, etc. (not tested)
  • As a standalone cgi python script, usigng cgi2wsgi.py wrapper (included)

The file config.py hold the general configuration (like config.php does), and care must be taken of implementation details in .htaccess (or whatever configuration file you server support)

"Php-like"* functionality is not necessary but it facilitates the deployment (no changes in fckconfig.js), and it makes cgi and wsgi operating modes behaving the same way. It consists on being able to:

  • use script filename in urls ( like .../upload/py/upload.py) instead of simply the script directory (.../upload/py/)
  • serve files from the same or child directories (if any)
  • do automatic reloading of source files (if not, apache server must be restarted manually to apply source code changes)
  • not need to specify PythonPath (if wsighandler.py and modpython_gateway.py are already inside PythonPath, that is in /usr/local/lib/python2.4/site-packages in debian, c:/python2.5/lib/site-packages in windows, or similar )

Attachments (4)

svn-diff.txt (25.0 KB) - added by reingart 9 years ago.
svn diff output
standalone-py-quickupload-2.4.zip (8.6 KB) - added by reingart 9 years ago.
Python QuickUpload (pre #454, for version 2.4)
unified-py-connector-2.5.zip (23.3 KB) - added by reingart 9 years ago.
Unified Python Connector for 2.5 (updated)
config.py (6.2 KB) - added by reingart 9 years ago.
Config File (updated) - Connector Disabled

Download all attachments as: .zip

Change History (15)

Changed 9 years ago by reingart

svn diff output

comment:1 Changed 9 years ago by alfonsoml

Hello reingart

I've tried to apply the patch with TortoiseSVN but I get an error on line 8.

Could you please make the file browser connector use the same config.py file, put everything in a single folder and upload a zip?

I could then add all of it to the changes for #454 as this was the last connector that did lack the quick upload feature.

Thanks

Changed 9 years ago by reingart

Python QuickUpload (pre #454, for version 2.4)

comment:2 Changed 9 years ago by reingart

I see #454 was closed, but python connector is still unchanged (at least in the svn trunk and developers branches).

I have uploaded to this ticket the unified connector for python, so, is there any problem with this code or just python will be unsupported in next release?

Regards

comment:3 Changed 9 years ago by alfonsoml

  • Milestone set to FCKeditor 2.5
  • Owner set to alfonsoml

Sorry, I didn't saw the uploaded file, the message must have get lost in the spam folder.

I'll take a look at it right now. (In fact I was planning to write you about it because it would be a pitty to not have it updated when we are so close :-) )

comment:4 Changed 9 years ago by alfonsoml

It looks nice to see all the work that you have done, although I don't understand python at all XD

Some minor details:
In PHP there were differences between the FileTypesPath and QuickUploadPath settings because by default they both pointed to different directories previously, but that problem doesn't exist in Python because there wasn't a quickUpload before, so this code can be more coherent by default changing

FileTypesPath['File'] 			= UserFilesPath + 'file/' 
FileTypesAbsolutePath['File'] 	= (not UserFilesAbsolutePath == '') and (UserFilesAbsolutePath + 'file/') or ''
QuickUploadPath['File']			= UserFilesPath 
QuickUploadAbsolutePath['File']	= UserFilesAbsolutePath

to

FileTypesPath['File'] 			= UserFilesPath + 'file/' 
FileTypesAbsolutePath['File'] 	= (not UserFilesAbsolutePath == '') and (UserFilesAbsolutePath + 'file/') or ''
QuickUploadPath['File']			= QuickUploadPath['File'] 
QuickUploadAbsolutePath['File']	= QuickUploadAbsolutePath['File']

(and the same with all the file types) so the uploaded files end up in the same place from both the filebrowser and the quickupload.

In the config.py you can add a note to remark what people must do, like renaming and configuring the htaccess.txt file

I'm not sure that the packager will process this files, so the connector should be really disabled by default and the part of the packager be removed.

The "connector is disabled" message points in upload.py to the php one: "This file uploader is disabled. Please check the \"editor/filemanager/connectors/php/config.php\"" and the message in connector.py doesn't specify the connector path.

Yes, I could do those changes myself, but before commiting the changes I would like to know if anybody sees any other thing to adjust. As I said you don't have to follow the same code that the PHP connector, just try to do it the best way in Python and also remember that you are free from backwards compatibility for the main part as most of the features didn't exist and you have ported them right now.

Thank you again, tomorrow I'll checkin the changes if there are no concerns about the code, so you can change the things that I've mentioned or any other that you find would be better for Python users.

comment:5 Changed 9 years ago by reingart

I don't undestand the first change (it would raise an error because QuickUploadPath['File'] is not defined elsewhere):

QuickUploadPath['File']         = QuickUploadPath['File'] 
QuickUploadAbsolutePath['File']	= QuickUploadAbsolutePath['File']

The correct one should be:

QuickUploadPath['File']	        = FileTypesPath['File']
QuickUploadAbsolutePath['File']	= FileTypesAbsolutePath['File']

Regarding the rest of the message, sorry if I copied the php connector "too literal" in some parts. I did it to maintain a base compatibility with fckeditor itself, just because the old python connector was a little buggy and not cleanly designed as the php connector. Anyway, In contrast with php one, I'd used several python features (advanced data types, object oriented design, multiple heritage) to mantain the code clean and compact, and improve future extensibility with other python apps (i.e. zope, plone, etc).

I will make the changes you've suggested, and please fell free to send me any other correction/adjustment so I can test it and submit the patch / zip file.

Regards and thanks you for this excellent editor,

comment:6 Changed 9 years ago by alfonsoml

Yes, you're right. I had my mind in another place while I copied the parts and didn't realize the mistake but you got the idea.

and don't be sorry about basing your code on the PHP, I only said that if you feel that something is better done some other way in Python then go ahead, but of course, your code is already done and (I suppose) working, so don't feel that I'm forcing you to change anything, I only said that you can try to make the connector and it's configuration file easy to use, you don't have to worry about backward compatibility like it happens in most of the other connectors.

Changed 9 years ago by reingart

Unified Python Connector for 2.5 (updated)

comment:7 Changed 9 years ago by reingart

Sorry for the delay. I've made the modifications (with a few bug fixes/ enhancements), tested them and uploaded in a zip file.

You can check it on:

http://www.nsis.com.ar/fckeditor/editor/filemanager/connectors/test.html http://www.nsis.com.ar/fckeditor/editor/filemanager/connectors/uploadtest.html http://www.nsis.com.ar/fckeditor/_samples/default.html

comment:8 Changed 9 years ago by alfonsoml

  • Resolution set to fixed
  • Status changed from new to closed

Fixed with [591]

Thank you again.

Changed 9 years ago by reingart

Config File (updated) - Connector Disabled

comment:9 Changed 9 years ago by reingart

Seeing the changeset, I forgotten to disable the connector per default:

File config.py Line 45 should be: Enabled = False

(I've uploaded the correct file)

Sorry for this little mistake, it 's a pitty not having the packager removing this things automatically (anyway, it is may fault :( )

comment:10 Changed 9 years ago by alfonsoml

Done in [595]

Maybe the packager would have removed the lines, but then if it's changed in the future we should have to remember to check that everything still works, and I think that in that case we could leave all the connectors enable by default in SVN, not only PHP and python.

comment:11 Changed 9 years ago by fredck

  • Component changed from File Browser to Server : Python
  • Keywords python removed
Note: See TracTickets for help on using tickets.
© 2003 – 2016 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy