def METHOD_NAME(self, server_url, assoc=None):
    try:
        secret = base64.encodebytes(assoc.secret)
    except AttributeError:
        # Python 2.x compat
        secret = base64.encodestring(assoc.secret)
    else:
        secret = secret.decode()
    OpenIDStore.objects.create(
        server_url=server_url,
        handle=assoc.handle,
        secret=secret,
        issued=assoc.issued,
        lifetime=assoc.lifetime,
        assoc_type=assoc.assoc_type,
    )