예제 #1
0
    def add_site(self):
        self.template_path = 'site_add.html'

        # get the site code
        site_code = self.request.get('site_code').strip()
        self.vars['site_code'] = site_code

        # return if there is no site_code, or we are not a post
        if (not site_code) or self.request.method != 'POST':
            return

        # check that the site_code is valid
        if not Site.is_code_valid(site_code):
            self.vars['site_code_error'] = "site code is not valid"
            return

        # check that the site_code is valid
        if Site.is_code_taken(site_code):
            self.vars['site_code_error'] = "site code already exists"
            return

        # ok to create
        site = Site(site_code=site_code, owner=self.person)
        site.put()

        # create the first shared secret
        SharedSecret.new_for_site(site)

        self.redirect('/site/' + site_code)
예제 #2
0
파일: site.py 프로젝트: evdb/Privatar
 def add_site(self):
     self.template_path = 'site_add.html'
     
     # get the site code
     site_code = self.request.get('site_code').strip()
     self.vars['site_code'] = site_code
     
     # return if there is no site_code, or we are not a post
     if (not site_code) or self.request.method != 'POST' :
         return
                 
     # check that the site_code is valid
     if not Site.is_code_valid( site_code ):
         self.vars['site_code_error'] = "site code is not valid"
         return
     
     # check that the site_code is valid
     if Site.is_code_taken( site_code ):
         self.vars['site_code_error'] = "site code already exists"
         return
     
     # ok to create
     site = Site( site_code=site_code, owner=self.person )
     site.put()
     
     # create the first shared secret
     SharedSecret.new_for_site( site )
     
     self.redirect('/site/' + site_code )
예제 #3
0
def get_privatar():
    global CACHED_PRIVATAR
    if not CACHED_PRIVATAR:
        # load the secret or return if there is none
        secret = SharedSecret.get_secret_for_site_code('privatar')
        if not secret: return None

        # create the privatar object and cache it
        CACHED_PRIVATAR = privatar('privatar', secret)
        CACHED_PRIVATAR.http_base = ''

    return CACHED_PRIVATAR
예제 #4
0
def get_privatar():
    global CACHED_PRIVATAR        
    if not CACHED_PRIVATAR:
        # load the secret or return if there is none
        secret = SharedSecret.get_secret_for_site_code('privatar')
        if not secret: return None

        # create the privatar object and cache it
        CACHED_PRIVATAR = privatar( 'privatar', secret)
        CACHED_PRIVATAR.http_base = ''
                    
    return CACHED_PRIVATAR
예제 #5
0
파일: avatar.py 프로젝트: evdb/Privatar
    def get_gravatar_md5(self):
        # extract the privatar code from the url
        privatar_code = re.findall('/avatar/([^/.]+)', self.request.path)[0]

        # get the site_code
        site_code, version  = privatar.extract_site_code_and_version( privatar_code )

        # load the shared_secret dictionary for the site key
        shared_secret = SharedSecret.get_secret_for_site_code_and_version( site_code, version )
        if not shared_secret:
            raise Exception( "ERROR - something is wrong with your request" )
        
        # decrypt md5
        email_md5 = privatar.extract_email_md5( privatar_code, shared_secret );

        return email_md5
예제 #6
0
파일: avatar.py 프로젝트: evdb/Privatar
    def get_gravatar_md5(self):
        # extract the privatar code from the url
        privatar_code = re.findall('/avatar/([^/.]+)', self.request.path)[0]

        # get the site_code
        site_code, version = privatar.extract_site_code_and_version(
            privatar_code)

        # load the shared_secret dictionary for the site key
        shared_secret = SharedSecret.get_secret_for_site_code_and_version(
            site_code, version)
        if not shared_secret:
            raise Exception("ERROR - something is wrong with your request")

        # decrypt md5
        email_md5 = privatar.extract_email_md5(privatar_code, shared_secret)

        return email_md5