You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use a modified version of the substitution by templates (https://support.getgrist.com/examples/2023-07-proposals-contracts/).
I added a function to get the days and months in French in the substitution of template. After adding this function (with the sandbox pyodide) it becomes impossible to add columns to any table, the error message appears :
error [pyodide error] RangeError: Maximum call stack size exceeded at wasm://wasm/02239a6e:wasm-function[3174]:0x25deab at wasm://wasm/02239a6e:wasm-function[3175]:0x26a9f5 at wasm://wasm/02239a6e:wasm-function[1045]:0x1asm9was/029/01a60/0wasm-function[2490]:0x1fdbb7 at wasm://wasm/02239a6e:wasm-function[2114]:0x1e4dbd at wasm://wasm/02239a6e:wasm-function[3174]:0x26719b at wasm://wasm/02239a6e:wasm-function[3175]:0x26a9m/15 wasm5
If I change the sandbox to gvisor, then the document works correctly.
fromdatetimeimportdatetime# Dictionnaires de traductionjours_fr= {
"Monday": "Lundi", "Mon": "Lun",
"Tuesday": "Mardi", "Tue": "Mar",
"Wednesday": "Mercredi", "Wed": "Mer",
"Thursday": "Jeudi", "Thu": "Jeu",
"Friday": "Vendredi", "Fri": "Ven",
"Saturday": "Samedi", "Sat": "Sam",
"Sunday": "Dimanche", "Sun": "Dim",
}
mois_fr= {
"January": "Janvier", "Jan": "Jan",
"February": "Février", "Feb": "Fév",
"March": "Mars", "Mar": "Mar",
"April": "Avril", "Apr": "Avr",
"May": "Mai", "May": "Mai",
"June": "Juin", "Jun": "Jun",
"July": "Juillet", "Jul": "Jul",
"August": "Août", "Aug": "Aoû",
"September": "Septembre", "Sep": "Sep",
"October": "Octobre", "Oct": "Oct",
"November": "Novembre", "Nov": "Nov",
"December": "Décembre", "Dec": "Déc",
}
# Finds all data associated with this recordclassFind_Data(dict):
def__missing__(self, key):
# Si la clé existe comme attribut dans `rec`ifhasattr(rec, key):
returngetattr(rec, key)
# Vérifie si la clé est un appel de fonction (exemple : "format_date(birth_date, '%d/%m/%Y')")match=re.match(r"(\w+)\((.+)\)", key)
ifmatch:
func_name, args=match.groups()
args= [arg.strip(" '\"") forarginargs.split(",")] # Traite les arguments comme des chaînesiffunc_nameinself:
returnself[func_name](*args) # Appelle la fonction correspondanteraiseKeyError(f"La clé ou l'attribut '{key}' est introuvable.")
def__init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self["format_date"] =self.format_date# Ajoute la fonction comme une clé#@staticmethoddefformat_date(date, fmt="%d %B %Y"):
"""Formate une date en français."""formatted_date=getattr(rec, date).strftime(fmt)
# Traduction des joursforeng, frinjours_fr.items():
formatted_date=formatted_date.replace(eng, fr)
# Traduction des moisforeng, frinmois_fr.items():
formatted_date=formatted_date.replace(eng, fr)
returnformatted_date# Finds the "modele" template in the Templates tabletemplate=Templates.lookupOne(nom="ev_rapport1").modele# Formats the template with fields from this table as well as fields from the referenced tabletemplate.format_map(Find_Data())
Template:
<p><spanstyle="color: #ff9900; font-size: 1em;">{Etablissement.Nom_complet}</span><br/><spanstyle="color: #ff9900;">{Type}</span><br/><spanstyle="font-size: 0.7em;">Du {format_date(Date_debut, '%A %d %B %Y %Ih%M')} au {format_date(Date_fin, '%A %d %B %Y %Ih%M')}.<br/>Il y a {Nb_Attendus} places, limite des inscriptions le {format_date(Date_limite, '%A %d %B %Y')}. <br/></span><spanstyle="color: #ff9900; font-size: 1.2em;">Lieu </span><br/><spanstyle="font-size: 0.7em;">{Etablissement.Contact}<br/>
{Etablissement.Adresse_complete_html}<br/>
waze://?ll={Etablissement.Latitude},{Etablissement.Longitude}&z=10</span><br/><spanstyle="color: #ff9900; font-size: 1.2em;">Complément d'information </span><br/><span>{Complement_d_information}</span></p>
Describe the current behavior
I use a modified version of the substitution by templates (https://support.getgrist.com/examples/2023-07-proposals-contracts/).
I added a function to get the days and months in French in the substitution of template. After adding this function (with the sandbox pyodide) it becomes impossible to add columns to any table, the error message appears :
error [pyodide error] RangeError: Maximum call stack size exceeded at wasm://wasm/02239a6e:wasm-function[3174]:0x25deab at wasm://wasm/02239a6e:wasm-function[3175]:0x26a9f5 at wasm://wasm/02239a6e:wasm-function[1045]:0x1asm9was/029/01a60/0wasm-function[2490]:0x1fdbb7 at wasm://wasm/02239a6e:wasm-function[2114]:0x1e4dbd at wasm://wasm/02239a6e:wasm-function[3174]:0x26719b at wasm://wasm/02239a6e:wasm-function[3175]:0x26a9m/15 wasm5
If I change the sandbox to gvisor, then the document works correctly.
Steps to reproduce
Duplicate
You can duplicate https://igrist.sdis66.fr/o/docs/ukJ1W3WQi7qb/Evenements-Anonymise?utm_id=share-doc
code
Template:
Describe the expected behavior
No response
Where have you encountered this bug?
Instance information (when self-hosting only)
The text was updated successfully, but these errors were encountered: