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

Allow definition of custom functions / classes at document level #386

Open
jperon opened this issue Dec 31, 2022 · 5 comments
Open

Allow definition of custom functions / classes at document level #386

jperon opened this issue Dec 31, 2022 · 5 comments
Labels
enhancement New feature or request

Comments

@jperon
Copy link

jperon commented Dec 31, 2022

This is an idea I had several times, but which is very well illustrated by this case: it’s sometimes necessary to use custom functions / classes, and while they can be defined within column formulas, this leads to code duplication. It would be very handy if we had a way to add python code that would go to the top of the code, just after imports:

import grist
from functions import *       # global uppercase functions
import datetime, math, re     # modules commonly needed in formulas

<<<HERE WOULD GO CUSTOM CODE>>>

In the case linked, this would allow to define SList at the document level, not within the function body.

@jperon
Copy link
Author

jperon commented Dec 31, 2022

While thinking about it, it would also be practical to have the option to define class functions for each table.

@dmw24
Copy link

dmw24 commented Jan 23, 2023

This would be super helpful keeping my DB functions clean and easy to update

@paulfitz paulfitz added the enhancement New feature or request label Jan 23, 2023
@emanuelegissi
Copy link

Yes, indeed very useful

@paulfitz
Copy link
Member

paulfitz commented Feb 9, 2024

It does seems a good idea. For UI, I could imagine an editable region in the Code Viewer. The data engine would need a bit of tweaking to make it use the code, and update correctly when it changes. If anyone wants to take a shot at it, it does seem an achievable feature, though not trivial.

@kamilmodest
Copy link

kamilmodest commented Apr 8, 2024

While it's not a solution, unfortunately, but a workaround that could be helpful for someone who found this page via googling:

https://community.getgrist.com/t/install-third-party-libraries/1087/3

TL;DR; you need to create your own Dockerfile with injecting all the necessary additional Python libraries in it.

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

No branches or pull requests

5 participants