(self, request=None)
Save plugin data.

        We want to save the generated lorem ipsum text for later use.
        Thus, although we don't show it to the user, in case when
        ``generate_lipsum`` field is set to True, we silently generate the
        text and save it into the plugin data.
Save plugin data.
Save plugin data .
def save_plugin_data(self, request=None):
        """Save plugin data.

        We want to save the generated lorem ipsum text for later use.
        Thus, although we don't show it to the user, in case when
        ``generate_lipsum`` field is set to True, we silently generate the
        text and save it into the plugin data.
        """
        if self.cleaned_data.get('generate_lipsum', None):
            lipsum_language = self.cleaned_data.get('lipsum_language', None)
            try:
                if lipsum_language in LANGUAGE_CHOICES_KEYS:
                    if lipsum_language == 'en':
                        gen = Generator()
                    else:
                        gen = TranslipsumGenerator(
                            language_code=lipsum_language
                        )
                    text = gen.generate_paragraph()
                    truncator = Truncator(text)
                    self.cleaned_data['text'] = truncator.chars(
                        self.cleaned_data.get('lipsum_max_chars',
                                              DEFAULT_MAX_CHARS)
                    )
            except Exception as err:
                if DEBUG:
                    logger.debug(err)
def save_plugin_data ( self , request = None ) : if self . cleaned_data . get ( 'generate_lipsum' , None ) : lipsum_language = self . cleaned_data . get ( 'lipsum_language' , None ) try : if lipsum_language in LANGUAGE_CHOICES_KEYS : if lipsum_language == 'en' : gen = Generator ( ) else : gen = TranslipsumGenerator ( language_code = lipsum_language ) text = gen . generate_paragraph ( ) truncator = Truncator ( text ) self . cleaned_data [ 'text' ] = truncator . chars ( self . cleaned_data . get ( 'lipsum_max_chars' , DEFAULT_MAX_CHARS ) ) except Exception as err : if DEBUG : logger . debug ( err )