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
def encode(self, value, mutation_context): child_data = self.get_child_data(mutation_context=mutation_context)
"Aligned" can't get child data using 'get_child_data' because of it has no stack menber.I suggest taking a approach like "Size" function to get the data associated with the request parameter.
Use-Case
My modified code is as follows: def encode(self, value, mutation_context): if self.request is not None and self.block_name is not None: target_block = self.request.resolve_name(self.context_path,self.block_name) child_data = target_block.render(mutation_context=mutation_context) padding_length = self._modulus - (len(child_data) % self._modulus) a, b = divmod(padding_length, len(self._pattern)) # remove return child_data return self._pattern * a + self._pattern[:b] else: return
Anything else?
No response
The text was updated successfully, but these errors were encountered:
Let me add a little more, def encode(self, value, mutation_context): if self.request is not None and self.block_name is not None: target_block = self.request.resolve_name(self.context_path,self.block_name) child_data = target_block.render(mutation_context=mutation_context) remainder = len(child_data) % self._modulus if remainder != 0: padding_length = self._modulus - (len(child_data) % self._modulus) a, b = divmod(padding_length, len(self._pattern)) return self._pattern * a + self._pattern[:b] else: return b"" else: return
When modal, we should add a judgment that the calculation result is 0 ,which means that the data is already aligned at this time.
The alignment primitive is not a request class object and does not have the children parameter during initialization. Therefore, its stack is empty. Therefore, the get_child_data method cannot be used.
Proposal
def encode(self, value, mutation_context): child_data = self.get_child_data(mutation_context=mutation_context)
"Aligned" can't get child data using 'get_child_data' because of it has no stack menber.I suggest taking a approach like "Size" function to get the data associated with the request parameter.
Use-Case
My modified code is as follows:
def encode(self, value, mutation_context): if self.request is not None and self.block_name is not None: target_block = self.request.resolve_name(self.context_path,self.block_name) child_data = target_block.render(mutation_context=mutation_context) padding_length = self._modulus - (len(child_data) % self._modulus) a, b = divmod(padding_length, len(self._pattern)) # remove return child_data return self._pattern * a + self._pattern[:b] else: return
Anything else?
No response
The text was updated successfully, but these errors were encountered: