def to_creator(self, for_modify=False):
        """ Returns a dict object suitable for a 'CreateSignature'.

        A signature object for creation is like :

            <signature name="unittest">
              <content type="text/plain">My signature content</content>
            </signature>

        which is :

            {
             'name' : 'unittest',
             'content': {
               'type': 'text/plain',
               '_content': 'My signature content'
             }
            }

        Note that if the contenttype is text/plain, the content with text/html
        will be cleared by the request (for consistency).
        """
        signature = {}

        if for_modify:
            try:
                # we should have an ID
                signature['id'] = self.id
            except AttributeError:
                raise AttributeError('a modify request should specify an ID')
            # Case where we change or set a name
            if hasattr(self, 'name'):
                signature['name'] = self.name

        else:
            # a new signature should have a name
            signature['name'] = self.name

        if self.has_content():
            # Set one, flush the other (otherwise, we let relief behind...)
            if self._contenttype == 'text/plain':
                plain_text = self._content
                html_text = ''
            else:
                html_text = self._content
                plain_text = ''

            content_plain = {'type': 'text/plain', '_content': plain_text}
            content_html = {'type': 'text/html', '_content': html_text}

            signature['content'] = [content_plain, content_html]

        else:
            # A creation request should have a content
            if not for_modify:
                raise AttributeError(
                    'too little information on signature, '
                    'run setContent before')

        return signature
def to_creator ( self , for_modify = False ) : signature = { } if for_modify : try : signature [ 'id' ] = self . id except AttributeError : raise AttributeError ( 'a modify request should specify an ID' ) if hasattr ( self , 'name' ) : signature [ 'name' ] = self . name else : signature [ 'name' ] = self . name if self . has_content ( ) : if self . _contenttype == 'text/plain' : plain_text = self . _content html_text = '' else : html_text = self . _content plain_text = '' content_plain = { 'type' : 'text/plain' , '_content' : plain_text } content_html = { 'type' : 'text/html' , '_content' : html_text } signature [ 'content' ] = [ content_plain , content_html ] else : if not for_modify : raise AttributeError ( 'too little information on signature, ' 'run setContent before' ) return signature
Returns a dict object suitable for a 'CreateSignature'.

        A signature object for creation is like :

            <signature name="unittest">
              <content type="text/plain">My signature content</content>
            </signature>

        which is :

            {
             'name' : 'unittest',
             'content': {
               'type': 'text/plain',
               '_content': 'My signature content'
             }
            }

        Note that if the contenttype is text/plain, the content with text/html
        will be cleared by the request (for consistency).