Opened 10 years ago

Closed 10 years ago

Last modified 10 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:


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 to expose wsgi from apache, optionally with a modified handler ( to get "php-like" functionality* (both files included),
  • Over apache + mod_wsgi, fastcgi, etc. (not tested)
  • As a standalone cgi python script, usigng wrapper (included)

The file 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/ 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 and 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 10 years ago.
svn diff output (8.6 KB) - added by reingart 10 years ago.
Python QuickUpload (pre #454, for version 2.4) (23.3 KB) - added by reingart 10 years ago.
Unified Python Connector for 2.5 (updated) (6.2 KB) - added by reingart 10 years ago.
Config File (updated) - Connector Disabled

Download all attachments as: .zip

Change History (15)

Changed 10 years ago by reingart

svn diff output

comment:1 Changed 10 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 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.


Changed 10 years ago by reingart

Python QuickUpload (pre #454, for version 2.4)

comment:2 Changed 10 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?


comment:3 Changed 10 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 10 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


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 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 to the php one: "This file uploader is disabled. Please check the \"editor/filemanager/connectors/php/config.php\"" and the message in 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 10 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 10 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 10 years ago by reingart

Unified Python Connector for 2.5 (updated)

comment:7 Changed 10 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:

comment:8 Changed 10 years ago by alfonsoml

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

Fixed with [591]

Thank you again.

Changed 10 years ago by reingart

Config File (updated) - Connector Disabled

comment:9 Changed 10 years ago by reingart

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

File 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 10 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 10 years ago by fredck

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