Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
ovr committed Oct 26, 2023
1 parent 319825e commit 035cdd9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
16 changes: 11 additions & 5 deletions packages/cubejs-backend-native/src/template/mj_value/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,17 @@ impl StructObject for JinjaPythonObject {
let obj_ref = &self.inner as &PyObject;

Python::with_gil(|py| {
let mut fields = vec![];

if let Ok(dict_ref) = obj_ref.downcast::<PyDict>(py) {
for key in dict_ref.keys() {
fields.push(key.to_string().into());
let mut fields: Vec<Arc<str>> = vec![];

match obj_ref.downcast::<PyDict>(py) {
Ok(dict_ref) => {
for key in dict_ref.keys() {
fields.push(key.to_string().into());
}
},
Err(err) => {
#[cfg(debug_assertions)]
log::trace!("Unable to extract PyDict: {:?}", err)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ exports[`Jinja (new api) render python.yml: python.yml 1`] = `
safe_string: \\"\\"safe string\\" <>\\"
dump:
dict_as_obj: \\"{}\\""
dict_as_obj: \\"{\\\\n \\\\\\"b_attr\\\\\\": String(\\\\n \\\\\\"value for attribute b\\\\\\",\\\\n Normal,\\\\n ),\\\\n \\\\\\"a_attr\\\\\\": String(\\\\n \\\\\\"value for attribute a\\\\\\",\\\\n Normal,\\\\n ),\\\\n}\\""
`;

exports[`Jinja (new api) render template_error.jinja: template_error.jinja 1`] = `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ def new_safe_string():

class MyCustomObject(dict):
def __init__(self):
self.attr_a = "value for attribute a"
self.attr_b = "value for attribute b"

self['a_attr'] = "value for attribute a"
self['b_attr'] = "value for attribute b"

@template.function
def new_object_from_dict():
Expand Down
4 changes: 2 additions & 2 deletions packages/cubejs-backend-native/test/templates/scoped-utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def new_safe_string():
class MyCustomObject(dict):
def __init__(self):
self.attr_a = "value for attribute a"
self.attr_b = "value for attribute b"
self['a_attr'] = "value for attribute a"
self['b_attr'] = "value for attribute b"
@context_func
def new_object_from_dict():
Expand Down

0 comments on commit 035cdd9

Please sign in to comment.