Re: [web2py] utf8 decode encode
Hi, Dmitry You've got a unicode string. So you need to convert it to a str type with utf-8 sequence in it. Use encode() method of unicode type: s = u'\u041f\u0435\u0440\u0435\u043d\u043e\u0441 \u0441\u0440\u0435 \u0434\u0441\u0442\u0432 \u0441\u043e \u0441\u0447\u0435\u0442\u0430 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c' print s Перенос средств со счета в очередь type(s) type 'unicode' s.encode('utf-8') '\xd0\x9f\xd0\xb5\xd1\x80\xd0\xb5\xd0\xbd\xd0\xbe\xd1\x81 \xd1\x81\xd1 \x80\xd0\xb5\xd0\xb4\xd1\x81\xd1\x82\xd0\xb2 \xd1\x81\xd0\xbe \xd1\x81 \xd1\x87\xd0\xb5\xd1\x82\xd0\xb0 \xd0\xb2 \xd0\xbe\xd1\x87\xd0\xb5\xd1 \x80\xd0\xb5\xd0\xb4\xd1\x8c' s1=s.encode('utf-8') type(s1) type 'str' print s1 Перенос средств со счета в очередь Now you can use s1 in your returrn clause. Vlad Chernivtsi, Ukraine У сб, 2015-06-06 у 01:22 -0700, Dmitry Ermolaev пише: u'\u041f\u0435\u0440\u0435\u043d\u043e\u0441 \u0441\u0440\u0435\u0434 \u0441\u0442\u0432 \u0441\u043e \u0441\u0447\u0435\u0442\u0430 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c' -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] Re: replacing T() with T.M()
Massimo, my decision can fix this issue: http://code.google.com/p/web2py/issues/detail?id=1677 Can you apply my patch ? With the best regards, Vladyslav Kozlovskyy Chernivtsi, Ukraine У ср, 2013-09-25 у 21:42 -0700, Massimo Di Pierro пише: Yes the produce the same output but while T.M(s) caches the markmin output, MARKMIN(T(s)) only caches the translated string before MARKMIN rendering. Therefore T.M(s) is faster. On Wednesday, 25 September 2013 20:09:38 UTC-5, Anthony wrote: Sorry, that wasn't clear. But why can't you just do: var ajax_error_500 = '{{=MARKMIN(T('An error occurred, please [[reload %s]] the page') % URL(args=request.args, vars=request.get_vars))}}' Anthony On Wednesday, September 25, 2013 5:47:31 PM UTC-4, dbdeveloper wrote: T.M() uses MARKMIN (see docs in attachment). Using MARKMIN you can create message with link, img, tables, bold, italic, colors and so on. Vlad У ср, 2013-09-25 у 07:20 -0700, Anthony пише: var ajax_error_500 = '{{=T.M('An error occurred, please [[reload %s]] the page') % URL(args=request.args, vars=request.get_vars) }}' The original included an HTML a element. In your example above, does the [[... %s]] notation indicate that an a element should be created? If so, what if you want to include some attributes? What if you need a different HTML element? Anthony -- 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 +un...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- 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. For more options, visit https://groups.google.com/groups/opt_out. -- 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. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] replacing T() with T.M()
Hi all! During translating I have found in applications/welcome/views/web2py_ajax.html such calls (marked red): script type=text/javascript!-- // These variables are used by the web2py_ajax_init function in web2py_ajax.js (which is loaded below). var w2p_ajax_confirm_message = {{=T('Are you sure you want to delete this object?')}}; var w2p_ajax_disable_with_message = {{=T('Working...')}}; var w2p_ajax_date_format = {{=T('%Y-%m-%d')}}; var w2p_ajax_datetime_format = {{=T('%Y-%m-%d %H:%M:%S')}}; var ajax_error_500 = '{{=XML(T('An error occured, please %s the page') % A(T('reload'), _href=URL(args=request.args, vars=request.get_vars))) }}' //--/script {{ response.files.insert(0,URL('static','js/jquery.js')) response.files.insert(1,URL('static','css/calendar.css')) response.files.insert(2,URL('static','js/calendar.js')) response.files.insert(3,URL('static','js/web2py.js')) response.include_meta() response.include_files() }} this (marked red) call is hard to understand and to translate (the sentence is split into 2 parts) I propose to replace this two T() calls with one T.M() call: script type=text/javascript!-- // These variables are used by the web2py_ajax_init function in web2py_ajax.js (which is loaded below). var w2p_ajax_confirm_message = {{=T('Are you sure you want to delete this object?')}}; var w2p_ajax_disable_with_message = {{=T('Working...')}}; var w2p_ajax_date_format = {{=T('%Y-%m-%d')}}; var w2p_ajax_datetime_format = {{=T('%Y-%m-%d %H:%M:%S')}}; var ajax_error_500 = '{{=T.M('An error occurred, please [[reload %s]] the page') % URL(args=request.args, vars=request.get_vars) }}' //--/script {{ response.files.insert(0,URL('static','js/jquery.js')) response.files.insert(1,URL('static','css/calendar.css')) response.files.insert(2,URL('static','js/calendar.js')) response.files.insert(3,URL('static','js/web2py.js')) response.include_meta() response.include_files() }} This call is easily to understand and easily to translate. With the best regards, Vladyslav Kozlovskyy Ukraine, Chernivtsi -- 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. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: replacing T() with T.M()
T.M() uses MARKMIN (see docs in attachment). Using MARKMIN you can create message with link, img, tables, bold, italic, colors and so on. Vlad У ср, 2013-09-25 у 07:20 -0700, Anthony пише: var ajax_error_500 = '{{=T.M('An error occurred, please [[reload %s]] the page') % URL(args=request.args, vars=request.get_vars) }}' The original included an HTML a element. In your example above, does the [[... %s]] notation indicate that an a element should be created? If so, what if you want to include some attributes? What if you need a different HTML element? Anthony -- 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. For more options, visit https://groups.google.com/groups/opt_out. -- 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. For more options, visit https://groups.google.com/groups/opt_out. Title: Markmin markup language Markmin markup languageAboutThis is a new markup language that we call markmin designed to produce high quality scientific papers and books and also put them online. We provide serializers for html, latex and pdf. It is implemented in the markmin2html function in the markmin2html.py.Example of usage:m = "Hello **world** [[link http://web2py.com]]" from markmin2html import markmin2html print markmin2html(m) from markmin2latex import markmin2latex print markmin2latex(m) from markmin2pdf import markmin2pdf # requires pdflatex print markmin2pdf(m) This is a test block with new features:This is a blockquote with a list with tables in it:This is a paragraph before list. You can continue paragraph on the next lines.This is an ordered list with tables:Item 1Item 2aabbcc112233Item 4 T1T2t3aaabbbcccdddfffggg12305.0This this a new paragraph with a table. Table has header, footer, sections, odd and even rows:Title 1Title 2Title 3data 1data 22.00data 3data4(long)23.00data 533.50New sectionNew data5.00data 1data2(long)100.45data 312.50data 4data 5.33data 6data7(long)8.01data 8514Total:9 items698,79Multilevel listsNow lists can be multilevel:Ordered item 1 on level 1. You can continue item text on next stringsOrdered item 1 of sublevel 2 with a paragraph (paragraph can start with point after plus or minus characters, e.g. ++. or --.)This is another item. But with 3 paragraphs, blockquote and sublists:This is the second paragraph in the item. You can add paragraphs to an item, using point notation, where first characters in the string are sequence of points with space between them and another string. For example, this paragraph (in sublevel 2) starts with two points:.. This is the second paragraph...this is a blockquote in a listYou can use blockquote with headers, paragraphs, tables and lists in it:Tables can have or have not header and footer. This table is defined without any header and footer in it:redfox0bluedolphin1000greenleaf1This is yet another paragraph in the item.This is an item of unordered list (sublevel 3)This is the second item of the unordered list (sublevel 3)This is a single item of ordered list in sublevel 6and this is a paragraph in sublevel 4This is a new item with paragraph in sublevel 3.Start ordered list in sublevel 4 with code block: line 1 line 2 line 3Yet another item with code block: line 1 line 2 line 3 This item finishes with this paragraph.Item in sublevel 3 can be continued with paragraphs. this is another code block in the sublevel 3 itemThe last item in sublevel 3This is a continuous paragraph for item 2 in sublevel 2. You can use such structure to create difficult structured documents.item 3 in sublevel 2item 1 in sublevel 2 (new unordered list)item 2 in sublevel 2item 3 in sublevel 2item 1 in sublevel 2 (new ordered list)item 2 in sublevel 2item 3 in sublevle 2item 2 in level 1item 3 in level 1new unordered list (item 1 in level 1)level 2 in level 1level 3 in level 1level 4 in level 1This is the last section of the testSingle paragraph with '' in it will be turned into separator:And this is the last paragraph in the test. Be happy!Why?We wanted a markup language with the following requirements:less than 300 lines of functional codeeasy to readsecuresupport table, ul, ol, codesupport html5 video and audio elements (html serialization
Re: [web2py] Re: pluralization system problem
Thank you for your fix. I'll create the patch. With the best regards Vlad Kozlovskyy Chernivtsi, Ukraine У пн, 2013-09-23 у 13:29 -0700, mcamel пише: El domingo, 22 de septiembre de 2013 12:59:23 UTC+2, dbdeveloper escribió: # This rule isn't perfect but covers many cases. Complete rules at http://www.rae.es/dpd/srv/search?id=Iwao8PGQ8D6QkHPn4i. construct_plural_form = lambda word, plural_id: (word + ('es' if word[-1:] in ('s', 'x', 'ch', 'y', 'l', 'r', 'n', 'd', 'z', 'j') else 's')) Perfect rule! Thank you! I'll add it to es.py and send a patch. It's not perfect because it doesn't cover all cases. Complete rule would be as complex as the Ukrainian one. Please use it if you agree to use plural-*.py when this rule fails. Thank you very much. I have already posted the patch. BTW, I've checked welcome/languages/es.py and found this entries with error (below are corrected): 'and rename it (required):': 'y renómbrela (requerido):', 'and rename it:': ' y renómbrelo:', 'Clear DISK': 'Limpiar DISCO', 'Clear RAM': 'Limpiar RAM', 'done!': '¡listo!', 'Groups': 'Grupos', 'Index': 'Índice', 'Register': 'Regístrese', 'register': 'regístrese', 'Semantic': 'Semántica', 'Welcome to web2py!': '¡Bienvenido a web2py!', This last is specially annoying because it is displayed at the main page of the welcome app!. Can you do the fix or must i open a ticket?. Thank you very much!. -- 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. For more options, visit https://groups.google.com/groups/opt_out. -- 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. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: pluralization system problem
Hi У сб, 2013-09-21 у 09:18 -0700, mcamel пише: Ok. I did so and worked fine. I supposed words needed to be included in translation file once, but in fact, expressions including words has to be included also in the dictionary as if they were words itself. web2py localisation subsystem uses THE WHOLE EXPRESSION not single words. Also similar sentences can have different translations depending on substitution parameters in them (or even on context): open an account (BANK), open an account (SITE) and open %s % %{account[0]} sentences can be translated in different ways. We do not need to store word-word pairs in localization dictionary. The pluralizaiton subsystem has its own dictionary where word to word pairs are used. Words in pluralizatiоn subsystem MUST be in lower case only and MOSTLY one word per record (but you can use word pairs or even sentences in %%{...} templates but it isn't commonly used practice. I propose this to be included in the manual: 1. expressions including words has to be included also in the dictionary as if they were words itself see explanation above 1. you can use '%%{word(%i)}' or '%%{word(%s)}' if you want to use plural without showing the number that decides the plural form. %%{world} pluralization subsystem template is a complex template which covers many use cases. One of them is what you have described above :) You can learn from the template in docs I have posted recently in this thread. There's also an errata: substitute rules/plural_rules/*.py with gluon/contrib/plural_rules/*.py. Besides, i propose this to be added to gluon/contrib/plural_rules/es.py: # This rule isn't perfect but covers many cases. Complete rules at http://www.rae.es/dpd/srv/search?id=Iwao8PGQ8D6QkHPn4i. construct_plural_form = lambda word, plural_id: (word + ('es' if word[-1:] in ('s', 'x', 'ch', 'y', 'l', 'r', 'n', 'd', 'z', 'j') else 's')) Perfect rule! Thank you! I'll add it to es.py and send a patch. By the way, is there a better way to propose modifications to the manual?. Yes, I think correct described construct_plural_form rule is a better way to use plural forms! But I don't know these rules for all languages, and for some languages (for example for my own Ukrainian language) this rule is so difficult that manual filling of plural dictionary is the only way. With the best regards, Vlad Kozlovskyy Chernivtsi, Ukraine Thank you very much!. El sábado, 21 de septiembre de 2013 01:23:38 UTC+2, dbdeveloper escribió: It is not an issue. It's only a small misunderstanding. :) There are correct steps how to create application with working pluralization system: 1. Create a simple app 2. Replace index() at default.py with return T('%s % %{object}', 2, language='es') 3. Insert into administrative interface, click [Reload routers] (in my case it did not appear without this workaround) 4. Click [Manage]-[Edit] beside newly created app 5. Go to Languages section and click [update all languages] to refresh language files 6. Click [Edit] beside es.py language file and find string '%s %%{object}' 7. Write translation FOR THIS WHOLE STRING '%s %%{objeto}' and click Save changes, then return to previous window by clicking [Edit] menu item on the top of the screen 8. Return to Languages section and click [Edit] beside Plural-Forms: plural-es.py and add plural form for objeto word: objetos then click Update and leave this screen by clicking [Edit] menu item on the top of the screen. 9. Access app/default/index -- 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. For more options, visit https://groups.google.com/groups/opt_out. -- 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. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: pluralization system problem
One addition to the step 8: Record with word in plural-*.py files appears ONLY during execution T() or T.M() with correspondent %%{word} template in it. So before editing plural forms you need to execute you application once (step 9) or you need to fill plural-*.py files manually as a Python source file. У сб, 2013-09-21 у 02:23 +0300, Vladyslav Kozlovskyy пише: It is not an issue. It's only a small misunderstanding. :) There are correct steps how to create application with working pluralization system: 1. Create a simple app 2. Replace index() at default.py with return T('%s %%{object}', 2, language='es') 3. Insert into administrative interface, click [Reload routers] (in my case it did not appear without this workaround) 4. Click [Manage]-[Edit] beside newly created app 5. Go to Languages section and click [update all languages] to refresh language files 6. Click [Edit] beside es.py language file and find string '%s % %{object}' 7. Write translation FOR THIS WHOLE STRING '%s %%{objeto}' and click Save changes, then return to previous window by clicking [Edit] menu item on the top of the screen 8. Return to Languages section and click [Edit] beside Plural-Forms: plural-es.py and add plural form for objeto word: objetos then click Update and leave this screen by clicking [Edit] menu item on the top of the screen. 9. Access app/default/index Hope this explanation can help you to understand pluralization system better. With the best regards, Vladyslav Kozlovskyy Ukraine, Chernivtsi У чт, 2013-09-19 у 07:45 -0700, mcamel пише: Nothing about pluralization, so i've opened Issue 1684 . El jueves, 19 de septiembre de 2013 12:03:00 UTC+2, LightDot escribió: Issues/tickets/bug reports are found here: http://code.google.com/p/web2py/issues/list Just search if something like this already exist and if not, create a new issue. -- 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. For more options, visit https://groups.google.com/groups/opt_out. -- 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. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: pluralization system problem
It is not an issue. It's only a small misunderstanding. :) There are correct steps how to create application with working pluralization system: 1. Create a simple app 2. Replace index() at default.py with return T('%s %%{object}', 2, language='es') 3. Insert into administrative interface, click [Reload routers] (in my case it did not appear without this workaround) 4. Click [Manage]-[Edit] beside newly created app 5. Go to Languages section and click [update all languages] to refresh language files 6. Click [Edit] beside es.py language file and find string '%s % %{object}' 7. Write translation FOR THIS WHOLE STRING '%s %%{objeto}' and click Save changes, then return to previous window by clicking [Edit] menu item on the top of the screen 8. Return to Languages section and click [Edit] beside Plural-Forms: plural-es.py and add plural form for objeto word: objetos then click Update and leave this screen by clicking [Edit] menu item on the top of the screen. 9. Access app/default/index Hope this explanation can help you to understand pluralization system better. With the best regards, Vladyslav Kozlovskyy Ukraine, Chernivtsi У чт, 2013-09-19 у 07:45 -0700, mcamel пише: Nothing about pluralization, so i've opened Issue 1684 . El jueves, 19 de septiembre de 2013 12:03:00 UTC+2, LightDot escribió: Issues/tickets/bug reports are found here: http://code.google.com/p/web2py/issues/list Just search if something like this already exist and if not, create a new issue. -- 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. For more options, visit https://groups.google.com/groups/opt_out. -- 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. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: pluralization system problem
4. Create languages/plural-es.py, with: {'object': ['objectos'],} Please try to replace 'object' with 'objecto'. In plural-*.py must be native language only. Vladyslav Kozlovskyy У ср, 2013-09-18 у 16:00 -0700, Massimo Di Pierro пише: Can you please open a ticket about this and we will review it asap? On Wednesday, 18 September 2013 14:54:48 UTC-5, mcamel wrote: Hello, I've found two problems with Spanish pluralization. I think the first is a bug and the second is an unexpected behavior. Both happens with 2.51 and 2.6.3. How to repeat: 1. Create a sample app 2. Replace index() at default.py with: return T('%s % %{object}', 2, language=es) 3. Add this to languages/es.py, just before '}': 'object': 'objecto', 4. Create languages/plural-es.py, with: {'object': ['objectos'],} You'll have this testing the index: 2 objectos Right. But now if you change '2' by '1' at index(), you'll have: 1 object instead of: 1 objecto If you change languages/plural-es.py, with: {'objecto': ['objectos'],} it works even worse (never in Spanish). The second problem happens if you remove %s from index(): return T('%%{object}', 2, language=es) Then you have an error: type 'exceptions.TypeError'(not all arguments converted during string formatting) Is there any workaround for this?. Thank you. -- 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. For more options, visit https://groups.google.com/groups/opt_out. -- 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. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] pluralization system problem
Use%%{word(%i)} to avoid printing the number: T('%%{object(%i)}', 2, language=es) or T('%%{object(%s)}', 2, language=es) У чт, 2013-09-19 у 07:49 -0700, mcamel пише: Hi Vladyslav, i really thank you, but this is too much information for my level. I understand %s is a must in this case, but cannot imagine a workaround to just pluralizates a word without printing the number that produces the pluralization. Anyway, thank you very much. Best regards, Manuel Cameselle. El jueves, 19 de septiembre de 2013 12:10:08 UTC+2, dbdeveloper escribió: this problem happens because pluralisation templates % %{word} works with real python placeholders %s only see explanation in attachment, please. Hope this can help you. With the best regareds, Vladyslav Kozlovskyy У ср, 2013-09-18 у 12:54 -0700, mcamel пише: The second problem happens if you remove %s from index(): return T('%%{object}', 2, language=es) Then you have an error: type 'exceptions.TypeError'(not all arguments converted during string formatting) Is there any workaround for this?. -- 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. For more options, visit https://groups.google.com/groups/opt_out. -- 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. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Performance overhead when making languages not writable
Hi all! We have [is_gae] variable in [gluon/languages.py] to avoid writting dicts in Google AppEngine. All we need is to make such replacement in [gluon/languages.py]: replace 38 is_gae = settings.global_settings.web2py_runtime_gae with 38 is_gae = settings.global_settings.web2py_runtime_gae or setings.global_settings.languages_readonly # or use better varname :) With the best regards, Vladyslav Kozlovskyy (Ukraine) У пн, 2012-10-15 у 13:51 -0300, Vinicius Assef пише: I'd like to have a global (app wide) option to not override my language files. On Mon, Oct 15, 2012 at 1:47 PM, Fran francisb...@gmail.com wrote: On my Production servers I don't like the languages/* files to be writable - I prefer to keep these files part of the application's version control translated outside the application. Currently this leads to a performance overhead as there are many times that write_dict() is called and so gluon attempts to update the file throws an Exception. I'd ideally like to have a setting to not update these files at all, so just return inside this function (as is currently done if __corrupted__ in contents). The right place for this would appear to be request.global_settings How does this sound to people? If we agree on a strategy, I can write the code, as this doesn't seem hard to implement. Best Wishes, Fran. -- --
Re: [web2py] Performance overhead when making languages not writable
sure, it's a right decision :) У пн, 2012-10-15 у 18:44 +0100, Fran Boon пише: On 15 October 2012 18:36, Vladyslav Kozlovskyy vld...@gmail.com wrote: We have [is_gae] variable in [gluon/languages.py] to avoid writting dicts in Google AppEngine. All we need is to make such replacement in [gluon/languages.py]: replace 38 is_gae = settings.global_settings.web2py_runtime_gae with 38 is_gae = settings.global_settings.web2py_runtime_gae or setings.global_settings.languages_readonly # or use better varname :) Right - this is the right place to do it, but I'd do: 38 read_only = settings.global_settings.web2py_runtime_gae or settings.global_settings.languages_readonly then replace other is_gae refs with that... F --
Re: [web2py] Performance overhead when making languages not writable
Done У пн, 2012-10-15 у 13:34 -0700, Massimo Di Pierro пише: OK. send me a patch. :-) On Monday, 15 October 2012 12:44:48 UTC-5, Fran wrote: On 15 October 2012 18:36, Vladyslav Kozlovskyy vld...@gmail.com wrote: We have [is_gae] variable in [gluon/languages.py] to avoid writting dicts in Google AppEngine. All we need is to make such replacement in [gluon/languages.py]: replace 38 is_gae = settings.global_settings.web2py_runtime_gae with 38 is_gae = settings.global_settings.web2py_runtime_gae or setings.global_settings.languages_readonly # or use better varname :) Right - this is the right place to do it, but I'd do: 38 read_only = settings.global_settings.web2py_runtime_gae or settings.global_settings.languages_readonly then replace other is_gae refs with that... F -- --
Re: [web2py] markmin embed:http://... not work trunk version
autolinks is right module. but I have some questions: 1. markmin doesn't have dependencies. Now it will be dependent on autolinks. Solution: we can disable autolink if it isn't found on path. Right? 2. Autolink is LGPL, makmin is MIT/BSD/GPL. I do not understand differentiation between them. Is there all alright ? 3. now the regex expression for search autolinks must be: http(s)://* Yes? 4. second parameter for expand_one: {} - do we always need to use empty dict here or better to use variable to cache repeated urls ? 5. if embed will be depricated, how about backward compatibility? Vladyslav Kozlovskyy 28.07.12 01:57, Massimo Di Pierro написав(ла): I think embed:http://url should be deprecated in MARKMIN. It think if a url is found and not marked-up whether or not prefixed with embed: the url should be precessed by the function gluon/contrib/autolinks.py/expand_one(url,{}) This function uses the oembed protocol to figure out the best way to embed the content pointed by the url (whether it is an image, a video, a youtube page, etc.) The {} argument is a dictionary that will be used for caching. The iframe prefix should be left alone but may need to discuss security. Should it be enabled by default? This may actually simplify markmin. Massimo On Thursday, 26 July 2012 17:30:21 UTC-5, Massimo Di Pierro wrote: Before you change it, let me think about this some more... On Thursday, 26 July 2012 17:03:35 UTC-5, dbdeveloper wrote: well, give me an example of correct iframe and embed output and I'll change markmin. ok? Vladyslav Kozlovskyy (Ukraine) 26.07.12 16:40, Jose написав(ла): El jueves, 26 de julio de 2012 02:04:21 UTC-3, dbdeveloper escribió: Hi, Jose! try 'iframe' instead of 'embed': iframe:http://www.youtube.com/embed/x1w8hKTJ2Co http://www.youtube.com/embed/x1w8hKTJ2Co Ok Vladyslav, but I think the same as Massimo, this breaks backwards compatibility. Jose -- -- --
Re: [web2py] markmin embed:http://... not work trunk version
I think, the best way is to use autolinks as a render()'s parameter (autolinks replaces auto parameter): def default_autolinks(url): default autolinks for links, pictures and videos using video tag return 'a href=%s%s/a' % (url, url) render(., autolinks=default_autolinks) disable autolinks: render(., autolinks=None) use other autolinks: from gluon.contrib.autolinks import expand_one render(, autolinks=lambda url: expand_one(url, {}) ) Your decision? Vladyslav Kozlovskyy 28.07.12 17:36, Massimo Di Pierro написав(ла): 1.2. I wrote autolinks and it is not used by anything else. We can change the licence and - in principle - we can move the code we need in markmin2html.py. 3. yes 4. perhaps we can pass a dict to markmin? 5. I do not think embed is documented in the book. If we silently ignore embed and treat embed:http://... the same as http://.. and the url points to an oembed service, it should still embed using the oembed rules. If not it will use a link instead of an iframe. Technically is a minor change of behavior but it will not break any app. Alternatively we can use embed: as alias of iframe:... if no oembed rule. What do you think? On Saturday, 28 July 2012 08:21:20 UTC-5, dbdeveloper wrote: autolinks is right module. but I have some questions: 1. markmin doesn't have dependencies. Now it will be dependent on autolinks. Solution: we can disable autolink if it isn't found on path. Right? 2. Autolink is LGPL, makmin is MIT/BSD/GPL. I do not understand differentiation between them. Is there all alright ? 3. now the regex expression for search autolinks must be: http(s)://* Yes? 4. second parameter for expand_one: {} - do we always need to use empty dict here or better to use variable to cache repeated urls ? 5. if embed will be depricated, how about backward compatibility? Vladyslav Kozlovskyy 28.07.12 01:57, Massimo Di Pierro написав(ла): I think embed:http://url should be deprecated in MARKMIN. It think if a url is found and not marked-up whether or not prefixed with embed: the url should be precessed by the function gluon/contrib/autolinks.py/expand_one(url,{}) http://autolinks.py/expand_one%28url,%7B%7D%29 This function uses the oembed protocol to figure out the best way to embed the content pointed by the url (whether it is an image, a video, a youtube page, etc.) The {} argument is a dictionary that will be used for caching. The iframe prefix should be left alone but may need to discuss security. Should it be enabled by default? This may actually simplify markmin. Massimo On Thursday, 26 July 2012 17:30:21 UTC-5, Massimo Di Pierro wrote: Before you change it, let me think about this some more... On Thursday, 26 July 2012 17:03:35 UTC-5, dbdeveloper wrote: well, give me an example of correct iframe and embed output and I'll change markmin. ok? Vladyslav Kozlovskyy (Ukraine) 26.07.12 16:40, Jose написав(ла): El jueves, 26 de julio de 2012 02:04:21 UTC-3, dbdeveloper escribió: Hi, Jose! try 'iframe' instead of 'embed': iframe:http://www.youtube.com/embed/x1w8hKTJ2Co http://www.youtube.com/embed/x1w8hKTJ2Co Ok Vladyslav, but I think the same as Massimo, this breaks backwards compatibility. Jose -- -- -- --
Re: [web2py] markmin embed:http://... not work trunk version
Ok. Wait the patch 29.07.12 01:28, Massimo Di Pierro написав(ла): I think this is a reasonable solution. The helper MARKMIN could be smarter and use autolinks expand_one. On Saturday, 28 July 2012 14:14:50 UTC-5, dbdeveloper wrote: I think, the best way is to use autolinks as a render()'s parameter (autolinks replaces auto parameter): def default_autolinks(url): default autolinks for links, pictures and videos using video tag return 'a href=%s%s/a' % (url, url) render(., autolinks=default_autolinks) disable autolinks: render(., autolinks=None) use other autolinks: from gluon.contrib.autolinks import expand_one render(, autolinks=lambda url: expand_one(url, {}) ) Your decision? Vladyslav Kozlovskyy 28.07.12 17:36, Massimo Di Pierro написав(ла): 1.2. I wrote autolinks and it is not used by anything else. We can change the licence and - in principle - we can move the code we need in markmin2html.py. 3. yes 4. perhaps we can pass a dict to markmin? 5. I do not think embed is documented in the book. If we silently ignore embed and treat embed:http://... the same as http://.. and the url points to an oembed service, it should still embed using the oembed rules. If not it will use a link instead of an iframe. Technically is a minor change of behavior but it will not break any app. Alternatively we can use embed: as alias of iframe:... if no oembed rule. What do you think? On Saturday, 28 July 2012 08:21:20 UTC-5, dbdeveloper wrote: autolinks is right module. but I have some questions: 1. markmin doesn't have dependencies. Now it will be dependent on autolinks. Solution: we can disable autolink if it isn't found on path. Right? 2. Autolink is LGPL, makmin is MIT/BSD/GPL. I do not understand differentiation between them. Is there all alright ? 3. now the regex expression for search autolinks must be: http(s)://* Yes? 4. second parameter for expand_one: {} - do we always need to use empty dict here or better to use variable to cache repeated urls ? 5. if embed will be depricated, how about backward compatibility? Vladyslav Kozlovskyy 28.07.12 01:57, Massimo Di Pierro написав(ла): I think embed:http://url should be deprecated in MARKMIN. It think if a url is found and not marked-up whether or not prefixed with embed: the url should be precessed by the function gluon/contrib/autolinks.py/expand_one(url,{}) http://autolinks.py/expand_one%28url,%7B%7D%29 This function uses the oembed protocol to figure out the best way to embed the content pointed by the url (whether it is an image, a video, a youtube page, etc.) The {} argument is a dictionary that will be used for caching. The iframe prefix should be left alone but may need to discuss security. Should it be enabled by default? This may actually simplify markmin. Massimo On Thursday, 26 July 2012 17:30:21 UTC-5, Massimo Di Pierro wrote: Before you change it, let me think about this some more... On Thursday, 26 July 2012 17:03:35 UTC-5, dbdeveloper wrote: well, give me an example of correct iframe and embed output and I'll change markmin. ok? Vladyslav Kozlovskyy (Ukraine) 26.07.12 16:40, Jose написав(ла): El jueves, 26 de julio de 2012 02:04:21 UTC-3, dbdeveloper escribió: Hi, Jose! try 'iframe' instead of 'embed': iframe:http://www.youtube.com/embed/x1w8hKTJ2Co http://www.youtube.com/embed/x1w8hKTJ2Co Ok Vladyslav, but I think the same as Massimo, this breaks backwards compatibility. Jose -- -- -- -- --
Re: [web2py] prettydate question
25.07.12 16:52, ctrlSoft написав(ла): browser is set up to english, but in model i do T.force('ro'). without forced translation result is the same -- please do these steps and post the result here: 1. add test() function into applicatons/welcome/controllers/default.py: def test(): import datetime d=datetime.datetime.strptime('2012-07-18 10:00:00', '%Y-%m-%d %H:%M:%S') T.force('ro') return locals() 2. copy test.html (see attachment) into applications/welcome/views/default/test.html 3. open page http://127.0.0.1:8000/welcome/default/test and post the output here Vladyslav Kozlovskyy -- {{extend 'layout.html'}} Prettydate test now:{{=prettydate(datetime.datetime.now(),T)}} {{=prettydate(d,T)}} {{for year in xrange(2000,2013):}} {{dd=datetime.datetime.strptime('%s-07-01 10:00:00'%year, '%Y-%m-%d %H:%M:%S')}} {{=prettydate(dd,T)}} {{pass}} {{for month in xrange(1,8):}} {{dd=datetime.datetime.strptime('2012-%s-01 10:00:00'%month, '%Y-%m-%d %H:%M:%S')}} {{=prettydate(dd,T)}} {{pass}} {{for day in xrange(1,31):}} {{dd=datetime.datetime.strptime('2012-07-%s 10:00:00'%day, '%Y-%m-%d %H:%M:%S')}} {{=prettydate(dd,T)}} {{pass}} {{=BEAUTIFY(response._vars)}}
Re: [web2py] markmin embed:http://... not work trunk version
well, give me an example of correct iframe and embed output and I'll change markmin. ok? Vladyslav Kozlovskyy (Ukraine) 26.07.12 16:40, Jose ???(??): El jueves, 26 de julio de 2012 02:04:21 UTC-3, dbdeveloper escribió: Hi, Jose! try 'iframe' instead of 'embed': iframe:http://www.youtube.com/embed/x1w8hKTJ2Co http://www.youtube.com/embed/x1w8hKTJ2Co Ok Vladyslav, but I think the same as Massimo, this breaks backwards compatibility. Jose -- --
Re: [web2py] markmin embed:http://... not work trunk version
Hi, Jose! try 'iframe' instead of 'embed': iframe:http://www.youtube.com/embed/x1w8hKTJ2Co In 1.99.7 embed looks like iframe, and iframe is not used at all (it's a new feature): * markmin2html('embed:http://www.youtube.com/embed/x1w8hKTJ2Co')* 'piframe src=http://www.youtube.com/embed/x1w8hKTJ2Co; frameborder=0 allowfullscreen/iframe/p' * markmin2html('iframe:http://www.youtube.com/embed/x1w8hKTJ2Co')* 'piframe:a href=http://www.youtube.com/embed/x1w8hKTJ2Co;http://www.youtube.com/embed/x1w8hKTJ2Co/a/p in the trunk embed is simply a link with class='embed'. We need css rule to make this link works: * markmin2html('embed:http://www.youtube.com/embed/x1w8hKTJ2Co')* 'pa href=http://www.youtube.com/embed/x1w8hKTJ2Co; class=embedhttp://www.youtube.com/embed/x1w8hKTJ2Co/a/p' * markmin2html('iframe:http://www.youtube.com/embed/x1w8hKTJ2Co')* 'piframe src=http://www.youtube.com/embed/x1w8hKTJ2Co; frameborder=0 allowfullscreen/iframe/p' Vladyslav Kozlovskyy (Ukraine) 26.07.12 05:07, Jose ???(??): Hi all From the book: https://web2py.com/books/default/chapter/29/5 The following is not working |embed:http://www.youtube.com/embed/x1w8hKTJ2Co| | | |show me the url and not the video | | | |I'm using the trunk version,in version 1.99.7 works well. | |José| -- --
Re: [web2py] prettydate question
ctrlSoft, is issue still present ? Vladyslav Kozlovskyy (Ukraine) 23.07.12 13:32, ctrlSoft ???(??): datetime format is: 2012-07-18 10:00:00 hi in view i have following code: td{{=prettydate(row.deadline,T)}}/td but result is : %d days ago %d days ago %d days ago %d days ago ... 1 week ago 1 week ago ... %d weeks ago %d weeks ago %d weeks ago how to display 4 days ago 5 days ago ... 2 weeks ago 3 weeks ago ... ... -- --
Re: [web2py] Admin infinite loop on latest trunk
in gluon/validators.py replace line 2582: OLD: key = self.crypt.key.split(':')[1] if ':' in self.crypt.key else '' NEW: key = self.crypt.key.split(':')[1] if self.crypt.key and ':' in self.crypt.key else '' and restart web2py With the best regards, Vladyslav Kozlovskyy (Ukraine) 20.07.12 13:49, Alec Taylor ???(??): Just grabbed the latest trunk from Google Code, and got quite an annoying problem, which I'm guessing was due to the added CSRF checks (http://code.google.com/p/web2py/source/detail?r=26be4b6bb1b607fda73219c93ee3e72f4eecd681). Basically I try to login to the admin panel, and it asks for my password, I enter my password and it has generated a ticket and has heading Internal error, unfortunately I can't view the ticket until I've logged into admin . Infinite loops are annoying! Can you please fix this error? Thanks, Alec Taylor --
Re: [web2py] Admin infinite loop on latest trunk
you are welcome! :) 20.07.12 17:02, Alec Taylor написав(ла): Thanks, seems Massimo just fixed it also So thanks to both of you :) On Fri, Jul 20, 2012 at 9:39 PM, Vladyslav Kozlovskyy vld...@gmail.com wrote: in gluon/validators.py replace line 2582: OLD: key = self.crypt.key.split(':')[1] if ':' in self.crypt.key else '' NEW: key = self.crypt.key.split(':')[1] if self.crypt.key and ':' in self.crypt.key else '' and restart web2py With the best regards, Vladyslav Kozlovskyy (Ukraine) 20.07.12 13:49, Alec Taylor написав(ла): Just grabbed the latest trunk from Google Code, and got quite an annoying problem, which I'm guessing was due to the added CSRF checks (http://code.google.com/p/web2py/source/detail?r=26be4b6bb1b607fda73219c93ee3e72f4eecd681). Basically I try to login to the admin panel, and it asks for my password, I enter my password and it has generated a ticket and has heading Internal error, unfortunately I can't view the ticket until I've logged into admin . Infinite loops are annoying! Can you please fix this error? Thanks, Alec Taylor -- --
Re: [web2py] Re: we need testers for new functionalities
I known where is a problem. I'll fix it Vladyslav 16.07.12 06:15, villas написав(ла): Regarding widgets, the trunk version seems to have introduced a problem. In the past I could do this as per the book: `` name:mywidget ``:widget But now this fails because of the first empty line. I can work around it with this: ``name:mywidget ``:widget I cannot see how this could have changed, so maybe it is a problem I have introduced into my own code, but if anyone else has widgets failing, please try my suggestion above. On Monday, July 16, 2012 1:26:44 AM UTC+1, Massimo Di Pierro wrote: Second. Vladyslav has done an impressive work. I still have lots of patches from him improving many areas. I am finding hard to keep up. ;-) I am also looking for ways to include widgets in the new wiki... Let me know if you have suggestions. Massimo On Sunday, 15 July 2012 17:38:58 UTC-5, villas wrote: I really like the new Markmin features and well done Vladyslav - I am amazed by your results in such a short time! New Wiki is also excellent and is a much neater integration into a site. I have been working quite a lot with plugin_wiki and I'm wondering whether there is some way to leverage my work on widgets, or some syntax planned to include a similar thing? Many thanks for making these improvements :) On Sunday, July 15, 2012 5:36:19 AM UTC+1, Massimo Di Pierro wrote: There is lots of new stuff in trunk. We need you to test it to make sure it does not break your apps. Here I will just mention two new features: 1) Improved MARKMIN (check out the latest examples in gluon/contrib/markmin/markmin.html) including nested lists, nested blockquotes, etc. Thanks to Vladyslav for this. 2) There is a minimalist built-in WIKI. Just do: def index(): return auth.wiki() Then use appadmin to create a 'wiki_editor' group and make yourself member. Yes, that is all. It uses MARKMIN. Use @{index/slug} to insert the ling to a page by slug. Pros? Cons? Suggestions? Checking that old apps do not break is more important than checking for new features.
Re: [web2py] Re: we need testers for new functionalities
Sorry, but I didn't find a mistake in markmin module. Probably it's a wiki-plugin issue. But I'm not familiar with this module yet. With the best regards, Vladyslav Kozlovskyy (Ukraine) 16.07.12 10:06, Vladyslav Kozlovskyy написав(ла): I known where is a problem. I'll fix it Vladyslav 16.07.12 06:15, villas написав(ла): Regarding widgets, the trunk version seems to have introduced a problem. In the past I could do this as per the book: `` name:mywidget ``:widget But now this fails because of the first empty line. I can work around it with this: ``name:mywidget ``:widget I cannot see how this could have changed, so maybe it is a problem I have introduced into my own code, but if anyone else has widgets failing, please try my suggestion above. On Monday, July 16, 2012 1:26:44 AM UTC+1, Massimo Di Pierro wrote: Second. Vladyslav has done an impressive work. I still have lots of patches from him improving many areas. I am finding hard to keep up. ;-) I am also looking for ways to include widgets in the new wiki... Let me know if you have suggestions. Massimo On Sunday, 15 July 2012 17:38:58 UTC-5, villas wrote: I really like the new Markmin features and well done Vladyslav - I am amazed by your results in such a short time! New Wiki is also excellent and is a much neater integration into a site. I have been working quite a lot with plugin_wiki and I'm wondering whether there is some way to leverage my work on widgets, or some syntax planned to include a similar thing? Many thanks for making these improvements :) On Sunday, July 15, 2012 5:36:19 AM UTC+1, Massimo Di Pierro wrote: There is lots of new stuff in trunk. We need you to test it to make sure it does not break your apps. Here I will just mention two new features: 1) Improved MARKMIN (check out the latest examples in gluon/contrib/markmin/markmin.html) including nested lists, nested blockquotes, etc. Thanks to Vladyslav for this. 2) There is a minimalist built-in WIKI. Just do: def index(): return auth.wiki() Then use appadmin to create a 'wiki_editor' group and make yourself member. Yes, that is all. It uses MARKMIN. Use @{index/slug} to insert the ling to a page by slug. Pros? Cons? Suggestions? Checking that old apps do not break is more important than checking for new features.