emilhe / dash-extensions

The dash-extensions package is a collection of utility functions, syntax extensions, and Dash components that aim to improve the Dash development experience
https://www.dash-extensions.com/
MIT License
409 stars 58 forks source link

Can't access kwarg `assets_folder` of dash_extensions.javascript.Namespace.dump #267

Open araichev opened 1 year ago

araichev commented 1 year ago

The above issue caused me a difficult-to-fix permissions error on my server, and i had to result to monkey patching to fix it. Would be easier if one could somehow configure the dump, assign, etc. functions to use a custom assets folder path.

emilhe commented 1 year ago

What do you think would be the prefered solution for this feature request? Some kind of auto detection of the assets folder used - or simply an (optional) argument to specify the assets folder?

araichev commented 1 year ago

Thanks for your response @emilhe. Maybe you can follow both approaches. But i would at least start by using as a default path the assets folder path set by the user in the DashProxy object. That will probably cover most use cases, including mine.

One way to do that is to move the assets_folder kwarg out of the dump method and into an attribute of the Namespace class, make dump reference that attribute, and set the attribute's value during instantiation (in line 56) to the assets folder path set in the DashProxy object.

Alternatively or additionally, you could give the user finer control of target directories by exposing the assets_folder kwarg in the assign function. But that might be overkill.

Hope that helps. Sorry i'm not familiar enough with the Dash Extension library to convert my suggestion above into a pull request.

emilhe commented 1 year ago

Could your intention be realised via the optional assets_folder kwarg of the dump function?

https://github.com/thedirtyfew/dash-extensions/blob/2bf9f451b6a448473384d54b22f825cfdf816fcf/dash_extensions/javascript.py#L32

araichev commented 1 year ago

Yes, but that kwarg is not accessible from the user-facing assign function. Also, it seems more natural for that kwarg to default to the location of the assets folder set when instantiating a DashProxy object. As it stands, if i set a custom assets folder when creating a DashProxy, it's not honoured by the assign function.