[web2py] Re: How to easily implement another CSS-Framework
So, do you delete all views or just the layout view? Am Freitag, 11. Oktober 2019 19:01:07 UTC+2 schrieb Ruslan Gareev: > > Hi. Yes, you can delete files. For me it's normal and i use that way in my > projects. > > пятница, 11 октября 2019 г., 10:38:52 UTC+5 пользователь Jay B написал: >> >> Hello guys, >> >> I'm trying to figure out how to include another CSS framework instead of >> bootstrap. But the fact that the layout.html and other files point to the >> bootstrap files makes it harder than I thought. >> >> I would like to test other CSS frameworks like Semantic UI or Bulma >> instead of Bootstrap and wonder how to do it best. Or am I forced to delete >> all CSS files and standard views? >> >> I would be happy if you could help me and thank you in advance for all >> the tips. >> >> Greetz >> Jay >> > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/bf44df7c-ac30-43ff-ae83-aeb61e995f8c%40googlegroups.com.
[web2py] Re: How to easily implement another CSS-Framework
I'd say you don't delete anything. You edit the views that need to be deleted to deal with a different css like you would for any html page On Saturday, 12 October 2019 06:34:23 UTC-7, Jay B wrote: > > So, do you delete all views or just the layout view? > > > Am Freitag, 11. Oktober 2019 19:01:07 UTC+2 schrieb Ruslan Gareev: >> >> Hi. Yes, you can delete files. For me it's normal and i use that way in >> my projects. >> >> пятница, 11 октября 2019 г., 10:38:52 UTC+5 пользователь Jay B написал: >>> >>> Hello guys, >>> >>> I'm trying to figure out how to include another CSS framework instead of >>> bootstrap. But the fact that the layout.html and other files point to the >>> bootstrap files makes it harder than I thought. >>> >>> I would like to test other CSS frameworks like Semantic UI or Bulma >>> instead of Bootstrap and wonder how to do it best. Or am I forced to delete >>> all CSS files and standard views? >>> >>> I would be happy if you could help me and thank you in advance for all >>> the tips. >>> >>> Greetz >>> Jay >>> >> -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/8b654c55-4bd4-4676-8da8-10bc1545a574%40googlegroups.com.
[web2py] Re: Error trying to go back to python 2 after testing python 3: TypeError: translate() takes exactly one argument (2 given)
In python 2 type str means bytes and type unicode means unicode In python 3 class bytes means bytes and class str means unicode. This is my biggest problem with py3. They changed the meaning of a keyword to mean the opposite of what it did in py2. It makes things really hard to debug. On Friday, 11 October 2019 04:58:40 UTC-7, Lisandro wrote: > > > Also in your json example you are getting unicode both in py2 and py3 > except py3 does not put the u'' in front of unicode strings because they > are default. > > I've used type() to inspect the keys and values of the dictionary in py2 > and py3: > > *py2* > >>> map = pickle.load(open(path, 'rb')) > >>> first_key = list(map.keys())[0] > >>> print(type(first_key)) > > >>> print(type(map[first_key])) > > > > *py3* > >>> map = pickle.load(open(path, 'rb')) > >>> first_key = list(map.keys())[0] > >>> print(type(first_key)) > > >>> print(type(map[first_key])) > > > Notice in python3 it says "class" not "type" and it is str, while on > python2 it says unicode :/ > > Anyway, I don't pretend to bother with this issue unrelated to web2py. > My goal is to be able to read/write the dicti to a .pkl file with py2 and > py3, so I'll keep testing and I'll post the solution here if I find it :) > > > > El viernes, 11 de octubre de 2019, 2:52:35 (UTC-3), Massimo Di Pierro > escribió: >> >> I am puzzled by this too. The error is not in web2py code. The error is >> in the string.py module. >> Also in your json example you are getting unicode both in py2 and py3 >> except py3 does not put the u'' in front of unicode strings because they >> are default. >> >> On Thursday, 10 October 2019 18:05:55 UTC-7, Lisandro wrote: >>> >>> I've found the issue, it's not web2py related, sorry about that. >>> >>> My web2py instance has several applications running, each one is >>> attached to a domain. >>> I store a the map of domains:apps in a dictionary that I save to a .pkl >>> file. >>> Then my routes.py reads that file and loads the map of domains:apps >>> >>> I write the .pkl file like this: >>> >>> with open('map.pkl', 'wb') as file: >>> pickle.dump(dictionary_map, file, protocol=2) >>> >>> Notice I use protocol=2 because I want to be able to read/write the file >>> with python 2 and 3. >>> >>> In my routes.py I read the file like this: >>> >>> map = pickle.load(open('domains_apps.pkl', 'rb')) >>> >>> routers = dict( >>> BASE=dict( >>> default_controller='default', >>> default_function='index', >>> domains=map, >>> map_static=True, >>> exclusive_domain=True, >>> ) >>> ) >>> >>> >>> >>> However, after writing .pkl the file with python 3 and returning to >>> python 2, my applications fail with the error reported in my first message. >>> The error goes away if I replace the .pkl file with an old backup I had >>> made before using python 2. >>> >>> I have noticed that once the .pkl file is written with python 3, then >>> reading it with python 2 and 3 throws different results: >>> >>> *with python 3*: >>> >>> r = pickle.load(open('domains_apps.pkl', 'rb')) >>> >>> print(r) >>> {'prod.com': 'prod', 'test.com': 'test'} >>> >>> >>> *with python 2*: >>> >>> r = pickle.load(open('domains_apps.pkl', 'rb')) >>> >>> print(r) >>> {*u*'prod.com': *u*'prod', *u*'test.com': *u*'test'} >>> >>> >>> Notice that in python 2 reading the .pkl file (that was written with >>> python 3 using protocol=2) returns unicode strings. This doesn't happen in >>> python 3. But i'm not sure what protocol to use. >>> >>> I'll do some more tests and I'll post here whatever solution I can find. >>> Thanks for your time! >>> Regards, >>> Lisandro. >>> >>> >>> >>> >>> >>> El jueves, 10 de octubre de 2019, 21:21:53 (UTC-3), Dave S escribió: Delete all the .pyc files? /dps >>> -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/d19b4989-f854-4a28-9617-59cc7c877417%40googlegroups.com.
[web2py] Re: web2py survey dynamic forms with nested choices
# db_0.py # shortcut for `not null` field creation def req_field(*args, **kwargs): kwargs['notnull'] = True kwargs['required'] = True return Field(*args, **kwargs) # shortcut for reference field creation, `notnull` by default def FK(ref_table, **kwargs): if 'notnull' not in kwargs: kwargs['notnull'] = True kwargs['required'] = True return Field(ref_table, 'reference %s' % ref_table, **kwargs) # SURVEY MODEL: #---[ SURVEY ]--- t_name = 'survey' db.define_table(t_name, req_field('name', 'string'), ) #---[ QUESTION ]--- t_name = 'question' db.define_table(t_name, req_field('content', 'string'), ) #---[ ANSWER ]--- t_name = 'answer' db.define_table(t_name, req_field('content', 'string'), ) #---[ SECTION ]--- t_name = 'section' db.define_table(t_name, req_field('name', 'string'), ) #---[ SURVEY_QUESTION ]--- t_name = 'survey_question' db.define_table(t_name, FK('survey'), FK('section'), FK('question'), ) __UNIQUE_INDEXES__[t_name] = ['survey', 'section', 'question'] # or maybe just ['survey', 'question']? #---[ SURVEY_QUESTION_ANSWER ]--- t_name = 'survey_question_answer' db.define_table(t_name, FK('survey_question'), FK('answer'), req_field('score', 'integer', default = 0), ) __UNIQUE_INDEXES__[t_name] = ['survey_question', 'answer'] # RESULTS MODEL : #---[ SURVEY_USER_RESULT ]--- # if record exists then `user` check `answer` to `question` from `survey` t_name = 'survey_user_result' db.define_table(t_name, FK('survey_question_answer'), FK('auth_user'), ) __UNIQUE_INDEXES__[t_name] = ['survey_question_answer', 'auth_user'] # assuming SQLite def __create_indexes__(): def make_uniq(tbl, cols): sql_str = \ 'CREATE UNIQUE INDEX IF NOT EXISTS %(index_name)s ON %(table_name)s ( %(col_names)s );' \ % dict( index_name = idx_name, table_name = tbl, col_names = ','.join(["'%s'"%_ for _ in cols]) ) db.executesql(sql_str) def create_indexes(): for t in __UNIQUE_INDEXES__: args = __UNIQUE_INDEXES__[t] if isinstance(args[0], basestring): # single index args = [args] for a in args: make_uniq(t, list(a)) create_indexes() # to create indexes uncomment line below, it is required to be run only once #__create_indexes__() # after index creation you can comment this line again # !!! if indexes or tablenames/fields will be changed (even order of fields in __UNIQUE_INDEXES__[tbl]) # you should somehow drop old-existing indexes first (there are dozen utils for SQLite) On Saturday, October 12, 2019 at 7:54:05 PM UTC+3, NGNZONE wrote: > > Situation Description > > First things first, I am not a very experience web2py developer but I have > learned the basics of the framework, so please pardon me if my questions > are not so constructive. I started working on a survey application which > will enable users to create multiple choice questions. A question will have > a number of choices, and when the user selects a particular choice, a > corresponding score will be added to a sub total. That is if the survey is > about Fruits for instance, if a user selects oranges, 5 will be added to > the sub total for that section, if another user selects Mangoes, 10 will be > added to the sub total and so on. The attached screenshot survey_layout > will better explain what I am talking about. It has three columns, the > first column is the question, the second, the corresponding choices and the > third column the score linked to each choice. [Survey layout][1] There are > six sections in the survey, and each section has a sub_total which is > generated from the score value of each choice the user chooses on each of > the questions. Finally the sub_totals will be added up to give a grand > total for the entire survey and it can then be interpreted. What I have > done so far is as seen on the follow screenshots > > > > Questions: > > 1.How do I create my models in such a way that the user can dynamically > create questions for the survey for each section on the page and when the > user takes the survey, each choice the user selects, will correspond to a > score value which can be tracked and summed up to give the section totals? > > 2.How will my form be defined to output all the questions for each section > one after the other on the screen? I have tried using SQLFORMS but don't > know exactly how to achieve this. > >1. Thinking of using pagination to separate the sections so the page >will not be too long. any better option? > > References: I have watched the web2py survey by MASSIMO DI PIERRO where I > learn h
[web2py] Re: web2py survey dynamic forms with nested choices
If you want to create/edit survey using one page you have to use JavaScript (I don't see another non-horrible way). If you want only web2py/python implementation you have to organize your application to edit one entity per page/request, i.e. you can do something as follows: /surveys - returns grid of surveys with references to /surveys/ (per row) that returns grid of sections + references to /surveys// that returns grid of questions + references to /surveys/// that returns grid (or form with `select multiple` ) of answers with scores On Saturday, October 12, 2019 at 7:54:05 PM UTC+3, NGNZONE wrote: > > Situation Description > > First things first, I am not a very experience web2py developer but I have > learned the basics of the framework, so please pardon me if my questions > are not so constructive. I started working on a survey application which > will enable users to create multiple choice questions. A question will have > a number of choices, and when the user selects a particular choice, a > corresponding score will be added to a sub total. That is if the survey is > about Fruits for instance, if a user selects oranges, 5 will be added to > the sub total for that section, if another user selects Mangoes, 10 will be > added to the sub total and so on. The attached screenshot survey_layout > will better explain what I am talking about. It has three columns, the > first column is the question, the second, the corresponding choices and the > third column the score linked to each choice. [Survey layout][1] There are > six sections in the survey, and each section has a sub_total which is > generated from the score value of each choice the user chooses on each of > the questions. Finally the sub_totals will be added up to give a grand > total for the entire survey and it can then be interpreted. What I have > done so far is as seen on the follow screenshots > > > > Questions: > > 1.How do I create my models in such a way that the user can dynamically > create questions for the survey for each section on the page and when the > user takes the survey, each choice the user selects, will correspond to a > score value which can be tracked and summed up to give the section totals? > > 2.How will my form be defined to output all the questions for each section > one after the other on the screen? I have tried using SQLFORMS but don't > know exactly how to achieve this. > >1. Thinking of using pagination to separate the sections so the page >will not be too long. any better option? > > References: I have watched the web2py survey by MASSIMO DI PIERRO where I > learn how to do what I have done so far. > > Thanks in advance > > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/b7569962-55f3-4c90-bfcd-2db1afea88eb%40googlegroups.com.