Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3 Flask connector #164

Closed
jsooter opened this issue Apr 21, 2017 · 25 comments
Closed

Python 3 Flask connector #164

jsooter opened this issue Apr 21, 2017 · 25 comments
Assignees
Milestone

Comments

@jsooter
Copy link

jsooter commented Apr 21, 2017

On the demo (fm.devale.pro) when I click on a file I see the file contents and can edit text files. However, on my server when I click on a file nothing happens. I see no output in the console either so I'm assuming file edit must be enabled but I'm not sure how. Here is my filemanager.config.json:

{
    "_comment": "IMPORTANT : go to the wiki page to know about options configuration https://github.com/servocoder/RichFilemanager/wiki/Configuration-options",
    "options": {
        "culture": "en",
        "theme": "default",
        "defaultViewMode": "grid",
        "localizeGUI": true,
        "showFullPath": false,
        "showTitleAttr": false,
        "showConfirmation": true,
        "browseOnly": false,
        "clipboard": true,
        "searchBox": true,
        "fileSorting": "NAME_ASC",
        "folderPosition": "bottom",
        "quickSelect": false,
        "logger": false,
        "allowChangeExtensions": false,
        "capabilities": [
            "select",
            "upload",
            "download",
            "rename",
            "copy",
            "move",
            "replace",
            "delete",
            "extract",
            "edit"
        ]
    },
    "filetree": {
        "enabled": true,
        "foldersOnly": false,
        "reloadOnClick": true,
        "expandSpeed": 200,
        "showLine": true,
        "width": 200,
        "minWidth": 200
    },
    "manager": {
        "dblClickOpen": false,
        "selection": {
            "enabled": true,
            "useCtrlKey": true
        },
        "renderer": {
            "position": false,
            "indexFile": "readme.md"
        }
    },
    "api": {
        "lang": "python",
        "connectorUrl": "/custom/connectors/python/filemanager",
        "requestParams": []
    },
    "security": {
        "allowNoExtension": false
    },
    "upload": {
        "multiple": true,
        "maxNumberOfFiles": 5,
        "chunkSize": false
    },
    "viewer": {
        "absolutePath": false,
        "previewUrl": false,
        "image": {
            "enabled": true,
            "showThumbs": true,
            "thumbMaxWidth": 64,
            "extensions": [
                "jpg",
                "jpe",
                "jpeg",
                "gif",
                "png",
                "svg"
            ]
        },
        "video": {
            "enabled": true,
            "extensions": [
                "ogv",
                "mp4",
                "webm",
                "m4v"
            ],
            "playerWidth": 400,
            "playerHeight": 222
        },
        "audio": {
            "enabled": true,
            "extensions": [
                "ogg",
                "mp3",
                "wav"
            ]
        },
        "opendoc": {
            "enabled": true,
            "extensions": [
                "pdf",
                "odt",
                "odp",
                "ods"
            ],
            "readerWidth": "640",
            "readerHeight": "480"
        },
        "google": {
            "enabled": true,
            "extensions": [
                "doc",
                "docx",
                "xls",
                "xlsx",
                "ppt",
                "pptx"
            ],
            "readerWidth": "640",
            "readerHeight": "480"
        },
        "codeMirrorRenderer": {
            "enabled": true,
            "extensions": [
                "txt",
                "csv",
                "xml",
                "cnf"
            ]
        },
        "markdownRenderer": {
            "enabled": true,
            "extensions": [
                "md"
            ]
        },
        "editable": {
            "enabled": true,
            "theme": "default",
            "lineNumbers": true,
            "lineWrapping": true,
            "codeHighlight": true,
            "matchBrackets": true,
            "extensions": [
                "txt",
                "csv",
                "md",
                "xml",
                "cnf"
            ]
        }
    },
    "customScrollbar": {
    	"enabled": true,
    	"theme": "inset-2-dark",
    	"button": true
    },
    "extras": {
        "extra_js": [],
        "extra_js_async": true
    },
    "url": "https://github.com/servocoder/RichFilemanager",
    "version": "2.3.2"
}
@psolom
Copy link
Owner

psolom commented Apr 21, 2017

File editing is enabled by default. I can see you use python connector. It's outdated. The only actual comectors are PHP and Java. I'm not Python developer and can't help you, but you can update the connector by your own. I would appreciate if you become a maintainer of Python connector.

@jsooter
Copy link
Author

jsooter commented Apr 21, 2017

I'm so sorry, it was a typo on my part. In the getfile and getfolder modes I had set type incorrectly. It works now.

I'm adapting this to python 3 and flask. I may be able to share the python-flask connector blueprint when I'm done.

@psolom
Copy link
Owner

psolom commented Apr 21, 2017

That would be great! Keep in mind that I'm going to remove "replace" action at the next release. It's rarely used and actual not very helful. So you don't have to adapt "replace" action at the server-side. It would be better if you just remove it.

If you use PHP connector as an example for implementation (I recommend you to do, because it supports all client-side features), I would strongly recomend you to examine "refactored" branch, which implements new security model and will be released in the next version. The refactoring is in progress, be aware.

Pay particular attention to the backend configuration file. It will give you an idea of the most of server-side features of PHP connector which I would like to be implemented for Python connector. The location of the file may be changes due to refactoring process.

@jsooter
Copy link
Author

jsooter commented Apr 21, 2017

Thanks, I'll do that!

@psolom psolom changed the title Can't preview or edit files Python connector: can't preview or edit files May 6, 2017
@psolom
Copy link
Owner

psolom commented May 7, 2017

Hi @jsooter !

Since the latest release v2.4.0 PHP connector is moved to the separate repository and should be installed via composer. You can do the same for the Python connector that you are working on. Are not you?

Check out new location of configuration files.

Please let me know if you have any impediments while implementing Python connector. Also inform me if you stoped working on it and not going to proceed. I will close the issue in this case. Thanks anyhow.

@jsooter
Copy link
Author

jsooter commented May 8, 2017

I ran short of time last week and couldn't finish the python connector. If it works for you, I plan on creating a class for the connector as well as a Flask blueprint. Once I finish my own implementation I'll refactor that code, test it and submit a pull request (unless you want me to manage a connector repo).

The blueprint will allow users to drop the connector into a Flask site fairly easily with very little configuration.

BTW I like the new config location. It will allow me to recommend and set a default path so it works out of the box.

@psolom
Copy link
Owner

psolom commented May 8, 2017

Glad to hear you are keep going. I definetely want that you implement, manage and maintain Python connector in the future. I'm not good at Python and just would like it to be flexible and easy to install. The decision is yours, you know it better either way. Keep me informed on the implementation progress occasionally, please. Thus I will be aware that things are moving on. Thanks a lot for your efforts!

@psolom
Copy link
Owner

psolom commented May 18, 2017

Hey @jsooter
How are your doing with Python connector?

@jsooter
Copy link
Author

jsooter commented May 18, 2017 via email

@psolom
Copy link
Owner

psolom commented May 18, 2017

Excellent news!
Looking forward for your PR.

Could your also create md file with detailed description on how to deploy, setup and configure of Python connector? Similar to PHP connector article. I will create a new article at the base of your file in the wiki Connectors section.

If you are going to push Python connector in a separate repository, you can keep detailed index ReadMe.md file at your repository, and just write a short article for the main RichFilemanager wiki repository, as it's done for PHP connector

@jsooter
Copy link
Author

jsooter commented May 18, 2017 via email

@jsooter
Copy link
Author

jsooter commented May 21, 2017

I have setup a repo for a working example of Python3 and Flask with Rich Filemanager.
https://github.com/jsooter/RichFilemanager-Python3Flask
It's a start. I'll work on that documentation next.

@psolom psolom changed the title Python connector: can't preview or edit files Python 3 Flask connector May 21, 2017
@psolom
Copy link
Owner

psolom commented May 21, 2017

Great!

What about the entry point for your connector? You can see file filemanager.php inside PHP connector folder. It serves for easy start and provides some configuration examples. Is this approach applicable for your connector?

At the moment there is outdated filemanager.py file located inside Python folder. Since it's useless you can replace its content and turn it into an entry point for your connector. What do you think?

@jsooter
Copy link
Author

jsooter commented May 23, 2017

What I created was a Python Flask application which works without Apache. In Flask static files should be located in the static directory.

I have used Mod WSGI to run a flask application in parallel with Apache, which would allow the folder structure you're requesting but the setup is complex.

The current python connector (included with RichFilemanager) uses Mod Python, which I have never used. It may be possible to fix that connector, which is the next thing I planned on doing.

As far as I know it is not possible to run Flask with Mod Python. Since I used Flask for my project It made sense to share it and was fairly easy to make a stand-alone implementation.

@psolom
Copy link
Owner

psolom commented May 24, 2017

I see. Concerning to your reply I think the extensive description article is required to describe all the things. It will help a lot for users who are going to use your Python Flask connector.

It may be possible to fix that connector, which is the next thing I planned on doing.

Excellent news. I hope it will be much easier for you to implement it, since you already have experience and code base, which may be reused probably.

@psolom
Copy link
Owner

psolom commented May 26, 2017

Hi @jsooter
Any updates on docs for wiki?

I'm going to mention your connector as a part of the next release but it may be tricy fo rcustomers without docs.

@jsooter
Copy link
Author

jsooter commented May 26, 2017

It's been a busy week, I'll get it done this weekend for sure. I looked into mod python and it looks like development has fallen off.

I think most people are using wsgi so I was thinking of building an apache/flask app so the folder structure could stay the same. However, configuration would be more complicated.

I think it would be good to have both the stand-alone flask app and the wsgi version.

@psolom
Copy link
Owner

psolom commented May 26, 2017

I'll get it done this weekend for sure.

Great, nice to hear!

I looked into mod python and it looks like development has fallen off.

Yeap, it's completely outdated and should be rewritten or replaced,

I think it would be good to have both the stand-alone flask app and the wsgi version.

Absolutely agree and hope that you will find time for this.

@psolom
Copy link
Owner

psolom commented Jun 3, 2017

Hi @jsooter
Any chance to get update on the stuss that we discussed soon?

@jsooter
Copy link
Author

jsooter commented Jun 5, 2017

I've added more details and description to the readme but I just haven't had time to setup and test the WSGI version. I'll set a goal to get that wrapped up by the end of this week.

@psolom
Copy link
Owner

psolom commented Jun 5, 2017

Good. Looking forward.

@psolom
Copy link
Owner

psolom commented Jun 10, 2017

I have just released v2.5.0 and noted your Python Flask connector in release notes. Now it more actual than before to create a simple Wiki article for the Richfilemanager repository, which will contain a few sentences describing your connector and link to your repository, so others could follow it. See my original request here. You can send a md file as an attachment and I will add it ti the wiki. Thanks in advance.

@psolom
Copy link
Owner

psolom commented Jun 10, 2017

I'm going to add this article to the Connectors section of the Wiki

@psolom psolom added this to the 2.5.0 milestone Jun 11, 2017
@psolom
Copy link
Owner

psolom commented Jun 11, 2017

Ok, I have created the wiki article:
https://github.com/servocoder/RichFilemanager/wiki/Python-3-Flask-connector

Let me know if you want to add something to this article.
Btw, is there any update on wsgi version?

@psolom
Copy link
Owner

psolom commented Jul 15, 2017

I close this issue due to inactivity.
Create new issue if you would like back to implementation of wsgi version.

@psolom psolom closed this as completed Jul 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants