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

Improve handling of globals #61

Open
glpatcern opened this issue Mar 2, 2022 · 9 comments
Open

Improve handling of globals #61

glpatcern opened this issue Mar 2, 2022 · 9 comments

Comments

@glpatcern
Copy link
Member

This refers in particular to the core code base and the storage interfaces.

@osamaahmed17
Copy link
Contributor

osamaahmed17 commented Nov 18, 2023

@glpatcern I am interested to work on this tasks during my free time. One question before I start working on MAC, do I have to make these folder in the laptops main directory such as (etc, var) or wopi server in the project directory? I have referenced it below.
Screenshot 2023-11-18 at 14 08 24

@glpatcern
Copy link
Member Author

Hi there, those instructions refer to a production deployment, and as indicated they concern the system top-level folders. You can also run everything in a container, see the Dockerfile for details (where you see the same files in the container's top level folders).

@osamaahmed17
Copy link
Contributor

osamaahmed17 commented Dec 5, 2023

Thank you for the information. I was able to run the Wopi server on local in Ubuntu. When I go to http://192.168.1.106:8880/wopi , I get the follow screen.

Screenshot from 2023-12-06 00-58-19

However, when I go to any other route like "/wopi/iop/openinapp", it says "Client not authorized".

Furthermore, I researched some implementations for improving the handling of globals. One of the most elegant ways I was able to figure it out was by Flask. It provides the g object, which is a global namespace that can store data during the life of a request. @glpatcern , I would appreciate to know your opinion!

@glpatcern
Copy link
Member Author

However, when I go to any other route like "/wopi/iop/openinapp", it says "Client not authorized".

That means you didn't provide the required authorization token.

Furthermore, I researched some implementations for improving the handling of globals. One of the most elegant ways I was able to figure it out was by Flask. It provides the g object, which is a global namespace that can store data during the life of a request.

If it only survives during the life of a request, it does not fit the purpose: as you can see in the code, there are a number of global variables that live "forever", until the server is shut down.

@osamaahmed17
Copy link
Contributor

Thank you for the information! I have got two more points. 🙂

  • How do I add an authorization token?
  • Well there is another method that involves Flask's configuration handling. It allows you to set global settings that are accessible across the entire application. It is particularly useful for settings, constants, or configurations that remain constant throughout the app's lifespan. I believe this will cover all the variables that live forever, until the server is shut down.

@glpatcern
Copy link
Member Author

glpatcern commented Dec 6, 2023

How do I add an authorization token?

Please have a look at the examples such as https://github.com/cs3org/wopiserver/blob/master/tools/wopiopen.py

Well there is another method that involves Flask's configuration handling. It allows you to set global settings that are accessible across the entire application.

Can you share more details about this "other method"? Consider that here we're talking about global references to packages or classes, not just settings.

@osamaahmed17
Copy link
Contributor

For the first point, I am going through the file for authorization that you shared with me. 🙂

For the second point, I was considering putting all the globals in the app.config file and referencing them from there to get their value, but better global handling can also be achieved through custom Flask extensions or modules that encapsulate global references to packages or classes. It can help manage and organize these references more effectively.

@osamaahmed17
Copy link
Contributor

@glpatcern, I went through the file you shared with me and if the second point's method in the comment is fine for you, I will start working on this issue. 🙂

@glpatcern
Copy link
Member Author

Hi there, to me it's not yet clear the method you want to pursue. Maybe you could start with a minimal modification and PR to validate the principle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants