27 lines
1002 B
Python
27 lines
1002 B
Python
from .operation import *
|
|
|
|
|
|
def get_backdrop_schema(name: str) -> dict[str, dict[str, Any]]:
|
|
return { 'content' : {'type': 'str' , 'optional': False , 'readonly': False} }
|
|
|
|
|
|
def get_backdrop(name: str) -> dict[str, Any]:
|
|
e = read(name, f"select * from backdrop")
|
|
return { 'content': e['content'] }
|
|
|
|
|
|
def set_backdrop_cache(name: str, cs: ChangeSet) -> SqlChangeSet:
|
|
old = get_backdrop(name)
|
|
|
|
redo_sql = f"update backdrop set content = '{cs.operations[0]['content']}' where content = '{old['content']}';"
|
|
undo_sql = f"update backdrop set content = '{old['content']}' where content = '{cs.operations[0]['content']}';"
|
|
|
|
redo_cs = g_update_prefix | { 'type': 'backdrop', 'content': cs.operations[0]['content'] }
|
|
undo_cs = g_update_prefix | { 'type': 'backdrop', 'content': old['content'] }
|
|
|
|
return SqlChangeSet(redo_sql, undo_sql, redo_cs, undo_cs)
|
|
|
|
|
|
def set_backdrop(name: str, cs: ChangeSet) -> ChangeSet:
|
|
return execute_command(name, set_backdrop_cache(name, cs))
|