Skip to content

Commit

Permalink
Merge branch 'develop' into msar_obj_removal_func
Browse files Browse the repository at this point in the history
  • Loading branch information
mathemancer committed Jan 10, 2025
2 parents d9d31ac + b287684 commit fff42e5
Show file tree
Hide file tree
Showing 198 changed files with 4,540 additions and 2,425 deletions.
5 changes: 5 additions & 0 deletions DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ Django uses gettext, which require the `.po` files to be compiled into a more ef
- To handle pluralization and other complexities, the source translation strings may utilize a special syntax called [JSON with ICU Plurals](https://help.transifex.com/en/articles/6220806-json-with-icu-plurals) (a subset of the [ICU format](https://unicode-org.github.io/icu/userguide/icu/i18n.html)).
- After making changes to your code, ensure that the source `/en/dict.json` file contains new translation strings, if any.
- Do not update other translation files. They will be pulled from our translation service provider when the translation process is complete.
- If you encounter merge conflicts in `en/dict.json`, run this script to automatically resolve them:
```
python3 mathesar_ui/src/i18n/scripts/resolve_dict_merge_conflicts.py
```
## Translation process
Expand Down
4 changes: 3 additions & 1 deletion config/settings/common_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def pipe_delim(pipe_string):
ROOT_URLCONF = "config.urls"

MODERNRPC_METHODS_MODULES = [
'mathesar.rpc.analytics',
'mathesar.rpc.collaborators',
'mathesar.rpc.columns',
'mathesar.rpc.columns.metadata',
Expand Down Expand Up @@ -231,7 +232,8 @@ def pipe_delim(pipe_string):
MATHESAR_UI_SOURCE_LOCATION = os.path.join(BASE_DIR, 'mathesar_ui/')
MATHESAR_CAPTURE_UNHANDLED_EXCEPTION = os.environ.get('CAPTURE_UNHANDLED_EXCEPTION', default=False)
MATHESAR_STATIC_NON_CODE_FILES_LOCATION = os.path.join(BASE_DIR, 'mathesar/static/non-code/')
MATHESAR_ANALYTICS_URL = os.environ.get('MATHESAR_ANALYTICS_URL', default='https://example.com')
MATHESAR_ANALYTICS_URL = os.environ.get('MATHESAR_ANALYTICS_URL', default='https://example.com/collector')
MATHESAR_INIT_REPORT_URL = os.environ.get('MATHESAR_INIT_REPORT_URL', default='https://example.com/hello')

DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'

Expand Down
2 changes: 2 additions & 0 deletions config/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# Override default settings
DEBUG = False
MATHESAR_MODE = 'PRODUCTION'
MATHESAR_ANALYTICS_URL = 'https://analytics.mathesar.dev/collect-analytics-reports'
MATHESAR_INIT_REPORT_URL = 'https://analytics.mathesar.dev/collect-initial-report'

'''
This tells Django to trust the X-Forwarded-Proto header that comes from our proxy,
Expand Down
25 changes: 24 additions & 1 deletion db/connection.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from psycopg.rows import dict_row
from uuid import uuid4


def exec_msar_func(conn, func_name, *args):
"""
Execute an msar function using a psycopg (3) connection.
Args:
conn: a psycopg connection
conn: a psycopg connection or cursor
func_name: The unqualified msar_function name (danger; not sanitized)
*args: The list of parameters to pass
"""
Expand All @@ -16,6 +17,28 @@ def exec_msar_func(conn, func_name, *args):
)


def exec_msar_func_server_cursor(conn, func_name, *args):
"""
Execute an msar function using a psycopg (3) connection and a server cursor.
Args:
conn: a psycopg connection or cursor
func_name: The unqualified msar_function name (danger; not sanitized)
*args: The list of parameters to pass
Note:
The server cursor must be properly closed during usage.
Use the pattern:
with connection.exec_msar_func_server_cursor(...) as cursor:
...
since the with statement automatically closes the cursor.
"""
server_cursor = conn.cursor(name=str(uuid4()))
return server_cursor.execute(
f"SELECT msar.{func_name}({','.join(['%s'] * len(args))})", args
)


def select_from_msar_func(conn, func_name, *args):
"""
Select all records from an msar function using a psycopg (3) connection.
Expand Down
Loading

0 comments on commit fff42e5

Please sign in to comment.