mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 23:17:32 -06:00

This greatly reduced the amount of duplicate code in the DataBaseHandlers Not sure how secure this is SQL injections. Need to check that and maybe put in some guards. Using double underscores for now and only provide a getter. But then again why bother with an SQL injection as you can just as easily modify the Python code, and we still have the old Containers to fallback to if the Database gets corrupted. Contributes to CURA-6096
29 lines
1.4 KiB
Python
29 lines
1.4 KiB
Python
from typing import Generator
|
|
|
|
from UM.Settings.SQLQueryFactory import SQLQueryFactory, metadata_type
|
|
from UM.Settings.DatabaseContainerMetadataController import DatabaseMetadataContainerController
|
|
from UM.Settings.InstanceContainer import InstanceContainer
|
|
|
|
|
|
class QualityDatabaseHandler(DatabaseMetadataContainerController):
|
|
"""The Database handler for Quality containers"""
|
|
|
|
def __init__(self):
|
|
super().__init__(SQLQueryFactory(table = "qualities",
|
|
fields = {
|
|
"id": "text",
|
|
"name": "text",
|
|
"quality_type": "text",
|
|
"material": "text",
|
|
"variant": "text",
|
|
"global_quality": "bool",
|
|
"definition": "text",
|
|
"version": "text",
|
|
"setting_version": "text"
|
|
}))
|
|
self.container_type = InstanceContainer
|
|
|
|
def groomMetadata(self, metadata: metadata_type) -> metadata_type:
|
|
if "global_quality" not in metadata:
|
|
metadata["global_quality"] = "False"
|
|
return super().groomMetadata(metadata)
|