diff --git a/paramecio/citoplasma/generate_admin_class.py b/paramecio/citoplasma/generate_admin_class.py index 0641d7e..eb13c8f 100644 --- a/paramecio/citoplasma/generate_admin_class.py +++ b/paramecio/citoplasma/generate_admin_class.py @@ -76,8 +76,12 @@ class GenerateAdminClass: post=self.model.select_a_row(getpostfiles.get['id'], [], True) title_edit=I18n.lang('common', 'edit_new_item', 'Edit item') - if post==None: - post={} + if post==None or post==False: + + if getpostfiles.get['id']=='0': + post={} + else: + return "" form=show_form(post, edit_forms, self.t, False) diff --git a/paramecio/citoplasma/httputils.py b/paramecio/citoplasma/httputils.py index b6eff21..bb9508e 100644 --- a/paramecio/citoplasma/httputils.py +++ b/paramecio/citoplasma/httputils.py @@ -22,33 +22,37 @@ class GetPostFiles: self.get=request.query.decode() - def obtain_post(self, required_post=[]): + def obtain_post(self, required_post=[], ignore_csrf_token=False): self.post={} self.post=request.forms.decode() + if len(required_post)==0: + required_post=self.post.keys() + for post in required_post: - self.post[post]=self.post.get(post, '') s=get_session() - if 'csrf_token' in s: - - self.post['csrf_token']=self.post.get('csrf_token', '') - - if self.post['csrf_token']!=s['csrf_token'] and self.post['csrf_token'].strip()!="": + if ignore_csrf_token==False: + + if 'csrf_token' in s: - raise NameError('Error: you need a valid csrf_token') - else: - #Clean csrf_token - - del s['csrf_token'] + self.post['csrf_token']=self.post.get('csrf_token', '') + if self.post['csrf_token']!=s['csrf_token'] and self.post['csrf_token'].strip()!="": + + raise NameError('Error: you need a valid csrf_token') + else: + #Clean csrf_token + + del s['csrf_token'] + - else: - raise NameError('Error: you don\'t send any valid csrf_token') + else: + raise NameError('Error: you don\'t send any valid csrf_token') #Check post_token diff --git a/paramecio/citoplasma/mtemplates.py b/paramecio/citoplasma/mtemplates.py index f761430..adaa65d 100644 --- a/paramecio/citoplasma/mtemplates.py +++ b/paramecio/citoplasma/mtemplates.py @@ -287,7 +287,13 @@ class HeaderHTML: self.css_local[module]=self.css_local.get(module, []) - self.css_local[module].append(css) + try: + + self.css_local[module].index(css) + + except: + + self.css_local[module].append(css) return '' @@ -297,7 +303,11 @@ class HeaderHTML: self.js_local[module]=self.js_local.get(module, []) - self.js_local[module].append(js) + try: + self.js_local[module].index(js) + + except: + self.js_local[module].append(js) return '' diff --git a/paramecio/cromosoma/webmodel.py b/paramecio/cromosoma/webmodel.py index 0d5f81b..7264789 100644 --- a/paramecio/cromosoma/webmodel.py +++ b/paramecio/cromosoma/webmodel.py @@ -206,7 +206,7 @@ class WebModel: sql="insert into `"+self.name+"` (`"+"`, `".join(fields)+"`) VALUES ("+", ".join(arr_str)+")" - cursor=self.sqlclass.query(sql, values+self.conditions[1], self.connection_id) + cursor=self.sqlclass.query(sql, values, self.connection_id) if cursor.rowcount>0: diff --git a/paramecio/index.py b/paramecio/index.py index af73f94..93a8c74 100644 --- a/paramecio/index.py +++ b/paramecio/index.py @@ -74,39 +74,6 @@ for module in config.modules: #add_func_static_module(controller_base) - -""" - try: - - controller_path=load(module) - - controller_base=os.path.dirname(controller_path.__file__) - - base_module=module.split('.')[-1] - - arr_module_path[base_module]=controller_base - - dir_controllers=os.listdir(controller_base) - - for controller in dir_controllers: - - if controller.find('.py')!=-1 and controller.find('__init__')==-1: - - controller_py=controller.replace('.py', '') - - load(module+'.'+controller_py) - - add_func_static_module(controller_base) - - except: - - print("Exception in user code:") - print("-"*60) - traceback.print_exc(file=sys.stdout) - print("-"*60) -""" -#exit() - #Prepare ssl if config.ssl==True: diff --git a/paramecio/modules/admin/index.py b/paramecio/modules/admin/index.py index 08f57ed..11a2fed 100644 --- a/paramecio/modules/admin/index.py +++ b/paramecio/modules/admin/index.py @@ -34,9 +34,9 @@ module_admin=path.dirname(__file__) env=env_theme(__file__) -def make_admin_url(url): +def make_admin_url(url, query_args={}): - return make_url('%s/%s' % (config.admin_folder, url)) + return make_url('%s/%s' % (config.admin_folder, url), query_args) @get('/'+config.admin_folder) @get('/'+config.admin_folder+'/')