[web2py] Field.Virtual: unexpected behaviour

2016-05-09 Thread Val K
Hi! I am angry, I wasted half a day to catch this error: db.define_table('tbl', Field('name'), Field.Virtual('alias_name', lambda row: row.name) # right notation is `row.tbl.name` ) in controller: rows = db(db.tbl).select() #it's OK! I

[web2py] Re: Field.Virtual: unexpected behaviour

2016-05-09 Thread Val K
all a little differently: Field.Virtual('alias_name', lambda row: *None*) #- works OK! i.e. row.alias_name *exists* and row.alias_name == *None* *but * Field.Virtual('alias_name', lambda row: row.*bla_bla*) #- causes that row. alias_name *doesn't* *exist at all!* On Monday, May 9, 2016 at 7:05

[web2py] Re: Field.Virtual: unexpected behaviour

2016-05-09 Thread Val K
it seems that `try-except` catches key/attribute error while evaluating field.virtual and if it happens - doesn't create field.virtual at all On Monday, May 9, 2016 at 7:17:07 PM UTC+3, Val K wrote: > > all a little differently: > Field.Virtual('alias_name', lambda

[web2py] Re: Why is this code for getting variables from view to controller not working?

2016-05-09 Thread Val K
Hi! *it seems that the error happens in `str(value)`* *What is your controller like?* On Monday, May 9, 2016 at 8:58:19 PM UTC+3, Emmanuel Dsouza wrote: > > in view: > > *{{extend 'layout.html'}}* > ** > > ** > *function myFunction(){* > *var value = 22;* > *ajax('{{=

[web2py] Re: I would like to know how to redirect the url after login

2016-05-10 Thread Val K
Hi! auth.settings.login_next = *URL(...)* On Tuesday, May 10, 2016 at 2:50:17 AM UTC+3, cron...@udg.co.cu wrote: > > Hello I am new to web2py and I would like to know how to redirect the url > after login, so I forwarded to the same home page. > greetings and thanks in advance > > i found t

[web2py] Re: Very simple issue: redirect on login - auth.settings.login_next

2016-05-26 Thread Val K
Hi! As I understand *requires() * designed to decorate and *back* redirection after login, so it ignores *auth.settings.login_next * If you want to redirect after login just do it from your *check_condition()* directly On Thursday, May 26, 2016 at 5:15:15 PM UTC+3, 黄祥 wrote: > > f

[web2py] Re: readonly field only in SQLFORgrid edit page if field is not empty

2016-05-26 Thread Val K
Where and how can I set the db.foobar.text.writable = False? request.args(1) = 'edit' On Thursday, May 26, 2016 at 12:46:45 PM UTC+3, Mike Constabel wrote: > > Hello, > > I try to find a solutiuon for a hopefully simple problem. > > Example: > > db.define_table("foobar", > Field("uuid", "

[web2py] Re: Append fields within form, iteratively add fields inside form, List:string append, custom forms

2016-05-31 Thread Val K
Hi! Try this controller: def create_table(): a_list = 'My skills and experience:' form1 = SQLFORM(db.Project, hidden=dict(add_term_f1='')) form2 = SQLFORM(db.add_list_item, submit_button=' + Add', hidden=dict(add_term_f2='')) request.post_vars.added_term = request.vars.add_term_f

[web2py] update_or_insert and keyed tables

2016-10-06 Thread Val K
it seems, that *update_or_insert* doesn't work with keyed tables, because it uses *update_record* method ... It's a pity. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (R

[web2py] Re: Pydal ids customs

2016-10-06 Thread Val K
Glad to help you, but there isn't any code On Thursday, October 6, 2016 at 12:47:36 AM UTC+3, argenio...@metamaxzone.com wrote: > > I'm doing a migrate data of 2 databases with diferents tables. > > My only problems is with ids! > > table 1 > id: 5, name: Diana > id: 8, name: Carlos > > > when i

[web2py] Re: validate_and_insert() doesn't work for compute field

2016-10-06 Thread Val K
Yes, it's a bug: *validate_and_insert* calls *_validate_fields* that fills fields with default values (all table fields!), so for 'y' it's *None * from book: " *if a value for the field is not provided*, web2py tries to compute from the other field values using the compute function" but it's pr

[web2py] pair small bugs

2016-10-07 Thread Val K
1. Trying to change 'notnull' of field that is *'reference ...'* hasn't any effect at DB-level, i.e. you can set 'notnull' (False or True) only once, migrate doesn't do the job - no error and no effect 2. Trying to change 'notnull' of *any* field of table with *rname* causes an error, beca

[web2py] Re: pair of small bugs

2016-10-08 Thread Val K
Thank you, Anthony! But I think, that this fact ( web2py does not migrate changes in attributes) makes web2py unsuitable for db-schema development, i.e. I have to consider all the details and write holy code at once. The situation gets worse by the fact that migrate is only half-migrate witho

[web2py] Re: PostGreSQL views

2016-10-12 Thread Val K
Hi! I use PG views quite often. Common problem is related to permissions: don't forget to grant privilege to web2py login role for select/reference from/to your handmade views. To define view I use db.base_table.field.clone() - undocumented function For example: #definition base table define_ta

[web2py] Re: nested loops in views

2016-10-14 Thread Val K
just keep in mind simple rule: {{pass}} == anti-indent On Friday, October 14, 2016 at 7:24:11 PM UTC+3, Pierre wrote: > > Hi, > > why is this not working ? > > {{extend 'layout.html'}} > {{ d={'a':[1,2],'b':[3,4]} }} > > {{for k,v in d.items():}}{{=k}}{{pass}} > {{for vi in v:}}{{=vi}}{{pass}}

[web2py] Re: Referencing another table

2016-10-14 Thread Val K
'reference bursary_users' and requires = [IS_IN_DB(db, 'bursary_users .barcode')] - I think, that it's mutually exclusive requirements 'reference bursary_users' == requires = IS_IN_DB(db, 'bursary_users.*id*') On Friday, October 14, 2016 at 6:21:38 PM UTC+3, James Booth wrote: > > Hey gu

[web2py] Re: How to create a search field(while typing display suggested pages)

2016-10-14 Thread Val K
web2py has SQLFORM.widgets.autocomplete, but you can try chosen.js On Wednesday, October 12, 2016 at 4:55:46 AM UTC+3, sanjana chowdary wrote: > > please help me > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://githu

[web2py] Re: Referencing another table

2016-10-15 Thread Val K
Keep in mind, that 'reference ' - realized at DB-level as FK-constraint, web2py allows to define reference to PK only (you try to refer to not-PK field) requires=... - just web2py validator and has no effect on underlying DB and there isn't an autovalidation of DB manipulation from code

Re: [web2py] Re: Referencing another table

2016-10-15 Thread Val K
If you want to have strict DB-constraints, you can: db.define_table('barcode', Field('code', type='string', unique=True, notnull=True), # *consider just 'code', not 'barcode'* - it's necessary to prevent possible hard-to-catch bugs during SQLFORMs processing

[web2py] Re: No module named appname.modules.funtions

2016-10-31 Thread Val K
Be beware: I had the same bug (No module named appname.modules.func) on windows binary web2py, but with weird behaviour: if server is local - everything OK if server is public, but request is local - everything OK if server is public and request isn't local - causes an error the reason is CAPIT

[web2py] Re: Starting scheduler worker from controller

2016-11-17 Thread Val K
I start scheduler as Linux daemon,it works fine. Can you do that? On Thursday, November 17, 2016 at 7:41:28 PM UTC+3, Gael Princivalle wrote: > > Hello. > > Is it possible to run a scheduler worker from a controller? > Restarting a server kill all workers. I would like to run my workers > automat

[web2py] Re: What a good web2py application architecture looks like?

2016-11-17 Thread Val K
BO seems like stored procedures that expose secure interface to DB, but if it is your aim I think it would be better and more universal to have pure stored procedures at DB-side, no? On Thursday, November 17, 2016 at 3:02:19 PM UTC+3, mfarees...@gmail.com wrote: > > Hi, > I need some help from

[web2py] Re: Why is this query not giving me the correct set of rows as expected?

2016-11-24 Thread Val K
Field('userid') means type 'string', but auth.user_id is integer - does your query work without second condition? On Thursday, November 24, 2016 at 6:21:02 PM UTC+3, Mike Stephenson wrote: > > request.args[0] is just a number representing a day. What's wrong here? > > On Thursday, November 24, 2

Re: [web2py] improving DAL for normalized DB

2016-12-08 Thread Val K
would this differ from reference fields? > > /dps > > >> >> On Sat, Jan 23, 2016 at 4:08 PM, Val K wrote: >> >>> Hi guys! >>> I have an idea to improve DAL in scope of work with normalized DB. >>> As known It's a common practice to avoi

[web2py] Re: Web2py multiple table joins

2016-12-09 Thread Val K
Maybe try to replace db.auth_user.id with auth.user.id or just auth.user_id On Friday, December 9, 2016 at 9:13:27 AM UTC+3, mfarees...@gmail.com wrote: > > Hi > I want to write a query in web2py. The purpose of this query is to return > all users that belong to a user group specified in the

Re: [web2py] improving DAL for normalized DB

2016-12-09 Thread Val K
lone() - very useful function, but still undocumented On Friday, December 9, 2016 at 4:31:48 AM UTC+3, Richard wrote: > > Hello Val K, > > I am not sure I understand fully what your are talking about. On one hand, > I do understand that you would like a proper way to define SQL VIEW in

[web2py] Re: Best way to validate individual conditional Smartgrid Forms

2017-01-20 Thread Val K
Yes! just keep in mind, that *before *call SQLFORM.grid/smartgrid/factory or just SQLFORM or even FORM ( learn two latter details) you can: 1. modify request.vars as you want: request.vars.fieldC='smthng not none' 2. modify fields properties: if request.vars.fieldA: db.table.fieldC.required=

[web2py] Re: Form field defaults the second time through

2017-01-20 Thread Val K
form.vars appear only after form.process() call (process() - filter/convert/format/validate request.vars to form.vars) you have variants : 1. *before *form creation - modify field.default 2. *before* form.process() - modify request.vars - request.vars.PostDate=... 3. pass your own set of var

[web2py] Re: Advice on structuring my app

2017-01-21 Thread Val K
Hi, here is my solution: There are some abstract *actions *like view/edit/delete/upload/download and so on There are the *roles *that define combinations of the actions - it's the table that has 'value' bit field - each bit corresponds to the action There are the *groups *and two symmetric rela

[web2py] Re: Form field defaults the second time through

2017-01-22 Thread Val K
n my post: instead request.vars must be request. *post_*vars - I fixed this On Sunday, January 22, 2017 at 12:48:45 PM UTC+3, Dave S wrote: > > > > On Friday, January 20, 2017 at 9:23:37 AM UTC-8, Val K wrote: >> >> form.vars appear only after form.process() call (pro

[web2py] Re: Form field defaults the second time through

2017-01-22 Thread Val K
re is brute force variant - self-redirection : if form.process().accepted: ... *session.*flash='OK'; redirect(URL()) - but don't forget about args/vars/user_signature if it matters On Sunday, January 22, 2017 at 11:58:06 PM UTC+3, Dave S wrote: > > > > On Sunday

Re: [web2py] Re: Form field defaults the second time through

2017-01-23 Thread Val K
2017 at 2:56:07 PM UTC-8, Val K wrote: >> >> The problem is that one controller is used for generation and process >> form. it's like different modes >> pre-populating form by assignments form.vars.name=... could be used >> only for the request form, when

Re: [web2py] Re: vue.js

2017-01-27 Thread Val K
Vue delimiters are configurable too! @scaffold /static /js /main-vue.js: row#23 Vue.config.delimiters = ['${', '}'] - it's global default config

[web2py] Re: Using jquery and ajax to change form input fields

2017-01-27 Thread Val K
you do an *ajax *request and *immediately * try to use ajax-results On Friday, January 27, 2017 at 5:48:59 PM UTC+3, Morganti wrote: > > Hi guys, > > I have some extra felds no auth_user. I need to complete some fields after > one filled in. > > I am able to read this field using jquery..blur and

[web2py] Re: id table in web2py contain uuid

2017-01-27 Thread Val K
db.define_table(...Field('uuid_field'), primarykey=['uuid_field'] ) - no? On Thursday, January 26, 2017 at 7:15:40 AM UTC+3, 黄祥 wrote: > > let say i got the csv file from another web app, in that csv file contain > a field id that contain uuid > e.g. > a.csv (got from another web app) >

[web2py] Re: Simple search query form, but display data on another page. I know this can't be this hard!

2017-01-27 Thread Val K
as I understand, as 'results' page you mean just another *browser *page, if so - pass to your FORM attr _target='_blank' FORM(... _target='_blank') - isn't tested but should work, because this: A(_href='...', _target='_blank') - works fine On Saturday, January 21, 2017 at 3:42:22 AM UTC+3,

[web2py] Re: Using jquery and ajax to change form input fields

2017-01-27 Thread Val K
_endereco').val(%s);" % > repr(str(session.cep['logradouro'])) > > When the session.cep['logradouro']) there is no special character (utf-8), > ok! It´s running, but, when utf-8 is presented, nothing. > > I tried to use string.decode('utf-8'

[web2py] Re: id table in web2py contain uuid

2017-01-27 Thread Val K
'just wondering is the default id on table that is generated by dal can be replace from integer auto increment into uuid type ?' - I do it everyday! On Saturday, January 28, 2017 at 12:50:24 AM UTC+3, 黄祥 wrote: > > it just created the new field on table name uuid and assign it as a > primary k

[web2py] Re: Using jquery and ajax to change form input fields

2017-01-28 Thread Val K
, but, I used the idea > and studied more and got the solution. > > repr(x.decode('utf-8)').encode('latin_1')) > > where x=session.cep['logradouro'] > > Thanks a lot your helping. > > Best regards > > Em sexta-feira, 27 de janeir

[web2py] Form DOM: Search selected option's text

2015-12-10 Thread Val K
Hi! It just to help others I wasted a pair hours to find right matching expression for searching selected option's *text*-value (not key-value ). It must be like: selected_opt_text = form.element('[name=my_select_field_name] option[ *selected=selected*]')[0] just *'... option[selected]'* mat

[web2py] Re: Form DOM: Search selected option's text

2015-12-11 Thread Val K
r 2015 14:10:01 UTC-6, Val K wrote: >> >> Hi! >> It just to help others >> >> I wasted a pair hours to find right matching expression for searching >> selected option's *text*-value (not key-value ). It must be like: >> >> selected_opt_text = form

[web2py] Re: Pre-populated Forms

2015-12-11 Thread Val K
1. get prototype record 2. overwrite field.default with corresponding prototype value 3. don't pass record to SQLFORM On Monday, December 7, 2015 at 7:15:46 AM UTC+3, Anthony Smith wrote: > > Hi All, > > I have a products table: > db.define_table('product', > Field('product_

[web2py] Re: how to wrap an already existing input element in a new div in web2py

2015-12-18 Thread Val K
if you mean custom view of SQLFORM you can try something like this: def your_controller() ... form=SQLFORM(...) # or SQLFORM.factory ... form.process() ... # creating view - must be after form.process() fcw = form.custom.widget # see web2py book fcl = form.custom.label

[web2py] Re: Pre-populated Forms

2015-12-18 Thread Val K
ValK's response. >> All the best. >> >> >> On Sunday, 13 December 2015 17:53:36 UTC, Anthony Smith wrote: >>> >>> Hi Val, >>> >>> Thanks for your reply, but unable to find any about get prototype record >>> in the book. >

[web2py] DB design

2015-12-26 Thread Val K
I'm not IT-specialist, but I know any theory has own root-idea that may be explained by fingers. I was looking for it in DB theory and I've found it for myself! It is "PerformanceDBA" 's articles at StackOverflow. I think these articles may be very useful for everyone. -- Resources: - http://w

[web2py] Re: This jquery conditional form at pg 505 in book doesn't work. What's the problem?

2016-01-14 Thread Val K
Hi! Try to replace *.attr('checked')* with *.prop('checked')* On Thursday, January 14, 2016 at 12:32:46 PM UTC+3, aston...@gmail.com wrote: > > I am using the latest web2py version > > On Thursday, January 14, 2016 at 2:58:00 PM UTC+5:30, aston...@gmail.com > wrote: >> >> db = DAL('sqlite://d

[web2py] Re: Hide form field

2016-01-14 Thread Val K
hidden=dict(...) - just *extra *hidden fields, it doesn't change attributes of any Field(...) On Thursday, January 14, 2016 at 12:20:22 PM UTC+3, desta wrote: > > Thanks Massimo. I tried what you suggested but they are still visible. > > I was able to achieve what I want using: > form = SQLFORM.

[web2py] Re: Field Type Data

2016-01-14 Thread Val K
Hi! See IS_DATETIME validator in the web2py book On Thursday, January 14, 2016 at 4:49:17 AM UTC+3, Lorenzo Zonca wrote: > > Goodmorning to everyone. > > Through a field "date " with calendar of a C

[web2py] Re: Field Type Data

2016-01-14 Thread Val K
As I see you want to customize date format at form level, i.e. user picks the date from calendar and the field is filled with 'Monday ...' (name of the day) If it's what you want you can use the following: There are two JS-variables are used by calendar (see your_app/views/web2py_ajax.html):

[web2py] Re: connection string syntax of postgres on pythonanywhere

2016-01-16 Thread Val K
try this 'postgres://alexglaros:myPassWord@alexglaros-97. postgres .pythonanywhere-services.com:10097/postgres_es

[web2py] Re: SQLFORM.grid and jQuery-bootgrid help

2016-01-17 Thread Val K
Hi! > Using Bootgrid the TD column html is converted into string. It's very strange, do you check your SQLFORM.grid without using Bootgrid? May be it happens (html to string) at server-side? In your example why do you set *data-formatter* if TD contains already rendered link? On Sunday, Ja

[web2py] Re: best advice on customer/client picklist popup.

2016-01-18 Thread Val K
Hi Lucas! I had similar problem and here is my solution: For search I use SQLFORM.grid with buttons (button per row) having data-attributes, for example, in your case attrs may be: data-client_id, data-client_name with corresponding values Then I use LOAD() with ajax_trap=True to embed SQL

[web2py] improving DAL for normalized DB

2016-01-23 Thread Val K
Hi guys! I have an idea to improve DAL in scope of work with normalized DB. As known It's a common practice to avoid NULL value by creating separate (option) table(s) to store non required fields. So, it would be great to have a field type like "storedin table_name.field_name" For example: db

[web2py] Re: OFF TOPIC: Collaborative data modeling environment

2016-02-07 Thread Val K
Hi Alex! Furtunaly, I'm thinking about the same! I mean the synchronization Postgres-DAL while developing. First of all, I belive you can find the script *extract_pgsql_models.py* in your web2py/scripts directiory, but it just generates models to stdout and you can improve it but why? So, I did

[web2py] Embedding Rapydscript

2016-02-07 Thread Val K
Hi! Coding Python with switching to coding JS - really painful. So, I tried Rapydscript (RS) and I like it very much! Unfortunately, I couldn't find how to automate compilation RS-files to pure JS. Here is my solution to embed RS to web2py 1. Download and install Node.js

[web2py] Re: web2py UnicodeDecodeError: 'utf8' codec can't decode byte 0xc7 in position 15: invalid continuation

2016-02-08 Thread Val K
Hi! I had a similar problem with MS Access. Error like this means that your database encoding isn't utf-8, you should figure out which is it? After that, you can try to set db_codec to proper encoding (see DAL signature in the web2py book) On Thursday, February 4, 2016 at 5:52:02 PM UTC+3, F

Re: [web2py] Embedding Rapydscript

2016-02-08 Thread Val K
this w/o extra coding, but I use Pyscripter only. On Monday, February 8, 2016 at 11:50:08 AM UTC+3, mcm wrote: > > Very nice. > Did you evaluate running compile_pyjs() as a web2py's scheduler task? > It could simplify your code and make it more resilient. > > > 2016-

[web2py] Re: OFF TOPIC: Collaborative data modeling environment

2016-02-08 Thread Val K
It seems you haven't Python installed on your comp (Python isn't windows standard), you can try to use web2py/py.exe to process python-files On Monday, February 8, 2016 at 11:14:35 PM UTC+3, Alex Glaros wrote: > > looks like what I need Val > > can you direct me in how to run it? > > I typed Ma

[web2py] Re: need help connecting to a second database for a copy of application

2016-02-08 Thread Val K
Hi! 1. I believe one pg-install=one pg-server 2. I think that pg listens only one port until you set another one and restart server Why do you think you have to have another pg-server? One pg-server can services many databases - just use different names for DAL, i.e. db=DAL() db1=DAL() to c

[web2py] Re: Displalay a form in light box or pop up window in view

2016-02-11 Thread Val K
Hi! Here is my solution. I have modal_wrapper function. In controller file, I have two controllers - main_page and modal_content: def main_page(): main_pg=DIV() m_cont = LOAD(f='*modal_content**.load*', ajax=True, ajax_trap=True ) dialog = modal_wrapper(m_cont, _id='*co

[web2py] Re: Problems with Upload files

2016-02-11 Thread Val K
1. If you specify uploadfolder, it must be absolute path - something like os.path.join(request.folder, 'path_relative_to_your_app') 2. To store file I use like this: dst = open('your_file_absolute_name', 'wb') shutil.copyfileobj(form.vars.file, dst) dst.close() it works On Friday, Fe

[web2py] Re: Displalay a form in light box or pop up window in view

2016-02-11 Thread Val K
gt; It works, however, I need to pass an argument to my controller > "modal_content". How do I pass a request.args(0) from my view to the > controller in above? Just like I would do > > onclick='window.open("{{=URL("*modal_content*",args=something.id)}}"

[web2py] Re: Problems with Upload files

2016-02-11 Thread Val K
I think you haven't from.process() form=SQLFORM() # or SQLFORM.factory - just makes a set of html-like-component (set of DIV(), INPUT() and so on) form.process() - filters and fills form with request.vars, does validation and so on On Friday, February 12, 2016 at 2:50:14 AM UTC+3, Alfons

[web2py] Re: Problems with Upload files

2016-02-12 Thread Val K
Upload field has custom_store param-see https://www.google.ru/url?q=https://groups.google.com/forum/m/%23!topic/web2py/8X-QlbtyxEQ&sa=U&ved=0ahUKEwiL2r_DlvLKAhWBOSwKHYgSDIwQFggNMAA&sig2=WkaSH-wCNyJiXG0Su3f8uA&usg=AFQjCNEu9h6olQktR8ir7Lk7KgBi1y8aoA -- Resources: - http://web2py.com - http://web2p

[web2py] Re: File picker

2016-02-12 Thread Val K
http://www.web2py.com/books/default/chapter/29/14/other-recipes#Publishing-a-folder On Tuesday, February 9, 2016 at 5:35:41 AM UTC+3, Heinrich Piard wrote: > > Hi all, > > does anyone have an example of a web button which allows me to browse > through the local file system on the web server to pi

[web2py] Re: Displalay a form in light box or pop up window in view

2016-02-12 Thread Val K
view with the argument. If we need to call the LOAD from the view, its > > {{=LOAD('default','manage_things',ajax=True)}} > > Then it fails for m_count. > > > On Friday, February 12, 2016 at 12:20:10 AM UTC-5, Val K wrote: >> >> LOAD() wo

[web2py] Re: reading from external db

2016-02-14 Thread Val K
Be careful with legacy databases! You can do involuntary changes by db.define_table(), to avoid this use migrate=False. If you're going to read only (i.e. only select-query), connect to DB using limited user/role account On Saturday, February 13, 2016 at 1:01:36 AM UTC+3, yarecki wr wrote: >

[web2py] Re: regarding permission

2016-02-17 Thread Val K
Hi! There is a model only in your message, what does your controller like? After "auth = Auth(db)", auth.user_id == id of logged in user (None means nobody logged in) On Wednesday, February 17, 2016 at 12:36:53 PM UTC+3, prashant joshi wrote: > > is there any way to provide permission to the

[web2py] Re: SQLFORM.factory - form.process().accepted fails first time but works after that

2016-02-17 Thread Val K
It seems after first click your form is reloaded, may be there is nested forms in your html-page or something else. What does your LOAD-call like? try ajax=true or ajax_trap=true On Wednesday, February 17, 2016 at 12:17:04 AM UTC+3, Jim S wrote: > > I have a simple SQLFORM.factory form. > >

[web2py] Re: Prepping upload file browser

2016-02-20 Thread Val K
It's possible - just write your own browser ;) You can't access the file system from any browser due to security reasons On Saturday, February 20, 2016 at 4:25:46 AM UTC+3, Dave S wrote: > > Using SQLFORM for a table with a Field('x', 'upload'), is there a way to > tell the file chooser widget w

[web2py] Handling JSON stream

2016-02-21 Thread Val K
How do you serialize form? Jquery.param makes json in extended format by default, try use traditional=true -- 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) ---

[web2py] Re: Handling JSON stream

2016-02-21 Thread Val K
7 PM UTC+3, Kenneth wrote: > > Hi, > > I don't access to change the webform, so I need to get by what I receive. > It is a standard webform in Drupal that sends the JSON. > > > Kenneth > > > Den söndag 21 februari 2016 kl. 13:01:40 UTC+2 skrev Val K: >&g

Re: [web2py] Receiving array passed in from jQuery $.ajax() into Storage object

2016-02-22 Thread Val K
How about including in web2py this module? Here is my variant returning Storage (original returns dict). Usage: post_vars = jquery_unparam_w2p(request.body.read()) # -*- coding: utf-8 -*- # based on jquery-unparam 2.0.0 import re try: from

[web2py] DAL: query using JSON field

2016-02-28 Thread Val K
Hi! Is there any way to produce query using JSON field? It seems that web2py treats args of that query as string: db(db.tabl.json_fld==[1])._select() - "... WHERE tabl.json_fld=='[1]'" db(db.tabl.json_fld[0]==1)._select() - "... WHERE (SUBSTR(tabl.json_fld,1,(2 - 1)) = '1')" I use PostgreSQL a

[web2py] Re: DAL: query using JSON field

2016-02-28 Thread Val K
Note, do not include "WHERE" in the query -- the DAL will add that. Also, > because this query is opaque to the DAL, you must specify fields to select > in the .select() call so the DAL knows what table to query. > > Anthony > > On Sunday, February 28, 2016 at 7:56:21 A

[web2py] Re: Join subqueries

2016-02-29 Thread Val K
Hi! There are many aliases with sub select in your query, it's difficult to understand tables structure. Post tables definition and some comment about what do you want to do, please On Monday, February 29, 2016 at 8:11:09 AM UTC+3, Bill Black wrote: > > SELECT a.*,b.num_passed > FROM (SELEC

[web2py] Re: constraints

2016-02-29 Thread Val K
I see serial(fk) in your tables definition, but FK couldn't be serial, serial means generative id by sequence There is a little singularity in web2py - if you specify "id" as "reference ..." but don't specify it as primarykey=['id'] explicit then web2py treats it as serial id and ignores fk-

[web2py] Re: SQLFORM.grid() control detect_record_change

2016-02-29 Thread Val K
Hi! Web2py does following (roughly): - retrieves DB-record to update and compute hash that is function(record) - stores record-hash and *formkey* as {formkey:hash} in session, so, even the same user opens many forms for the same record, after confirming one of them he'll receive warning while con

[web2py] Re: Join subqueries

2016-02-29 Thread Val K
sult | quiz_id (fk), passed (boolean) > > quiz - question, quiz - result are one to many relations. > > I'm trying to get the 'quiz name, # of questions in the quiz, # of passed > (result) for the quiz' > > > On Monday, February 29, 2016 at 12:43:41 PM UTC-5

[web2py] Re: Join subqueries

2016-02-29 Thread Val K
| quiz_id (fk), passed (boolean) > > quiz - question, quiz - result are one to many relations. > > I'm trying to get the 'quiz name, # of questions in the quiz, # of passed > (result) for the quiz' > > > On Monday, February 29, 2016 at 12:43:41 PM UTC-5, V

[web2py] Re: How to insert different grid elements in tab panels?

2016-03-02 Thread Val K
As I know it's impossible to have 2 "static" (not ajax) SQLFORM.grids at the same page, because each of them will treat request.args as its own On Wednesday, March 2, 2016 at 8:12:49 PM UTC+3, Ron Chatterjee wrote: > > > If I have two independent grid, when I search in one grid, it gets > re

[web2py] PostgreSQL: json_agg()

2016-03-06 Thread Val K
Hi! This is useful aggregate function for PG-users (tested with PostgreSQL 9.3 ): def json_agg_sql(flds_lst, as_alias): json_fld_sql = """ '"%s":' || to_json(%s) """ json_row = [json_fld_sql % (f.name, f.name) for f in flds_lst] json_row_sql = "'{' || " + "|| ',' ||".joi

[web2py] Re: How i can do a form factory 2 tables with bulkdata

2016-03-10 Thread Val K
Hi! 1. it is not quite clear for me, what is the goal of client/property fields? Are they search fields? 2. If you want user to fill/edit/del all these fields (without server interaction) and submit result at once - it's impossible without having some JS-coding 3. Your Bulk

[web2py] DAL: reference to FK-field causes an error

2016-03-12 Thread Val K
Hi! I have a problem - look at example: db.define_table('a_tbl', Field('name')) db.define_table('b_tbl', Field('id', 'reference a_tbl') ,Field('name'), primarykey=['id']) db.define_table('c_tbl', Field('b_tbl_id', 'reference b_tbl') ,Field('name')) *c_tbl* definition causes an error (see below

[web2py] Re: DAL: reference to FK-field causes an error

2016-03-12 Thread Val K
I explicitly define 'id' as primary key in b_tbl, in this case web2py creates table with id as just INTEGER (not incremental) - I've checked it, - it isn't problem The problem is that web2py doesn't perform recursively search for base type of referenced field. It consider that FK-field cou

[web2py] Re: DAL: reference to FK-field causes an error

2016-03-12 Thread Val K
PRIMARY KEY(id)) ; On Saturday, March 12, 2016 at 8:54:37 PM UTC+3, Anthony wrote: > > Not sure if it's a bug, but the book does say: > >- Keyed tables can only reference other keyed tables. >- Referencing fields must use the reference tablename.fieldname

[web2py] Re: DAL: reference to FK-field causes an error

2016-03-12 Thread Val K
# multicolumn primary key reference? if not rfield.unique and len(rtable._primarykey)>1: # then it has to be a table level FK if rtablename not in TFK: works fine! On Sunday, March 13, 2016 at 12:17:06 AM UTC+3, Val K wrote: > >

[web2py] Re: DAL: reference to FK-field causes an error

2016-03-13 Thread Val K
arch 13, 2016 at 3:51:59 AM UTC+3, Anthony wrote: > > You can submit an issue to the pyDAL repo. > > On Saturday, March 12, 2016 at 6:03:10 PM UTC-5, Val K wrote: >> >> >> I've solved my problem - just additional condition >> in dal\pydal\adapters\base.py

[web2py] Re: Advice for small database on GAE

2016-03-13 Thread Val K
Hi! If your DB is so small and could be entirely placed in memory, you could have one yet web2py app on PythonAnywhere.com ( it's free) and use it as just data source. I mean - "every couple of months with 3 or 4 more" your GAE app reload all data from your PythonAnywhere app On Friday

[web2py] Re: fighting with the widget

2016-03-15 Thread Val K
See web2py.js There is : $(ul).find(":text").after('+ -'). keypress(function(e) { return(e.which == 13) ? pe(ul, e) : true; }).next().click(function(e) { pe(ul, e); e.preventDefault(); }).next().click(function(e) { rl(ul, e);

[web2py] Re: iterating through form fields with rows

2016-03-15 Thread Val K
Hi! Just for clarity: *row.field_name* - access to field value of *record retrieved from DB *( by db().select() ) *form.vars.field_name *- access to field value of *submitted from *( *after* form.process() ) form.vars - just a Storage() object like a dict() form.vars.keys() - list of all fi

[web2py] Re: fighting with the widget

2016-03-15 Thread Val K
i.e. not > .w2p_list) > > On Tuesday, March 15, 2016 at 9:44:04 PM UTC+1, Val K wrote: >> >> See web2py.js >> There is : >> $(ul).find(":text").after('+ -'). >> keypress(function(e) { >> return(e.which

[web2py] Re: fighting with the widget

2016-03-15 Thread Val K
There is no problem with bootstrap - you can write your own widgets using its classes, but if you customize/override web2py.js/web2py-bootsrup3.js/widgtes.py you have a chance to get a pain with updating web2py (bootstrap is updated much rarely) optimal solution (I think) - write your own

Re: [web2py] please help with new widgets

2016-03-15 Thread Val K
Date/Time/Datetime Widget - doesn't become hidden after click on another input ( have to click on any non-input, tested in Opera) On Tuesday, March 15, 2016 at 9:40:39 AM UTC+3, Sukrut Joshi wrote: > > please send me college management system which developed in web2py.. > which contain > 'stud

[web2py] Re: multiple id selection using request.vars.name

2016-03-20 Thread Val K
ids= isinstance(request.vars.name, basestring) and [ids] or ids # so it will be a list in anyway post_selected= db(Post._id.belongs(ids)).select() On Sunday, March 20, 2016 at 12:41:24 AM UTC+3, Ron Chatterjee wrote: > > > I have checkbox and from there I read my ids, which is request.vars.name

[web2py] Re: custom authentication

2016-03-20 Thread Val K
Store user_id (or something else) in session and write your own decorator or just test in your controller "who is logged in" On Saturday, March 19, 2016 at 2:31:11 PM UTC+3, T.R.Rajkumar wrote: > > I have the username, password, role in legacy SQL server database. In my > login from I check

[web2py] Serialize object having js-function()

2016-04-27 Thread Val K
Hi! I made mini but useful and universal class to hold json-serializable objects. Main goal - serialize objects having items-function() as js-objects from types import MethodType from gluon.contrib import simplejson as sj class Smart_Storage(dict): """ A Smart_Storage object is like a

[web2py] Re: I need help with db.executesql()

2016-04-28 Thread Val K
is there "# -*- coding: utf-8 -*-" as first line of your file.py? On Friday, April 22, 2016 at 4:13:54 PM UTC+3, c.lp...@gmail.com wrote: > > hi,All: >when i execute the following code: > >>> from gluon import * > >>> db = > DAL('db2:pyodbc://DSN=mydb;uid=db2inst1;pwd=ok896d;',db_codec='UTF-

Re: [web2py] Re: How can I pre populate a option column of a form?

2016-04-28 Thread Val K
'form.vars.field = any' must be placed before form.process() So, in your case: form = SQLFORM(db.pratiche) form.vars.stato_pratica = 'aperta' form.add_button('Back', URL('index')) if form.process().accepted: On Friday, April 22, 2016 at 12:23:59 AM UTC+3, Andrea Marin wrote: > >

Re: [web2py] Re: login by ajax

2016-05-04 Thread Val K
Hi! It seems, that ajax_login isn't exist yet? if not user: self.log_event(self.messages['login_failed_log'], request.post_vars) # invalid login session.flash = self.messages.invalid_log

  1   2   3   4   >