Exemple #1
0
    def __request_second_block(self):
        """ """            
        form                     = self.params
        old_url                  = self.page['url']
        self.page['url']         = {}
        self.page['title']       = {}
        self.page['description'] = {}
        
        for i in range(10):
            key = 'url_%s' % i
            if key in self.page:
                del(self.page[key])

        self.page['url']         = form['url']
        self.page['title']       = form['title']
        self.page['description'] = form['description']
        
        # Get URL, Title and Description in any languages
        for code in self.languages:

            if self.message is None:
                error_in = ' ( ' + code + ' )'
                
                # If the url is changed
                if old_url[code] != self.page['url'][code]:
                    url_list = self.__get_url_list(code)
                    num_urls = len(url_list)
                    
                    for code_two in self.languages:
                        field = "url_{}.{}".format(num_urls, code_two)
                        page_id = ensure_objectid(self.page["_id"]) if "_id" in self.page else None
                        available_url = g.db.pages.find_one({ field: url_list, "_id": { "$ne": page_id } })
                    print available_url
                    
                    # Check that the url is a maximum of 200 characters
                    if not check.length(self.page['url'][code], 0, 200):
                        self.message = g.pages_msg('error_b_2') + error_in
                    
                    # Verify that the format of the url is correct
                    elif len(self.page['url'][code]) and not check.url_two(self.page['url'][code]):
                        print 3, self.page['url'][code]
                        self.message = g.pages_msg('error_b_3') + error_in
                    
                    # Raises an error message if url is not available.
                    elif not available_url is None:
                        self.message = g.pages_msg('error_b_4') + error_in
                else:
                    url_list = self.__get_url_list(code)
                    num_urls = len(url_list)
                
                if not self.message:
                    kind_of_url = 'url_{}'.format(num_urls)
                    if not kind_of_url in self.page:
                        self.page[kind_of_url] = {}
                    self.page[kind_of_url][code] = url_list
Exemple #2
0
    def __request_second_block(self):
        """ """            
        form                     = self.params
        old_url                  = self.page['url']
        self.page['url']         = {}
        self.page['title']       = {}
        self.page['description'] = {}
        
        for i in range(10):
            key = 'url_%s' % i
            if key in self.page:
                del(self.page[key])

        self.page['url']         = form['url']
        self.page['title']       = form['title']
        self.page['description'] = form['description']
        
        # Get URL, Title and Description in any languages
        for code in self.languages:

            if self.message is None:
                error_in = ' ( ' + code + ' )'
                
                # If the url is changed
                if old_url[code] != self.page['url'][code]:
                    url_list = self.__get_url_list(code)
                    num_urls = len(url_list)
                    
                    for code_two in self.languages:
                        field = "url_{}.{}".format(num_urls, code_two)
                        page_id = ensure_objectid(self.page["_id"]) if "_id" in self.page else None
                        available_url = g.db.pages.find_one({ field: url_list, "_id": { "$ne": page_id } })
                    print available_url
                    
                    # Check that the url is a maximum of 200 characters
                    if not check.length(self.page['url'][code], 0, 200):
                        self.message = g.pages_msg('error_b_2') + error_in
                    
                    # Verify that the format of the url is correct
                    elif len(self.page['url'][code]) and not check.url_two(self.page['url'][code]):
                        print 3, self.page['url'][code]
                        self.message = g.pages_msg('error_b_3') + error_in
                    
                    # Raises an error message if url is not available.
                    elif not available_url is None:
                        self.message = g.pages_msg('error_b_4') + error_in
                else:
                    url_list = self.__get_url_list(code)
                    num_urls = len(url_list)
                
                if not self.message:
                    kind_of_url = 'url_{}'.format(num_urls)
                    if not kind_of_url in self.page:
                        self.page[kind_of_url] = {}
                    self.page[kind_of_url][code] = url_list
Exemple #3
0
 def __request_first_block(self):
     """ """
     form                = self.params
     old_name            = self.page['name']
     self.page['name']   = form['name']
     self.page['from']   = form['from']
     self.page['import'] = form['import']
     self.page['file']   = form['file']
             
     # Check that the name field is not empty
     if not len(form['name']):
         self.message = g.pages_msg('error_1')
     
     # If the name is changed
     elif old_name.lower() != self.page['name'].lower():
         try:
             new_name = str.lower(str(self.page['name']))
             regx = re.compile('^'+new_name+'$', re.IGNORECASE)
             available_name = g.db.pages.find_one({"name" : regx })
         except:
             available_name = 'Error invalid expression'
         
         # Check that the name has between 2 and 20 characters
         if not check.length(self.page['name'], 2, 20):
             self.message = g.pages_msg('error_2')
         
         # Verify that the format of the name is correct
         elif not check.username(self.page['name']):
             self.message = g.pages_msg('error_3')
         
         # Raises an error message if username is not available.
         elif not available_name is None:
             self.message = g.pages_msg('error_4')
             
     # ~
     if len(self.page['from']) and self.message is None:
         # Check that the "from" value has between 2 and 20 characters
         if not check.length(self.page['from'], 2, 20):
             self.message = g.pages_msg('error_5')
         
         # Verify that the format of the "from" value is correct
         elif not check.username(self.page['from']):
             self.message = g.pages_msg('error_6')
                          
         # Check that the "import" value has between 2 and 20 characters
         elif not check.length(self.page['import'], 2, 20):
             self.message = g.pages_msg('error_7')
         
         # Verify that the format of the "import" value is correct
         elif not check.username(self.page['import']):
             self.message = g.pages_msg('error_8')
             
     # Check that the file name field is not empty
     elif not len(self.page['file']) and self.message is None:
         self.message = g.pages_msg('error_9')
Exemple #4
0
    def __request_first_block(self):
        """ """
        form = request.form
        old_name = self.page['name']
        self.page['name'] = form['name']
        self.page['from'] = form['from']
        self.page['import'] = form['import']
        self.page['file'] = form['file']

        # Check that the name field is not empty
        if not len(form['name']):
            self.message = g.pages_msg('error_1')

        # If the name is changed
        elif old_name.lower() != self.page['name'].lower():
            try:
                new_name = str.lower(str(self.page['name']))
                regx = re.compile('^' + new_name + '$', re.IGNORECASE)
                available_name = g.db.pages.find_one({"name": regx})
            except:
                available_name = 'Error invalid expression'

            # Check that the name has between 2 and 20 characters
            if not check.length(self.page['name'], 2, 20):
                self.message = g.pages_msg('error_2')

            # Verify that the format of the name is correct
            elif not check.username(self.page['name']):
                self.message = g.pages_msg('error_3')

            # Raises an error message if username is not available.
            elif not available_name is None:
                self.message = g.pages_msg('error_4')

        # ~
        if len(self.page['from']) and self.message is None:
            # Check that the "from" value has between 2 and 20 characters
            if not check.length(self.page['from'], 2, 20):
                self.message = g.pages_msg('error_5')

            # Verify that the format of the "from" value is correct
            elif not check.username(self.page['from']):
                self.message = g.pages_msg('error_6')

            # Check that the "import" value has between 2 and 20 characters
            elif not check.length(self.page['import'], 2, 20):
                self.message = g.pages_msg('error_7')

            # Verify that the format of the "import" value is correct
            elif not check.username(self.page['import']):
                self.message = g.pages_msg('error_8')

        # Check that the file name field is not empty
        elif not len(self.page['file']) and self.message is None:
            self.message = g.pages_msg('error_9')
Exemple #5
0
    def __request_first_block(self):
        """ """
        form = request.form
        old_name = self.page["name"]
        self.page["name"] = form["name"]
        self.page["from"] = form["from"]
        self.page["import"] = form["import"]
        self.page["file"] = form["file"]

        # Check that the name field is not empty
        if not len(form["name"]):
            self.message = g.pages_msg("error_1")

        # If the name is changed
        elif old_name.lower() != self.page["name"].lower():
            try:
                new_name = str.lower(str(self.page["name"]))
                regx = re.compile("^" + new_name + "$", re.IGNORECASE)
                available_name = g.db.pages.find_one({"name": regx})
            except:
                available_name = "Error invalid expression"

            # Check that the name has between 2 and 20 characters
            if not check.length(self.page["name"], 2, 20):
                self.message = g.pages_msg("error_2")

            # Verify that the format of the name is correct
            elif not check.username(self.page["name"]):
                self.message = g.pages_msg("error_3")

            # Raises an error message if username is not available.
            elif not available_name is None:
                self.message = g.pages_msg("error_4")

        # ~
        if len(self.page["from"]) and self.message is None:
            # Check that the "from" value has between 2 and 20 characters
            if not check.length(self.page["from"], 2, 20):
                self.message = g.pages_msg("error_5")

            # Verify that the format of the "from" value is correct
            elif not check.username(self.page["from"]):
                self.message = g.pages_msg("error_6")

            # Check that the "import" value has between 2 and 20 characters
            elif not check.length(self.page["import"], 2, 20):
                self.message = g.pages_msg("error_7")

            # Verify that the format of the "import" value is correct
            elif not check.username(self.page["import"]):
                self.message = g.pages_msg("error_8")

        # Check that the file name field is not empty
        elif not len(self.page["file"]) and self.message is None:
            self.message = g.pages_msg("error_9")
Exemple #6
0
 def update(self):
     """ Update page in the database """
     if g.my['rank'] < 15:
         self.__request_first_block()
         
     self.__request_second_block()
     self.__request_label_and_alias()
     self.__request_values()
     
     if self.message is None:
         try:
             g.db.pages.update({ '_id' : ObjectId(self.page['_id']) }, self.page)
             self.status = 'msg msg-success'
             self.message = g.pages_msg('success_update_page')
         except PyMongoError:
             self.message = g.pages_msg('error_mongo_update')
             
     return False
Exemple #7
0
    def update(self):
        """ Update page in the database """
        if g.my["rank"] < 15:
            self.__request_first_block()

        self.__request_second_block()
        self.__request_label_and_alias()
        self.__request_values()

        if self.message is None:
            try:
                g.db.pages.update({"_id": ObjectId(self.page["_id"])}, self.page)
                self.status = "msg msg-success"
                self.message = g.pages_msg("success_update_page")
            except PyMongoError:
                self.message = g.pages_msg("error_mongo_update")

        return False
Exemple #8
0
 def new(self):
     """ Insert new page in the database """
     if g.my['rank'] < 15:
         self.__request_first_block()
         
     self.__request_second_block()
     self.__request_content()
     self.__request_values()
     
     if self.message is None:
         try:
             g.db.pages.insert(self.page)
             self.success = True
             self.status = 'msg msg-success'
             self.message = g.pages_msg('success_update_page')
         except PyMongoError:
             self.message = g.pages_msg('error_mongo_new')
             
     return False
Exemple #9
0
 def new(self):
     """ Insert new page in the database """
     if g.my['rank'] < 15:
         self.__request_first_block()
         
     self.__request_second_block()
     self.__request_content()
     self.__request_values()
     
     if self.message is None:
         try:
             g.db.pages.insert(self.page)
             self.success = True
             self.status = 'msg msg-success'
             self.message = g.pages_msg('success_update_page')
         except PyMongoError:
             self.message = g.pages_msg('error_mongo_new')
             
     return False
Exemple #10
0
    def update(self):
        """ Update page in the database """
        if g.my['rank'] < 15:
            self.__request_first_block()

        self.__request_second_block()
        self.__request_label_and_alias()
        self.__request_values()

        if self.message is None:
            try:
                g.db.pages.update({'_id': ObjectId(self.page['_id'])},
                                  self.page)
                self.status = 'msg msg-success'
                self.message = g.pages_msg('success_update_page')
            except PyMongoError:
                self.message = g.pages_msg('error_mongo_update')

        return False
Exemple #11
0
    def new(self, my_rank=100):
        """ Insert new page in the database """
        if my_rank < 15:
            self.__request_first_block()

        self.__request_second_block()
        self.__request_content()
        self.__request_values()

        if self.message is None:
            model.pages.create(page=self.page)
            self.success = True
            self.status = 'msg msg-success'
            self.message = g.pages_msg('success_update_page')
        return False
Exemple #12
0
 def new(self, my_rank=100):
     """ Insert new page in the database """
     if my_rank < 15:
         self.__request_first_block()
         
     self.__request_second_block()
     self.__request_content()
     self.__request_values()
     
     if self.message is None:
         model.pages.create(page=self.page)
         self.success = True
         self.status = 'msg msg-success'
         self.message = g.pages_msg('success_update_page')
     return False
Exemple #13
0
    def update(self):
        """ Update page in the database """
        if g.my['rank'] < 15:
            self.__request_first_block()

        self.__request_second_block()
        self.__request_content()
        self.__request_values()

        if self.message is None:
            model.pages.update(page_id=self.page['_id'], page=self.page)
            self.success = True
            self.status = 'msg msg-success'
            self.message = g.pages_msg('success_update_page')

        return False
Exemple #14
0
 def update(self):
     """ Update page in the database """
     if g.my['rank'] < 15:
         self.__request_first_block()
         
     self.__request_second_block()
     self.__request_content()
     self.__request_values()
     
     if self.message is None:
         model.pages.update(page_id=self.page['_id'], page=self.page)
         self.success = True
         self.status = 'msg msg-success'
         self.message = g.pages_msg('success_update_page')
             
     return False
Exemple #15
0
    def new(self):
        """ Insert new page in the database """
        if g.my['rank'] < 15:
            self.__request_first_block()

        self.__request_second_block()
        self.__request_label_and_alias()
        self.__request_values()

        if self.message is None:
            try:
                g.db.pages.insert(self.page)
                return True
            except PyMongoError:
                self.message = g.pages_msg('error_mongo_new')

        return False
Exemple #16
0
    def new(self):
        """ Insert new page in the database """
        if g.my["rank"] < 15:
            self.__request_first_block()

        self.__request_second_block()
        self.__request_label_and_alias()
        self.__request_values()

        if self.message is None:
            try:
                g.db.pages.insert(self.page)
                return True
            except PyMongoError:
                self.message = g.pages_msg("error_mongo_new")

        return False
Exemple #17
0
    def __request_values(self):
        """ """
        form = request.form

        # get all the languages
        for code in self.languages:
            self.page['content'][code] = []

            # check until the number of last label
            for i in range(self.len_of_label):

                label = 'label_name_{}_{}'.format(code, i)
                alias = 'alias_name_{}_{}'.format(code, i)

                # Append label in the "page" if exist it
                if label in form and i in self.type_label:

                    row_label = {
                        'label': form[label],
                        'alias': form[alias],
                        'value': ""
                    }

                    error_in = ' ( ' + form[label] + ' )'

                    # Verify that the format of the "name label" is correct
                    if not check.username(row_label['label']) and len(
                            row_label['label']):
                        self.message = g.pages_msg('error_c_1') + error_in

                    # if label is an image
                    if self.type_label[i] is 3:
                        name_file = upload_file(code + '_' + str(i), 'page')
                        if name_file is None:
                            name_file = form['label_' + code + '_' + str(i) +
                                             '_hidden']
                        row_label['value'] = name_file
                    else:
                        value = 'label_{}_{}_{}'.format(
                            code, i, self.type_label[i])
                        row_label['value'] = form[value]

                    self.page['content'][code].append(row_label)
Exemple #18
0
 def __request_values(self):
     """ """
     form = request.form
     
     # get all the languages
     for code in self.languages:            
         self.page['content'][code] = []
         
         # check until the number of last label
         for i in range(self.len_of_label):
             
             label = 'label_name_{}_{}'.format(code, i)
             alias = 'alias_name_{}_{}'.format(code, i)
             
             # Append label in the "page" if exist it
             if label in form and i in self.type_label:
                 
                 row_label = { 
                     'label' : form[label], 
                     'alias' : form[alias], 
                     'value' : ""
                 }
                 
                 error_in = ' ( ' + form[label] + ' )'
                 
                 # Verify that the format of the "name label" is correct
                 if not check.username(row_label['label']) and len(row_label['label']):
                     self.message = g.pages_msg('error_c_1') + error_in
                 
                 # if label is an image
                 if self.type_label[i] is 3:
                     name_file = upload_file(code+'_'+str(i), 'page')
                     if name_file is None:
                         name_file = form['label_'+code+'_'+str(i)+'_hidden']
                     row_label['value'] = name_file
                 else:
                     value = 'label_{}_{}_{}'.format(code, i, self.type_label[i])
                     row_label['value'] = form[value] 
                 
                 self.page['content'][code].append( row_label )  
Exemple #19
0
    def __request_values(self):
        """ """
        form = request.form

        # get all the languages
        for code in self.languages:
            self.page["content"][code] = []

            # check until the number of last label
            for i in range(self.len_of_label):

                label = "label_name_{}_{}".format(code, i)
                alias = "alias_name_{}_{}".format(code, i)

                # Append label in the "page" if exist it
                if label in form and i in self.type_label:

                    row_label = {"label": form[label], "alias": form[alias], "value": ""}

                    error_in = " ( " + form[label] + " )"

                    # Verify that the format of the "name label" is correct
                    if not check.username(row_label["label"]) and len(row_label["label"]):
                        self.message = g.pages_msg("error_c_1") + error_in

                    # if label is an image
                    if self.type_label[i] is 3:
                        name_file = upload_file(code + "_" + str(i), "page")
                        if name_file is None:
                            name_file = form["label_" + code + "_" + str(i) + "_hidden"]
                        row_label["value"] = name_file
                    else:
                        value = "label_{}_{}_{}".format(code, i, self.type_label[i])
                        row_label["value"] = form[value]

                    self.page["content"][code].append(row_label)
Exemple #20
0
    def __request_second_block(self):
        """ """
        form = request.form
        old_url = self.page['url']
        self.page['url'] = {}
        self.page['title'] = {}
        self.page['description'] = {}

        for i in range(10):
            key = 'url_%s' % i
            if key in self.page:
                del (self.page[key])

        # Get URL, Title and Description in any languages
        for code in self.languages:
            self.page['url'][code] = form['url_' + code]
            self.page['title'][code] = form['title_' + code]
            self.page['description'][code] = form['description_' + code]

            if self.message is None:
                error_in = ' ( ' + code + ' )'

                # Check that the url field is not empty
                if not len(self.page['url'][code]):
                    self.message = g.pages_msg('error_b_1') + error_in

                # If the url is changed
                elif old_url[code] != self.page['url'][code]:
                    lista_url = self.page['url'][code].split('/')
                    # Convert list with strings all to lowercase
                    map(lambda x: x.lower(), lista_url)
                    if self.page['url'][code][-1] == '/':
                        lista_url.pop()
                    num_urls = len(lista_url)

                    try:
                        for code_two in self.languages:
                            field = "url_%s.%s" % (num_urls, code_two)
                            available_url = g.db.pages.find_one(
                                {field: lista_url})
                    except:
                        available_url = 'Error invalid expression'

                    # Check that the url is a maximum of 200 characters
                    if not check.length(self.page['url'][code], 0, 200):
                        self.message = g.pages_msg('error_b_2') + error_in

                    # Verify that the format of the url is correct
                    elif not check.url_two(self.page['url'][code]):
                        self.message = g.pages_msg('error_b_3') + error_in

                    # Raises an error message if url is not available.
                    elif not available_url is None:
                        self.message = g.pages_msg('error_b_4') + error_in
                else:
                    lista_url = old_url[code].split('/')
                    if old_url[code][-1] == '/':
                        lista_url.pop()
                    num_urls = len(lista_url)

                kind_of_url = 'url_%s' % num_urls
                if not kind_of_url in self.page:
                    self.page[kind_of_url] = {}
                self.page[kind_of_url][code] = lista_url
Exemple #21
0
    def __request_second_block(self):
        """ """
        form = request.form
        old_url = self.page["url"]
        self.page["url"] = {}
        self.page["title"] = {}
        self.page["description"] = {}

        for i in range(10):
            key = "url_%s" % i
            if key in self.page:
                del (self.page[key])

        # Get URL, Title and Description in any languages
        for code in self.languages:
            self.page["url"][code] = form["url_" + code]
            self.page["title"][code] = form["title_" + code]
            self.page["description"][code] = form["description_" + code]

            if self.message is None:
                error_in = " ( " + code + " )"

                # Check that the url field is not empty
                if not len(self.page["url"][code]):
                    self.message = g.pages_msg("error_b_1") + error_in

                # If the url is changed
                elif old_url[code] != self.page["url"][code]:
                    lista_url = self.page["url"][code].split("/")
                    # Convert list with strings all to lowercase
                    map(lambda x: x.lower(), lista_url)
                    if self.page["url"][code][-1] == "/":
                        lista_url.pop()
                    num_urls = len(lista_url)

                    try:
                        for code_two in self.languages:
                            field = "url_%s.%s" % (num_urls, code_two)
                            available_url = g.db.pages.find_one({field: lista_url})
                    except:
                        available_url = "Error invalid expression"

                    # Check that the url is a maximum of 200 characters
                    if not check.length(self.page["url"][code], 0, 200):
                        self.message = g.pages_msg("error_b_2") + error_in

                    # Verify that the format of the url is correct
                    elif not check.url_two(self.page["url"][code]):
                        self.message = g.pages_msg("error_b_3") + error_in

                    # Raises an error message if url is not available.
                    elif not available_url is None:
                        self.message = g.pages_msg("error_b_4") + error_in
                else:
                    lista_url = old_url[code].split("/")
                    if old_url[code][-1] == "/":
                        lista_url.pop()
                    num_urls = len(lista_url)

                kind_of_url = "url_%s" % num_urls
                if not kind_of_url in self.page:
                    self.page[kind_of_url] = {}
                self.page[kind_of_url][code] = lista_url
Exemple #22
0
    def __request_second_block(self):
        """ """
        form = self.params
        old_url = self.page['url']
        self.page['url'] = {}
        self.page['title'] = {}
        self.page['description'] = {}

        for i in range(10):
            key = 'url_%s' % i
            if key in self.page:
                del (self.page[key])

        self.page['url'] = form['url']
        self.page['title'] = form['title']
        self.page['description'] = form['description']

        # Get URL, Title and Description in any languages
        for code in self.languages:
            self.page['url'][code] = self.page['url'].get(code, '')
            self.page['title'][code] = self.page['url'].get(code, '')
            self.page['description'][code] = self.page['url'].get(code, '')

            if self.message is None:
                error_in = ' ( ' + code + ' )'

                # If the url is changed
                if old_url.get(code) != self.page['url'][code]:
                    url_list = self.__get_url_list(code)
                    num_urls = len(url_list)

                    for code_two in self.languages:
                        field = "url_{}.{}".format(num_urls, code_two)
                        page_id = ensure_objectid(
                            self.page["_id"]) if "_id" in self.page else None
                        available_url = model.pages.find(field=field,
                                                         field_value=url_list,
                                                         page_id_ne=page_id,
                                                         only_one=True)
                    print available_url

                    # Check that the url is a maximum of 200 characters
                    if not check.length(self.page['url'][code], 0, 200):
                        self.message = g.pages_msg('error_b_2') + error_in

                    # Verify that the format of the url is correct
                    elif len(self.page['url'][code]) and not check.url_two(
                            self.page['url'][code]):
                        print 3, self.page['url'][code]
                        self.message = g.pages_msg('error_b_3') + error_in

                    # Raises an error message if url is not available.
                    elif not available_url is None:
                        name_page = available_url['name']
                        error_where = '{0} in the "{1}" page'.format(
                            error_in, name_page)
                        self.message = g.pages_msg('error_b_4') + error_where
                else:
                    url_list = self.__get_url_list(code)
                    num_urls = len(url_list)

                if self.message is None:
                    kind_of_url = 'url_{}'.format(num_urls)
                    if not kind_of_url in self.page:
                        self.page[kind_of_url] = {}
                    self.page[kind_of_url][code] = url_list
Exemple #23
0
    def __request_second_block(self):
        """ """            
        form = self.params
        old_url = self.page['url']
        self.page['url'] = {}
        self.page['title'] = {}
        self.page['description'] = {}
        
        for i in range(10):
            key = 'url_%s' % i
            if key in self.page:
                del(self.page[key])

        self.page['url'] = form['url']
        self.page['title'] = form['title']
        self.page['description'] = form['description']
        
        # Get URL, Title and Description in any languages
        for code in self.languages:
            self.page['url'][code] = self.page['url'].get(code, '')
            self.page['title'][code] = self.page['url'].get(code, '')
            self.page['description'][code] = self.page['url'].get(code, '')

            if self.message is None:
                error_in = ' ( ' + code + ' )'
                
                # If the url is changed
                if old_url.get(code) != self.page['url'][code]:
                    url_list = self.__get_url_list(code)
                    num_urls = len(url_list)
                    
                    for code_two in self.languages:
                        field = "url_{}.{}".format(num_urls, code_two)
                        page_id = ensure_objectid(self.page["_id"]) if "_id" in self.page else None
                        available_url = model.pages.find(field=field, 
                                                         field_value=url_list, 
                                                         page_id_ne=page_id,
                                                         only_one=True)
                    print available_url
                    
                    # Check that the url is a maximum of 200 characters
                    if not check.length(self.page['url'][code], 0, 200):
                        self.message = g.pages_msg('error_b_2') + error_in
                    
                    # Verify that the format of the url is correct
                    elif len(self.page['url'][code]) and not check.url_two(self.page['url'][code]):
                        print 3, self.page['url'][code]
                        self.message = g.pages_msg('error_b_3') + error_in
                    
                    # Raises an error message if url is not available.
                    elif not available_url is None:
                        name_page = available_url['name']
                        error_where = '{0} in the "{1}" page'.format(error_in, name_page)
                        self.message = g.pages_msg('error_b_4') + error_where 
                else:
                    url_list = self.__get_url_list(code)
                    num_urls = len(url_list)
                
                if self.message is None:
                    kind_of_url = 'url_{}'.format(num_urls)
                    if not kind_of_url in self.page:
                        self.page[kind_of_url] = {}
                    self.page[kind_of_url][code] = url_list