[web2py] smartgrid x lazy tables - bug or by design behavior?
If I set DAL(..., lazy_tables=True) then smartgrid will not display linked_tables. This occurs always, regardless if linked_tables are explicitly defined. Is it a bug or by design behavior? version is 2.8.2 -- 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] Re: impossible to convert decimal
Oops, you were right actually. I was doing a loop, and of course some values where as you said, empty values. Thanks a lot! :D Den torsdagen den 13:e februari 2014 kl. 20:54:57 UTC+1 skrev Cliff Kachinske: It looks like you have an empty value in the table row where you experience the error. On Thursday, February 13, 2014 6:49:44 AM UTC-5, Robin Manoli wrote: Hey, I have a decimal in db, for which I tried numerous ways to round to two decimal points, and also to calculate with other numbers. Basically I want to convert it to a float, but could find no way to do so. The Field looks like this: Field('score', 'decimal(4,3)') It does work to convert to string such as: {{=str(t.score)}} but neither does this work: {{=float(str(t.score))}} # error: type 'exceptions.ValueError' could not convert string to float: None and nor this: {{=float(t.score)}} # error: type 'exceptions.TypeError' float() argument must be a string or a number I even tried to import decimal and calculate that with t.score, but even that didn't work! What's going on? -- 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] Re: Javascript runs locally but not when deployed
What appears in the browser console when you see the deployed version? -- 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] HTML Parser of uploaded file
Goodmorning people, I'm teaching myself web2py and I've a little question for understanding how can i do ... I've a form (becomes from a table) with an upload field i would to upload an html file and I would to parse it in the mean time .. or just after the completition of the operation... eg.: after i've clicked on the submit button so i would import the file and after the parsing filling a new table with the results of the html parse operation. my table : db.define_table(files, Field(name, unique=True), Field('country', requires=IS_IN_DB(db, 'country.printable_name')), Field(files, upload, custom_store=store_file, custom_retrieve=retrieve_file) ) I used (thanks to web2py group experts) these two function for storing and renaming the file uploaded : def store_file(file, filename=None, path=None): path = applications/myappuploads if not os.path.exists(path): os.makedirs(path) pathfilename = os.path.join(path, filename) dest_file = open(pathfilename, 'wb') try: shutil.copyfileobj(file, dest_file) finally: dest_file.close() return filename def retrieve_file(filename, path=None): path = applications/myapp/uploads return (filename, open(os.path.join(path, filename), 'rb')) after I've connected in my display_form() all the things ... def display_form(): if len(request.args): form=SQLFORM(db.files, request.args[0], upload=URL(download)) else: form=SQLFORM(db.files, upload=URL(download)) txt_content=[] if form.process(onvalidation=validate).accepted: content=StringIO.StringIO(data) msg = process_file(content) response.flash = T(msg) elif form.errors: response.flash = T('some errors occurred') else: pass return {form:form} I validate the uploaded file giving the name that i've put in the field name def validate(form): if form.vars.files is not None: form.vars.files.filename = form.vars.name + .html and my process_file is : def process_file(content): all_lines = content msg = 'content not processed' for line in all_lines: try: msg = 'processed succesfully' except: msg = 'error processing' return msg here i've my problems in which way I can parse the html file, with which html parser ? Thank you in advance Luca -- 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] Re: logout error
Hi I updated web2py 2.5 to 2.8, now the login and logout seems to work but with a problem, the login page redirects to errorpage and logout correctly redirects to login page. But my logs are: *** 2014-02-14 10:18:45,224 - DEBUG - web2py.scheduler.ip-10-0-0-175#25487 - defining tables (migrate=True) 2014-02-14 10:18:45,274 - DEBUG - app - login page 2014-02-14 10:18:45,315 - ERROR - app - Traceback (most recent call last): File /srv/trustvouch-fe/applications/app/controllers/default.py, line 25, in login form = auth.login() File /srv/trustvouch-fe/gluon/tools.py, line 2393, in login redirect(next, client_side=settings.client_side) File /srv/trustvouch-fe/gluon/http.py, line 147, in redirect Location=loc) HTTP: 303 SEE OTHER 2014-02-14 10:18:45,515 - DEBUG - web2py.scheduler.ip-10-0-0-175#25487 - defining tables (migrate=True) 2014-02-14 10:19:08,879 - DEBUG - web2py.scheduler.ip-10-0-0-175#25487 - defining tables (migrate=True) 2014-02-14 10:19:08,932 - DEBUG - app - logout 2014-02-14 10:19:08,934 - ERROR - app - Traceback (most recent call last): File /srv/trustvouch-fe/applications/app/controllers/default.py, line 38, in logout auth.logout(next=URL(r=request, c='default', f='index')) File /srv/trustvouch-fe/gluon/tools.py, line 2434, in logout redirect(next) File /srv/trustvouch-fe/gluon/http.py, line 147, in redirect Location=loc) HTTP: 303 SEE OTHER both of them shows http 303 error, seems both have tools.py error, what am I doing wrong. Can anyone help me here, because I need to push live data to my app very soon -- 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] Re: What is proper requires= validator for foreign key?
Great. Thank you. (of course it would be much easier, if use of explicit requires= will cause nothing with implicit represent=) But in one detail it must be different as your version: If I try Field('parent_id', db.parent, requires=IS_IN_DB(db, db.parent.id), represent=lambda id, r: db.parent._format % db.parent(id) if id else '') this works well in appadmin, however it causes internal error in smartgrid: File C:\Python27\Lib\site-packages\web2py_2_8_2\web2py\gluon\sqlhtml.py, line 2764, in smartgrid user_signature=user_signature, **kwargs) File C:\Python27\Lib\site-packages\web2py_2_8_2\web2py\gluon\sqlhtml.py, line 2450, in grid value = field.represent(value, row) File C:\Python27\Lib\site-packages\web2py_2_8_2\web2py\gluon\sqlhtml.py, line 2708, in lambda field.represent = lambda id, r=None, referee=referee, rep=field.represent: A(callable(rep) and rep(id) or id, cid=request.cid, _href=url(args=['view', referee, id])) TypeError: lambda() takes exactly 2 arguments (1 given) This looks like proper solution: Field('parent_id', db.parent, requires=IS_IN_DB(db, db.parent.id), represent=lambda id: db.parent._format % db.parent(id) if id else '') So - your solution, but lambda with 1 parameter only. Thanks, Mirek Dne pátek, 14. února 2014 0:26:45 UTC+1 Anthony napsal(a): If you don't explicitly specify a validator for a reference field and the referenced table has a format attribute, then you get a default validator *and* a default represent attribute (the represent attribute is what is used for read-only displays). However, if you explicitly specify your own validator, then you no longer get the default represent attribute either, and so you must explicitly provider your own. You could do something like: Field('myfield', 'represent othertable', requires=..., represent=lambda id, r: db.othertable._format % db.othertable(id) ifid else '') Anthony On Thursday, February 13, 2014 6:08:55 PM UTC-5, Mirek Zvolský wrote: As user of my application I don't want see any ID's at all - instead I want always see record content formatted from format=.. In smartgrid I am able to receive records instead of ID's only, if I run with default validator for foreign key (i.e. without requires=..) In such case (without requires=..) I see related records for readonly foreign keys (View) and for readwrite foreign keys (Edit). If I use requires=.. then for readonly foreign keys I see ID's and I have no idea, how to prevent it. If I need a foreign key, which should be None for some records, then I think it is necessary to use requires=IS_EMPTY_OR(IS_IN_DB(db, db.parent.id)) However this will display ID's instead of formatted records for readonly foreign keys. :((( How to do it proper? Can represent=.. help? Or? I try it with 2.8.2 version. Thanks for help ! (Note: I don't know, if answer to my question was same in older versions, or if it has changed in 2,8.2 with new constraint handling for SQLite.) -- 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] Re: HTML Parser of uploaded file
BeautifulSoup http://www.crummy.com/software/BeautifulSoup/ is a common option. -- 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] REF: Join query help!
I have problem, I would like to have achieve a query which displays the value of the foreign key: db.define_table(owner, Field(owner_name)) db.define_table(dog, Field(dog_name), Field(owner, reference owner)) rs = db(db.owner.id==db.dog.owner).select(db.owner.name, db.owner.name) what i want to result set to be is: is a list of dictionaries with {fieldname:value} in this case have [{owner_name: Paul}, {dog_name, Snoopy}], [{owner_name: Ben}, {dog_name, Poopy}], ... ... how do i iterate through my record set rs above cause i am having challenges if i do it like this: for row in rs: for k, v in (row.as_dict()).items(): print '', k,' and ', v I am getting weird results! Any help? -- ... Teddy Lubasi Nyambe Opensource Zambia Lusaka, ZAMBIA Cell: +260 97 7760473 website: http://www.opensource.org.zm ~/ Human Knowledge belongs to the world! - AntiTrust Man is a tool-using animal. Without tools he is nothing, with tools he is all - Thomas Carlyle 1795-1881 /~ -- 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] manage scheduler result with smartgrid
Hi! does anybody can tell me what's wrong in this controller? def task(): if 'view' in request.args: sdb.scheduler_task.vars.represent = lambda v,row: myBEAUTIFY(loads(v), body=PRE) grid = SQLFORM.smartgrid(sdb.scheduler_task, linked_tables=['scheduler_run'], deletable=False, editable=False, create=False, csv = False, fields = [ sdb.scheduler_task.task_name, sdb.scheduler_task.status, sdb.scheduler_task.start_time, sdb.scheduler_task.args, sdb.scheduler_task.vars ], orderby=~sdb.scheduler_task.id ) return dict(grid=grid) I want to manage scheduler task result using a single smartgrid... in the resulting grid I got not column linked to scheduler_run. thankyou very mutch. Manuele -- 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] A DAL mssql question. Connection with FreeTDS and Unicode data in a Unicode-only collation problem
Hi, I am for the first time messing with mssql dal adapter and are really struggling to get it working to a SQL2008 server.. I have gotten the connection with FreeTDS working When I connect in python with. conn = pyodbc.connect ('DSN=TS;UID=foo;PWD=bar') cursor = conn.cursor() cursor.execute(select * from INVENT where ID=3000) pyodbc.Cursor object at 0x14591b0 for row in cursor: ... print row Everything works.. But when connecting with dal: db = DAL('mssql://foo:bar@host/db?DRIVER={FreeTDS}', migrate_enabled=False) I get the.. class 'pyodbc.ProgrammingError' ('42000', '[42000] [FreeTDS][SQL Server]Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier. (4004) (SQLExecDirectW)') I tried to send ?DRIVER={FreeTDS}TDS_VERSION=8.0 with no result.. And I cannot do a DSN connection with DAL: db = DAL('mssql://DSN=TS;UID=foo;PWD=bar', migrate_enabled=False) Any ideas? Sorry if this has been up before and I missed totally.. But I am really stuck here :) -- Regards Falk -- 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] Single form for many to many relationship
Hi! I'm looking for solution for nice single SQLFORM for many to many relationship. For example I have such model: db.define_table('person', Field('name'), Field('position'), Field('office', 'integer')) db.define_table('thing', Field('name'), Field('color')) db.define_table('person_thing', Field('person_id', 'reference person'), Field('thing_id', 'reference thing')) And I want to creeate SQLFORM.grid for table person, with insert/update form containing list of checkboxes for things, and ability to add new thing from that form, like this: Name: [Alex] Poszition: [CEO] Office: [13] Things: Thing1 [v] Thing2 [ ] Thing3 [v] (Add new thing button) Is it possible? -- 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] Re: manage scheduler result with smartgrid
Il 14/02/14 12:13, Manuele Pesenti ha scritto: Hi! does anybody can tell me what's wrong in this controller? Ok.. thanks to Mirek Zvolský I found that the main problem was linked to that I set up my scheduler db with lazy_tables=True. Now (changed that option to False) for every record the link to children runs is visible but the resulting grid says: Query Not Supported: no such column: scheduler_task.id What's the problem now? Thanks a lot Cheers Manuele -- 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] Cannot access virtual fields within a IS_IN_DB format function?
Given this table... translator_format = lambda row: row.custom_name if (row.custom_name and row.custom_name.strip()) else %s - %s %( db.notation(row.source_notation_id).notation_name, db.notation(row.target_notation_id).notation_name) db.define_table(translator, # A name for the translator is not required. If the custom name is empty, the name will be computed # from the notation names Field(custom_name, string, length=512, ), Field.Virtual(translator_name, translator_format), # ... format = translator_format, ) ... I'm trying to define this form: form = SQLFORM.factory( Field(translator_id, reference translator, label=T(Translator), requires = IS_IN_DB( db(translator_query), db.translator.id, translator_chooser_representation, zero=None, sort=False), ), # ... ) Now, within the format function, i cannot access the virtual field of the row: def translator_chooser_representation(r): return %s %(r.translator_name) ## This I'd like to use but it doesn't work return db.translator._format(r) ## This works, but I'd like the actual result to be different from the format Am I doing something wrong? -- 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] Re: REF: Join query help!
I'm not sure I'm understanding exactly what you're trying to do. You say you want to display the value of the foreign key (which would be an integer) but in your code you seem to be only interested in the names. So this may or may not be what you want. I've found a bug here rs = db(db.owner.id==db.dog.owner).select(db.owner.name, db.owner.name) This should be: rs = db(db.owner.id==db.dog.owner).select(db.owner.name, db.dog.namehttp://db.owner.name/ ) Then you can do: for r in rs: print r.owner.name + ' : ' + r.dog.name -- 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] Re: Cannot access virtual fields within a IS_IN_DB format function?
def translator_chooser_representation(r): return %s %(r.translator_name()) -- 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] Inputs for multiple records in same view
Hi, I've got a situation where I need to be able to input data for multiple records simultaneously. Records from the single table below: Model: db.define_table('t_toc_elements', Field('belongs', type='string', label=T('Belongs to work')), Field('name', type='string', label=T('Node name')), ... Field('material', type='text', label=T('Textual material (XML, text, etc.)')), Field('children', type='string', label=T('Children of node')), This is queried as per usual to get hits with a matching value in a particular field, say for toc elements that belong to the same work. Of course, getting the results to show up in a table is quite straightforward, i.e. using sqltable, etc. As is getting an input page using form factory, albeit this only gives input fields for ***one*** record. What I need is a combination of the two: input for all matching records on one page. Any ideas? -- 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] A Select Tag Helper Code
I wasn't able to find a simple function that would help generate a SELECT tag given a set of options (I did see the OPTION function) so created a simple one and thought it'd be useful to share. I'm new to Python so this may not be very elegant, but it works. The function takes the tag's name and a dictionary of options as input, returns an XML formatted completed select tag. def select_tag(name, options): select_tag='select name='+name+'' for key in options.keys(): select_tag=select_tag+'option value='+options[key]+''+key+ '/option\n' select_tag=select_tag+'/select' return XML(select_tag) -- 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] IS_IN_DB drop-down for search
Hi, I have a search bar with 2 columns, group and address. form = SQLFORM.factory(Field('ugroup', requires=IS_IN_DB(db, customers.gid', '%(group)s'), label='User group'), Field('address', label='address'), formstyle=divs, submit_button=Search, keepvalues=True ) The search page renders fine. But the search submission always forces to choose the ugroup from the drop-down, else i get the value not in database error. I want the search to choose either ugroup or address, optionally both for narrow results. How can i make 1. IS_IN_DB validation optional or 2. Override the IS_IN_DB validation with my custom validation something like this def check_search(form): if (not form.vars.ugroup) and (not form.vars.address): form.errors.ugroup= 'Need input on user group or address' if form.process(onvalidation=check_search).accepted: perform next steps I don't like to make the ugroup, a text box, when drop-down is better from usability perspective. Thanks, Yogesh -- 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] Treat Datetime field as Date?
I'm connecting to an MSSQL 2005 db, which only has the Datetime format (Date was added in 2008). Is there a standard way to treat a Datetime as a Date in web2py for forms and formatting? I've done the following, and it works thus far, but it seems a bit hackish. Field('BirthDte', 'datetime', widget=SQLFORM.widgets.date.widget, requires=IS_DATE(), represent = lambda value, row: value.strftime(%#d %b %Y)) -- 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] Form with related model can't validate NULL value
Hi, First time i write to the list. Been googling around and couldn't find a solution that i understand. I am really new to python and web2py. I have this model legacy_db.define_table('courses', Field('name','string'), Field('version','string'), Field('link','string'), Field('pro_id',legacy_db.project), Field('cli_id',legacy_db.client), format='%(name)s', migrate=False) NOTE: The pro_id field in the DATABASE (mysql) references the project table via FK. It allows NULL values as the only mandatory field should be client. So i added the courses through phpmyadmin correctly with the pro_id set to NULL to various courses. I created a controller to insert/edit that table so if someone wants to add a course can do it without having access to admin or to DB. def edit_courses(): form=SQLFORM(legacy_db.courses) if form.process().accepted: response.flash = 'Course was added Correctly' return dict(form=form,message=T('Edition for Courses')) View {{extend 'layout.html'}} h1{{=message}}/h1 {{=form}} So the issue comes when i insert a course with no pro_id field. Validators assume that one of the referenced values whould be used. And don't know how to put NULL which should be the case here. Thanks for the help. -- 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] web2py secrets video part 2???
I have been using videos and tutorials to get me going on web2py. I loved this video: http://pyvideo.org/video/433/pycon-2011--web2py-secrets-tutorial--1-2 I cannot seem to find the 2nd part if there is one. I was wondering if Massimo or anyone else had a link to share? Thanks, Alan -- 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] GAE localhost mysql instance
Hi, Can anyone point me to any resource that show me how to use CloudSQL+GAE together with a local mysql development environment on mac..It can't seem to connect to the local mysql for development purposes. I did this: if not request.env.web2py_runtime_gae: db = DAL(mysql://root:123@localhost/testing) else: db = DAL(google:sql://juslintest:data/testgae) session.connect(request, response, db=db) Error: RuntimeError(Failure to connect, tried %d times:\n%s % (attempts, tb)) RuntimeError: Failure to connect, tried 5 times: RuntimeError: no driver available ('MySQLdb', 'pymysql', 'mysqlconnector') -- 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] New to Web2Py: Large Model
Hi, I have an application in PHP with 500 over tables, what's the best way to managed them in Web2Py, without repeating model definitions nor loading them all. -- 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] Large Number of Models in Web2py
Hi All, I new to Web2py, comtemplating shifting a 500 over tables PHP Application over... Do you all know where i can learn how to optimize Web2py for large number of models. Is there a way i could define them without having to repeat it, at the same time, not loading all the models. [Sorry if i make many posts, they are not showing up on my list somehow after posting] -- 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] Re: [CLOSED] XMLHttpRequest cannot load https://www..... disallowed for cross-origin request ...
why didnt you specify what was a solution On Wednesday, December 18, 2013 4:05:43 PM UTC+5, weheh wrote: Looks like I got it working. The Apache config file wasn't complete, so once I found that issue, the CORS started to function properly. Thanks again for your responses. On Monday, December 16, 2013 11:16:05 PM UTC+8, Marin Pranjić wrote: Well, as I said, try your own jquery.ajax call. If it works, then CORS is enabled but component load is failing. If it doesn't work, then you didn't enable CORS correctly. You should also try $.ajax({crossDomain: true, ...}); JQuery should add it automatically but maybe it's not detecting it properly. On Mon, Dec 16, 2013 at 4:12 PM, weheh richard...@verizon.net wrote: @Marin: Thanks for your suggestion. I believe that that is precisely what is causing this issue. The original call is an HTTP call. It's followed by an HTTPS that results in the error message. But still no idea how to get the https call to go through. On Monday, December 16, 2013 10:45:45 PM UTC+8, Marin Pranjić wrote: @weheh can you try a custom jQuery.ajax cross domain call for testing/debugging? (just load something from HTTP to HTTPS) On Mon, Dec 16, 2013 at 2:38 PM, weheh richard...@verizon.net wrote: Hi Anthony, I added CORS stuff to my Apache httpd.conf as per this http://enable-cors.org/server_apache.html but I'm still getting the same error message. Any ideas about how to push through this? On Sunday, December 15, 2013 1:13:55 AM UTC+8, Anthony wrote: Is it in fact a cross-origin request, and have you set up CORS on the server? On Saturday, December 14, 2013 10:39:25 AM UTC-5, weheh wrote: I've got a dialog that I pop open and on it is a button that makes a web2py_component call. The button code looks like this, after it's gone through the XML() helper and jquery UI. button class=... onclick=if (confirm('Read?')) { web2py_component(quot;https://www.mysite.com/mycontroller/m yfunc.load?pc=YGYzlEh6amp;_signature=607e035a239d88bd3ab8652814ceff 2a9cab92b5quothttps://www.mysite.com/mycontroller/myfunc.load?pc=YGYzlEh6_signature=607e035a239d88bd3ab8652814ceff2a9cab92b5quot;, quot;target-divquot;); } role=button aria-disabled=false ... /button The button works fine when I launch it from my development machine: http://127.0.0.1:8000/myapp/... But, when I migrate the code to the server and execute there, I get an error. Firebug reports the following: XMLHttpRequest cannot load https://www.mysite.com/mycontr oller/myfunc.load?pc=YGYzlEh6_signature=https://www.yakitome.com/store/execute.load?pc=HcfnI_pVpid=7qty=1_signature=6c18eb4d880e19d463d85df3f9b02c97b5c8430e 607e035a239d88bd3ab8652814ceff2a9cab92b5. The request was redirected to 'https://www.mysite.com/user/login.load?_next=/ mycontroller/myfunc.load%https://www.yakitome.com/user/login.load?_next=/store/execute.load%3Fpc%3DHcfnI_pV%26pid%3D7%26qty%3D1 pc=YGYzlEh6https://www.yakitome.com/store/execute.load?pc=HcfnI_pVpid=7qty=1_signature=6c18eb4d880e19d463d85df3f9b02c97b5c8430e', which is disallowed for cross-origin requests that require preflight. Anybody have any idea how to deal with 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+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+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.
[web2py] Re: impossible to convert decimal
For 2 decimal precision, you can try, {:.2f}.format(your_value) On Thursday, February 13, 2014 6:49:44 AM UTC-5, Robin Manoli wrote: Hey, I have a decimal in db, for which I tried numerous ways to round to two decimal points, and also to calculate with other numbers. Basically I want to convert it to a float, but could find no way to do so. Nor could I convert it to string, or make any other number a decimal. Please help! -- 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] Escaping '%' percent character
Hello, I've looked through the documentation and the questions asked but I haven't been able to escape the '%' percent character in a string. I've tried using '\%' and '%%' in a label string, but none has worked so far. I'd appreciate the help. -- 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] Re: Manual image upload
db.mytable.insert(image=db.mytable.image.store(request.vars.image.file, request.vars.image.filename), image_blob = request.vars.image.file.read()) this should work, ref http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#More-on-uploads Note, if the file is to be stored in an associated blob field rather than the file system, the store() method will not insert the file in the blob field (because store() is called before the insert), so the file must be explicitly inserted into the blob field: db.define_table('myfile', Field('image', 'upload', uploadfield='image_file'), Field('image_file', 'blob')) stream = open(filename, 'rb') db.myfile.insert(image=db.myfile.image.store(stream, filename), image_file=stream.read()) On Friday, 11 May 2012 01:49:00 UTC+5:30, 王康 wrote: hi, have you guys solved this problem? Because now I'm in the same problem _ On Sunday, December 26, 2010 4:15:54 AM UTC+8, mdipierro wrote: Email me your app. On Dec 25, 2:08 pm, Arun K.Rajeevan the1.a...@gmail.com wrote: https://groups.google.com/d/msg/web2py/UtBmAdvY7E0/QQ5rBVM4lEIJ tables are given in that post. But, as I point out last, problem may be in conversion of file into blob and getting it back. BTW, if you can suggest a solution discussed in above link that will be great; although this problem is amusing, I'm in need for a solution. -- 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] rows.export_to_csv_file and headers
Hi. I have noticed that a few people have been frustrated with changing the colnames when exporting to cvs. I have arrived at a fairly compact solution, but perhaps not the most efficient one for large cvs dumps. For the record, and perhaps a bit of criticism, here it is :-) controller def foo(): if request.extension in ('csv','tsv'): rows = db().select(db.vw_traffic_by_time.ALL, orderby=db.vw_traffic_by_time.best_slot) return dict(rows=rows) view foo.tvs {{ import cStringIO stream=cStringIO.StringIO() colnames=map(lambda c: c.split('.')[1], rows.colnames) # get rid of the table part seek = len(\t.join(rows.colnames)+\r\n) # possibly faster than readlines()[1:]? rows.export_to_csv_file(stream, delimiter=\t,null=0) stream.seek(seek) response.headers['Content-Type']='application/vnd.ms-excel' response.write(\t.join(colnames) + \r\n, escape=False) response.write(''.join(stream.readlines()), escape=False) }} -- 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] Multi player game with Web2py
Hi, I find this difficult to formulate so bear with me. I am looking to implement something like a multi player web server, except that instead of games, users would be answering questions or selecting options. The responses of the users would change the evolution of the questions/options presented as the game progresses. I imagine that the server would present different rooms where games will start in a room when N players are logged in. Could I use Web2py for an application like this? There is a project in Node called Pomelo that targets these type of applications, but I would like to stick to web2py. There is no graphics involved neither high data traffic needed in what I intend to develop. I look forward to any help/suggestions. Thanks! Clara -- 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] iterating form.custom.widget and set _class attribute
As explained in the book I can modify a fields class by setting _class as follows: form.custom.widget.some_field['_class']=input-block-level however when I iterate form.cutom.widget as in following snippet: {{for field in form.custom.widget:}} {{=SPAN(form.custom.label[field])}} {{form.custom.widget[field][_class] = some-sample-class}} {{=form.custom.widget[field]}} {{pass}} TypeError is raised when I try to set _class, since form.custom.widget[field] is a str instance. How can I overcome this, do you have any suggestions? -- 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] auto.py converting mysql schema to web2py models?
Hello, I searched in group for a tool to convert mysql schema to web2py models. There is talk about an auto.py script but link to that script seems broken. Is there another way to do this now or is it even possible? Osman Kazdal -- 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] Can i still display the search form if i have set searchable=False in the SQLFORM.grid?
Hi, I need help with SQLFORM.grid, Is there any way i can display the search column even if i have set searchable=False in the SQLFORM.grid. Please let me know. Thank you Suhail -- 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] web2py large model
Hi, Can anyone advise on this. We have an application on PHP with 500 over tables. Is there any strategy we can adopt when using web2py to manage the models? Coz it seems too much for web2py models structure to chew. -- 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] rows.export_to_csv_file and headers
Hi. I have noticed that a few people have been frustrated with changing the colnames when exporting to cvs. I have arrived at a fairly compact solution, but perhaps not the most efficient one for large cvs dumps. For the record, and perhaps a bit of criticism, here it is :-) controller def foo(): if request.extension in ('csv','tsv'): rows = db().select(db.vw_traffic_by_time.ALL, orderby=db.vw_traffic_by_time.best_slot) return dict(rows=rows) view foo.tvs {{ import cStringIO stream=cStringIO.StringIO() colnames=map(lambda c: c.split('.')[1], rows.colnames) # get rid of the table part seek = len(\t.join(rows.colnames)+\r\n) # possibly faster than readlines()[1:]? rows.export_to_csv_file(stream, delimiter=\t,null=0) stream.seek(seek) response.headers['Content-Type']='application/vnd.ms-excel' response.write(\t.join(colnames) + \r\n, escape=False) response.write(''.join(stream.readlines()), escape=False) }} -- 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] Custom Regisration Form
I extended the auth_user table with additional profile fields (e.g. phone number, alert preference, etc.) and I'm trying to customize the registration form so that it shows only the desired fields (accomplished per documentation) and display the desired fields in a custom manner, including adding a drop down which is based on content which isn't in the database. I'm struggling to figure out a way to control the form's display and processing - I'm either not understanding the documentation and other instructions I found or trying to do something odd. - I'm exposing the user() function at /{app}/login rather than the standard location. - I tried to place a def register() function in the /{app}/long controller but that doesn't seem to have any effect. - I can display the custom registration form using an if statement in the login/user view, but I'm not sure how to process it afterwards when it submits (nor where it submits to). Any help/pointers would be much appreciated. -- 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] subscription problems - testing testing
Is there a secret first-post moderation policy on this list? I managed to subscribe by email without a hitch, but my posts to the list just disappear into thin air. Help anyone? G. -- 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] rows.export_to_csv_file and headers
Hi. I have noticed that a few people have been frustrated with changing the colnames when exporting to cvs. I have arrived at a fairly compact solution, but perhaps not the most efficient one for large cvs dumps. For the record, and perhaps a bit of criticism, here it is :-) controller def foo(): if request.extension in ('csv','tsv'): rows = db().select(db.vw_traffic_by_time.ALL, orderby=db.vw_traffic_by_time.best_slot) return dict(rows=rows) view foo.tvs {{ import cStringIO stream=cStringIO.StringIO() colnames=map(lambda c: c.split('.')[1], rows.colnames) # get rid of the table part seek = len(\t.join(rows.colnames)+\r\n) # possibly faster than readlines()[1:]? rows.export_to_csv_file(stream, delimiter=\t,null=0) stream.seek(seek) response.headers['Content-Type']='application/vnd.ms-excel' response.write(\t.join(colnames) + \r\n, escape=False) response.write(''.join(stream.readlines()), escape=False) }} -- 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] Re: Broken app IOError: [Errno 13] Permission denied
I recently came across this issue to when using wsgi mod. The simple think i needed to do was adding the full root folder to the session path. like: session = web.session.Session(app, web.session.DiskStore('%s/sessions'%global_variables.ROOT), {'count': 0}) -- 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] IS_IN_DB: how to overwrite validator
Hi, I am re-posting this question, for some reason i don't see my earlier post in this forum. I have a form with 2 fields for search, one text, other drop-down. I want the users to be able to type in the free text or choose from drop-down or both. form = SQLFORM.factory(Field('address', label='Address'), Field('ugroup', requires=IS_IN_DB(db, db.t_ugroups, '%(group_desc)s'), label='User group'), formstyle=divs, submit_button=Search ) I have a custom form validator to check that both are not null. def check_search(form): if (not form.vars.ugroup) and (not form.vars.address): form.errors.ugroup = 'Need input on user group or address' The problem is the IS_IN_DB kicks in and throws an error value not in database if only address is typed and searched. How do i overwrite the IS_IN_DB validator with my custom validator? Thanks, Yogesh -- 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] Re: smartgrid x lazy tables - bug or by design behavior?
A given table doesn't know about its linked tables until the tables are fully defined, so you won't get any linked tables automatically when lazy_tables=True. However, the following should work: SQLFORM.smartgrid(db.mytable, linked_tables=[db.othertable1, db.othertable2 ]) Unfortunately, there is a bug that is preventing that from working right now (in fact, the above won't work even with lazy_tables=False). I'll submit a patch. Note, you cannot do linked_tables=['othertable1', 'othertable2'] (which works when lazy_tables=False) -- you must use the [db.othertable1, db.othertable2] format in order to trigger the full definition of those tables. For now, as a workaround, you can just manually trigger the full table definitions before calling smartgrid: db.othertable1, db.othertable2 SQLFORM.smartgrid(db.mytable) Anthony On Friday, February 14, 2014 3:57:09 AM UTC-5, Mirek Zvolský wrote: If I set DAL(..., lazy_tables=True) then smartgrid will not display linked_tables. This occurs always, regardless if linked_tables are explicitly defined. Is it a bug or by design behavior? version is 2.8.2 -- 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] Re: subscription problems - testing testing
Yes, new members are moderated. You now have permission to post. Anthony On Friday, February 14, 2014 1:12:05 AM UTC-5, Gaute Amundsen wrote: Is there a secret first-post moderation policy on this list? I managed to subscribe by email without a hitch, but my posts to the list just disappear into thin air. Help anyone? G. -- 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] Re: smartgrid x lazy tables - bug or by design behavior?
Thank you for perfect answer. I have 2 workarounds: yours --or-- lazy_tables=True. Both are good enough for me for now. Dne pátek, 14. února 2014 14:55:15 UTC+1 Anthony napsal(a): A given table doesn't know about its linked tables until the tables are fully defined, so you won't get any linked tables automatically when lazy_tables=True. However, the following should work: SQLFORM.smartgrid(db.mytable, linked_tables=[db.othertable1, db. othertable2]) Unfortunately, there is a bug that is preventing that from working right now (in fact, the above won't work even with lazy_tables=False). I'll submit a patch. Note, you cannot do linked_tables=['othertable1', 'othertable2'] (which works when lazy_tables=False) -- you must use the [db.othertable1, db.othertable2] format in order to trigger the full definition of those tables. For now, as a workaround, you can just manually trigger the full table definitions before calling smartgrid: db.othertable1, db.othertable2 SQLFORM.smartgrid(db.mytable) Anthony On Friday, February 14, 2014 3:57:09 AM UTC-5, Mirek Zvolský wrote: If I set DAL(..., lazy_tables=True) then smartgrid will not display linked_tables. This occurs always, regardless if linked_tables are explicitly defined. Is it a bug or by design behavior? version is 2.8.2 -- 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: subscription problems - testing testing
Thanks :) Now let's hope all my attempted postings don't all show up at once :-) Resubmitting original in a moment. G. On 02/14/2014 03:05 PM, Anthony wrote: Yes, new members are moderated. You now have permission to post. Anthony On Friday, February 14, 2014 1:12:05 AM UTC-5, Gaute Amundsen wrote: Is there a secret first-post moderation policy on this list? I managed to subscribe by email without a hitch, but my posts to the list just disappear into thin air. Help anyone? G. -- 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] rows.export_to_csv_file and headers
Hi. I have noticed that a few people have been frustrated with changing the colnames when exporting to cvs. I have arrived at a fairly compact solution, but perhaps not the most efficient one for large cvs dumps. For the record, and perhaps a bit of criticism, here it is :-) controller def foo(): if request.extension in ('csv','tsv'): rows = db().select(db.vw_traffic_by_time.ALL, orderby=db.vw_traffic_by_time.best_slot) return dict(rows=rows) view foo.tvs {{ import cStringIO stream=cStringIO.StringIO() colnames=map(lambda c: c.split('.')[1], rows.colnames) # get rid of the table part seek = len(\t.join(rows.colnames)+\r\n) # possibly faster than readlines()[1:]? rows.export_to_csv_file(stream, delimiter=\t,null=0) stream.seek(seek) response.headers['Content-Type']='application/vnd.ms-excel' response.write(\t.join(colnames) + \r\n, escape=False) response.write(''.join(stream.readlines()), escape=False) }} -- 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] Re: Cannot access virtual fields within a IS_IN_DB format function?
Not sure if this is the problem, but your virtual field function should refer to row.translator.custom_name rather than row.custom_name. Anthony On Friday, February 14, 2014 8:00:17 AM UTC-5, Horst Horst wrote: Given this table... translator_format = lambda row: row.custom_name if (row.custom_name and row.custom_name.strip()) else %s - %s %( db.notation(row.source_notation_id).notation_name, db.notation(row.target_notation_id).notation_name) db.define_table(translator, # A name for the translator is not required. If the custom name is empty, the name will be computed # from the notation names Field(custom_name, string, length=512, ), Field.Virtual(translator_name, translator_format), # ... format = translator_format, ) ... I'm trying to define this form: form = SQLFORM.factory( Field(translator_id, reference translator, label=T(Translator), requires = IS_IN_DB( db(translator_query), db.translator.id, translator_chooser_representation, zero=None, sort=False), ), # ... ) Now, within the format function, i cannot access the virtual field of the row: def translator_chooser_representation(r): return %s %(r.translator_name) ## This I'd like to use but it doesn't work return db.translator._format(r) ## This works, but I'd like the actual result to be different from the format Am I doing something wrong? -- 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] Re: HTML Parser of uploaded file
Why are you using the custom store and retrieve methods? Note, looks like you might be vulnerable to a directory traversal attack (depending on whether you're validating the filename argument passed to the retrieve function). Anthony On Friday, February 14, 2014 5:21:40 AM UTC-5, Luca Guerrieri wrote: Goodmorning people, I'm teaching myself web2py and I've a little question for understanding how can i do ... I've a form (becomes from a table) with an upload field i would to upload an html file and I would to parse it in the mean time .. or just after the completition of the operation... eg.: after i've clicked on the submit button so i would import the file and after the parsing filling a new table with the results of the html parse operation. my table : db.define_table(files, Field(name, unique=True), Field('country', requires=IS_IN_DB(db, 'country.printable_name')), Field(files, upload, custom_store=store_file, custom_retrieve=retrieve_file) ) I used (thanks to web2py group experts) these two function for storing and renaming the file uploaded : def store_file(file, filename=None, path=None): path = applications/myappuploads if not os.path.exists(path): os.makedirs(path) pathfilename = os.path.join(path, filename) dest_file = open(pathfilename, 'wb') try: shutil.copyfileobj(file, dest_file) finally: dest_file.close() return filename def retrieve_file(filename, path=None): path = applications/myapp/uploads return (filename, open(os.path.join(path, filename), 'rb')) after I've connected in my display_form() all the things ... def display_form(): if len(request.args): form=SQLFORM(db.files, request.args[0], upload=URL(download)) else: form=SQLFORM(db.files, upload=URL(download)) txt_content=[] if form.process(onvalidation=validate).accepted: content=StringIO.StringIO(data) msg = process_file(content) response.flash = T(msg) elif form.errors: response.flash = T('some errors occurred') else: pass return {form:form} I validate the uploaded file giving the name that i've put in the field name def validate(form): if form.vars.files is not None: form.vars.files.filename = form.vars.name + .html and my process_file is : def process_file(content): all_lines = content msg = 'content not processed' for line in all_lines: try: msg = 'processed succesfully' except: msg = 'error processing' return msg here i've my problems in which way I can parse the html file, with which html parser ? Thank you in advance Luca -- 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] Re: SQLFORM.factory without a database table
SQLFORM.factory is for generating forms, not grids. The grid requires an actual database, though you can use a SQLite memory database: https://groups.google.com/d/msg/web2py/g4Mon6PvNFc/jytHfEnOXTIJ. Anthony On Friday, February 14, 2014 12:03:33 AM UTC-5, A36_Marty wrote: I would like to make a grid-like screen without an underlying database table. I've read the section in the book: http://www.web2py.com/books/default/chapter/29/07/forms-and-validators#SQLFORM-factory I get everything except how to create and send records to the SQLFORM.factory. The document mentions a table named no_table, but how do I create this table without storing it in the database? Could someone provide a simple example? Also, will the SQLFORM.factory produce a grid/table or just single-record create/edit forms? Sorry for the elementary question, but I don't quite grasp this no-database concept. 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. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: What is proper requires= validator for foreign key?
Looks like a bug in smartgrid -- I'll submit a patch. Anthony On Friday, February 14, 2014 5:32:35 AM UTC-5, Mirek Zvolský wrote: Great. Thank you. (of course it would be much easier, if use of explicit requires= will cause nothing with implicit represent=) But in one detail it must be different as your version: If I try Field('parent_id', db.parent, requires=IS_IN_DB(db, db.parent.id), represent=lambda id, r: db.parent._format % db.parent(id) if id else '') this works well in appadmin, however it causes internal error in smartgrid: File C:\Python27\Lib\site-packages\web2py_2_8_2\web2py\gluon\sqlhtml.py, line 2764, in smartgrid user_signature=user_signature, **kwargs) File C:\Python27\Lib\site-packages\web2py_2_8_2\web2py\gluon\sqlhtml.py, line 2450, in grid value = field.represent(value, row) File C:\Python27\Lib\site-packages\web2py_2_8_2\web2py\gluon\sqlhtml.py, line 2708, in lambda field.represent = lambda id, r=None, referee=referee, rep=field.represent: A(callable(rep) and rep(id) or id, cid=request.cid, _href=url(args=['view', referee, id])) TypeError: lambda() takes exactly 2 arguments (1 given) This looks like proper solution: Field('parent_id', db.parent, requires=IS_IN_DB(db, db.parent.id), represent=lambda id: db.parent._format % db.parent(id) if id else '') So - your solution, but lambda with 1 parameter only. Thanks, Mirek Dne pátek, 14. února 2014 0:26:45 UTC+1 Anthony napsal(a): If you don't explicitly specify a validator for a reference field and the referenced table has a format attribute, then you get a default validator *and* a default represent attribute (the represent attribute is what is used for read-only displays). However, if you explicitly specify your own validator, then you no longer get the default represent attribute either, and so you must explicitly provider your own. You could do something like: Field('myfield', 'represent othertable', requires=..., represent=lambda id, r: db.othertable._format % db.othertable(id) if id else '') Anthony On Thursday, February 13, 2014 6:08:55 PM UTC-5, Mirek Zvolský wrote: As user of my application I don't want see any ID's at all - instead I want always see record content formatted from format=.. In smartgrid I am able to receive records instead of ID's only, if I run with default validator for foreign key (i.e. without requires=..) In such case (without requires=..) I see related records for readonly foreign keys (View) and for readwrite foreign keys (Edit). If I use requires=.. then for readonly foreign keys I see ID's and I have no idea, how to prevent it. If I need a foreign key, which should be None for some records, then I think it is necessary to use requires=IS_EMPTY_OR(IS_IN_DB(db, db.parent.id)) However this will display ID's instead of formatted records for readonly foreign keys. :((( How to do it proper? Can represent=.. help? Or? I try it with 2.8.2 version. Thanks for help ! (Note: I don't know, if answer to my question was same in older versions, or if it has changed in 2,8.2 with new constraint handling for SQLite.) -- 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] Large Number of Models in Web2py
You can use conditional models ou a model-less application, importing the ones you want to use. On Wed, Feb 12, 2014 at 2:07 PM, Juslin Guo juslin...@gmail.com wrote: Hi All, I new to Web2py, comtemplating shifting a 500 over tables PHP Application over... Do you all know where i can learn how to optimize Web2py for large number of models. Is there a way i could define them without having to repeat it, at the same time, not loading all the models. [Sorry if i make many posts, they are not showing up on my list somehow after posting] -- 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: [CLOSED] XMLHttpRequest cannot load https://www..... disallowed for cross-origin request ...
https://groups.google.com/forum/#!topic/web2py/0vqUFdr0cjg On Tue, Feb 11, 2014 at 7:52 AM, Umed zarrh...@gmail.com wrote: why didnt you specify what was a solution On Wednesday, December 18, 2013 4:05:43 PM UTC+5, weheh wrote: Looks like I got it working. The Apache config file wasn't complete, so once I found that issue, the CORS started to function properly. Thanks again for your responses. On Monday, December 16, 2013 11:16:05 PM UTC+8, Marin Pranjić wrote: Well, as I said, try your own jquery.ajax call. If it works, then CORS is enabled but component load is failing. If it doesn't work, then you didn't enable CORS correctly. You should also try $.ajax({crossDomain: true, ...}); JQuery should add it automatically but maybe it's not detecting it properly. On Mon, Dec 16, 2013 at 4:12 PM, weheh richard...@verizon.net wrote: @Marin: Thanks for your suggestion. I believe that that is precisely what is causing this issue. The original call is an HTTP call. It's followed by an HTTPS that results in the error message. But still no idea how to get the https call to go through. On Monday, December 16, 2013 10:45:45 PM UTC+8, Marin Pranjić wrote: @weheh can you try a custom jQuery.ajax cross domain call for testing/debugging? (just load something from HTTP to HTTPS) On Mon, Dec 16, 2013 at 2:38 PM, weheh richard...@verizon.net wrote: Hi Anthony, I added CORS stuff to my Apache httpd.conf as per this http://enable-cors.org/server_apache.html but I'm still getting the same error message. Any ideas about how to push through this? On Sunday, December 15, 2013 1:13:55 AM UTC+8, Anthony wrote: Is it in fact a cross-origin request, and have you set up CORS on the server? On Saturday, December 14, 2013 10:39:25 AM UTC-5, weheh wrote: I've got a dialog that I pop open and on it is a button that makes a web2py_component call. The button code looks like this, after it's gone through the XML() helper and jquery UI. button class=... onclick=if (confirm('Read?')) { web2py_component(quot;https://www.mysite.com/mycontroller/m yfunc.load?pc=YGYzlEh6amp;_signature=607e035a239d88bd3ab865 2814ceff2a9cab92b5quothttps://www.mysite.com/mycontroller/myfunc.load?pc=YGYzlEh6_signature=607e035a239d88bd3ab8652814ceff2a9cab92b5quot;, quot;target-divquot;); } role=button aria-disabled=false ... /button The button works fine when I launch it from my development machine: http://127.0.0.1:8000/myapp/... But, when I migrate the code to the server and execute there, I get an error. Firebug reports the following: XMLHttpRequest cannot load https://www.mysite.com/mycontr oller/myfunc.load?pc=YGYzlEh6_signature=https://www.yakitome.com/store/execute.load?pc=HcfnI_pVpid=7qty=1_signature=6c18eb4d880e19d463d85df3f9b02c97b5c8430e 607e035a239d88bd3ab8652814ceff2a9cab92b5. The request was redirected to 'https://www.mysite.com/user/login.load?_next=/ mycontroller/myfunc.load%https://www.yakitome.com/user/login.load?_next=/store/execute.load%3Fpc%3DHcfnI_pV%26pid%3D7%26qty%3D1 pc=YGYzlEh6https://www.yakitome.com/store/execute.load?pc=HcfnI_pVpid=7qty=1_signature=6c18eb4d880e19d463d85df3f9b02c97b5c8430e', which is disallowed for cross-origin requests that require preflight. Anybody have any idea how to deal with 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+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+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
Re: [web2py] Re: SQLFORM.factory without a database table
To insert/update record with .factory() you can do something like that : if form.process().accepted: if condition when update mode is not meat: id = db.underlying_table.insert(field1=form.vars.field1, ...) # You keep the id in cas you need it to insert some information in another table. elif condition when update form mode: db(db.underlying_table.record_id == request.vars.record_id).update(field1=form.vars.field1) And you can consider a dict comprehension so you don't actually have to write too much : id = db.lotns_sample.insert(**{str(var): form.vars[var] for var in form.vars}) # You can filter form.vars to make sure you insert only the proper fields into the proper table in case you have fields from differents tables in you .factory() form. :) You can also use the web2py function to filter the field : id = db.underlying_table.insert(**db.underlying_table._filter_fields(form.vars)) Richard On Fri, Feb 14, 2014 at 9:36 AM, Anthony abasta...@gmail.com wrote: SQLFORM.factory is for generating forms, not grids. The grid requires an actual database, though you can use a SQLite memory database: https://groups.google.com/d/msg/web2py/g4Mon6PvNFc/jytHfEnOXTIJ. Anthony On Friday, February 14, 2014 12:03:33 AM UTC-5, A36_Marty wrote: I would like to make a grid-like screen without an underlying database table. I've read the section in the book: http://www.web2py.com/books/default/chapter/29/07/forms- and-validators#SQLFORM-factory I get everything except how to create and send records to the SQLFORM.factory. The document mentions a table named no_table, but how do I create this table without storing it in the database? Could someone provide a simple example? Also, will the SQLFORM.factory produce a grid/table or just single-record create/edit forms? Sorry for the elementary question, but I don't quite grasp this no-database concept. 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. 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: Javascript runs locally but not when deployed
Everything on the page appears correctly except the widget which does not show at all. Nothing. No hint no error... On Feb 14, 2014, at 5:17 AM, Leonel Câmara leonelcam...@gmail.com wrote: What appears in the browser console when you see the deployed version? -- 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 a topic in the Google Groups web2py-users group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/OvDhm_6Ks5s/unsubscribe. To unsubscribe from this group and all its topics, 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: how to embed an image (or another solution) ?
thanks Michele, didn't know about that function On 13-02-14 17:18, Michele Comitini wrote: if you wish to embed images in html, web2py has a little know, but handy function: embed64(data, extension) in your case you coud simply use: img src={{=embed64(data=data, extension='image/png')}}/ without doing the base64 encoding yourself. Embedding is very efficient for small images, can be bad for large ones mic 2014-02-13 0:48 GMT+01:00 Anthony abasta...@gmail.com mailto:abasta...@gmail.com: If you use the built-in upload mechanism (i.e., an upload type field in a db table), then files uploaded via that method can be downloaded via response.download. The welcome app includes a /default/download function to do just that. Check out http://web2py.com/books/default/chapter/29/03/overview#An-image-blog. Anthony On Monday, February 10, 2014 4:43:32 PM UTC-5, aapaap wrote: hello, maybe I'm totally on the wrong path, but this is my script for the moment: - users can upload pictures. Uploads seems to be allowed only in myapp/uploads - I want to show these images, but images to be shown are only allowed in myapp/static - so I have to show images from myapp/uploads I have the following controller: def Show_Plaatje(): fh = open ( os.path.join ( 'applications', request.application, 'uploads', 'images', 'pic_53.png' ), 'rb') data = fh.read() fh.close() return data And in my view: img src={{=URL('Show_Plaatje')}}/ This doesn't seem to work, if I look at the resulting html-source, I see img src=/Knutselen_Voor_Kinderen/default/Show_Plaatje thanks, Stef -- 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 mailto:web2py%2bunsubscr...@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.
Re: [web2py] Escaping '%' percent character
Please show some code. A simple Python example: s = %d%% % 3 s '3%' Regards Martin 2014-02-12 18:28 GMT+01:00 Alejandro Garza Gracia alexgarz...@gmail.com: Hello, I've looked through the documentation and the questions asked but I haven't been able to escape the '%' percent character in a string. I've tried using '\%' and '%%' in a label string, but none has worked so far. I'd appreciate the help. -- 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] Re: how to embed an image (or another solution) ?
thanks Anthony, but I want to browse the image directory, so I don't want to store them in the database. cheers, Stef On 13-02-14 0:48, Anthony wrote: If you use the built-in upload mechanism (i.e., an upload type field in a db table), then files uploaded via that method can be downloaded via response.download. The welcome app includes a /default/download function to do just that. Check out http://web2py.com/books/default/chapter/29/03/overview#An-image-blog. Anthony On Monday, February 10, 2014 4:43:32 PM UTC-5, aapaap wrote: hello, maybe I'm totally on the wrong path, but this is my script for the moment: - users can upload pictures. Uploads seems to be allowed only in myapp/uploads - I want to show these images, but images to be shown are only allowed in myapp/static - so I have to show images from myapp/uploads I have the following controller: def Show_Plaatje(): fh = open ( os.path.join ( 'applications', request.application, 'uploads', 'images', 'pic_53.png' ), 'rb') data = fh.read() fh.close() return data And in my view: img src={{=URL('Show_Plaatje')}}/ This doesn't seem to work, if I look at the resulting html-source, I see img src=/Knutselen_Voor_Kinderen/default/Show_Plaatje thanks, Stef -- 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] why is auth.messages.... not working
hello, I want to redefine the texts of the login screen so in models/db.py I've : auth.messages.label_username='Gebruikersnaam' and my login controler: @auth.requires_login() def Inloggen(): redirect ( URL ( Show_Knutselen )) but I keep seeing : username thanks, Stef -- 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] Re: Javascript runs locally but not when deployed
There are no errors at all on the browser javascript console? -- 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] Re: why is auth.messages.... not working
Field labels have to be set before calling auth.define_tables. Is that the case here? Anthony On Friday, February 14, 2014 10:28:21 AM UTC-5, aapaap wrote: hello, I want to redefine the texts of the login screen so in models/db.py I've : auth.messages.label_username='Gebruikersnaam' and my login controler: @auth.requires_login() def Inloggen(): redirect ( URL ( Show_Knutselen )) but I keep seeing : username thanks, Stef -- 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: Javascript runs locally but not when deployed
Do you use http or https? What if you try another one? Marin On Fri, Feb 14, 2014 at 4:31 PM, Leonel Câmara leonelcam...@gmail.comwrote: There are no errors at all on the browser javascript console? -- 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] Re: Large Number of Models in Web2py
For conditional models, check out http://web2py.com/books/default/chapter/29/04/the-core#Workflow as well as response.models_to_run herehttp://web2py.com/books/default/chapter/29/04/the-core#response. You can also define models within a function or class in a module and import from the module. Anthony On Wednesday, February 12, 2014 11:07:01 AM UTC-5, Juslin Guo wrote: Hi All, I new to Web2py, comtemplating shifting a 500 over tables PHP Application over... Do you all know where i can learn how to optimize Web2py for large number of models. Is there a way i could define them without having to repeat it, at the same time, not loading all the models. [Sorry if i make many posts, they are not showing up on my list somehow after posting] -- 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] Re: A DAL mssql question. Connection with FreeTDS and Unicode data in a Unicode-only collation problem
Hi, After some frenzied trying with codecs and views, I finally got it to work. It's a ugly hack, but works for the moment In dal.py I added: (TDS_VERSION=8.0) cnxn = 'SERVER=%s;PORT=%s;DATABASE=%s;UID=%s;PWD=%s*;TDS_VERSION=8.0*;%s' \ % (host, port, db, user, password, urlargs) I could not make it work with url name-values in the connection string like ?DRIVER={FreeTDS};TDS_VERSION=8.0.. I guess that there is some config error by me in the FreeTDS config, or that there are some interesting stuff going on in the remote mssql database settings. Beq, I need to do the connection with db_codec='latin1' to not get the 'exceptions.UnicodeDecodeError' 'utf8' codec can't decode byte 0xe4... So, this is sorta solved with duct tape and good intentions :) -- Regards Falk On Friday, February 14, 2014 12:14:30 PM UTC+1, Falk wrote: Hi, I am for the first time messing with mssql dal adapter and are really struggling to get it working to a SQL2008 server.. I have gotten the connection with FreeTDS working When I connect in python with. conn = pyodbc.connect ('DSN=TS;UID=foo;PWD=bar') cursor = conn.cursor() cursor.execute(select * from INVENT where ID=3000) pyodbc.Cursor object at 0x14591b0 for row in cursor: ... print row Everything works.. But when connecting with dal: db = DAL('mssql://foo:bar@host/db?DRIVER={FreeTDS}', migrate_enabled=False) I get the.. class 'pyodbc.ProgrammingError' ('42000', '[42000] [FreeTDS][SQL Server]Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier. (4004) (SQLExecDirectW)') I tried to send ?DRIVER={FreeTDS}TDS_VERSION=8.0 with no result.. And I cannot do a DSN connection with DAL: db = DAL('mssql://DSN=TS;UID=foo;PWD=bar', migrate_enabled=False) Any ideas? Sorry if this has been up before and I missed totally.. But I am really stuck here :) -- Regards Falk -- 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] Re: Large Number of Models in Web2py
Also, if you set DAL(..., lazy_tables=True), that will defer much of the model definition code until the first time the table is accessed within a given request. Though with 500 models, I would probably not rely on lazy_tables exclusively. Anthony On Friday, February 14, 2014 10:38:31 AM UTC-5, Anthony wrote: For conditional models, check out http://web2py.com/books/default/chapter/29/04/the-core#Workflow as well as response.models_to_run herehttp://web2py.com/books/default/chapter/29/04/the-core#response. You can also define models within a function or class in a module and import from the module. Anthony On Wednesday, February 12, 2014 11:07:01 AM UTC-5, Juslin Guo wrote: Hi All, I new to Web2py, comtemplating shifting a 500 over tables PHP Application over... Do you all know where i can learn how to optimize Web2py for large number of models. Is there a way i could define them without having to repeat it, at the same time, not loading all the models. [Sorry if i make many posts, they are not showing up on my list somehow after posting] -- 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] Re: Javascript runs locally but not when deployed
Glenn from PythonAnywhere suggested on StackOverflow it may happen since page is https while widget is http... On Thursday, February 13, 2014 8:16:06 PM UTC-5, NeoToren wrote: I am trying to run a simple javascript that needs to fetch an external URL: script src=http://widgets.aapc.com/countdown/aapc_cdwidgetbox_220.js /script When locally - it works great. When deployed on PythonAnywhere - it doesn't work and it doesn't throw an error. I have tried wrap a div container around it - didn't help I have tried sanitize True or False it in an XML - didn't help There was some discussion on this group more than 2 years ago about this - but no conclusion To make it more interesting... another kind of javascript widget such as : div align=center style=margin: 15px 0px 0px;noscriptdiv align=center style=width: 140px; border: 1px solid rgb(204, 204, 204); text-align: center; color: rgb(249, 249, 255); font-weight: bold; font-size: 12px; background-color: rgb(4, 2, 68);a href= http://mycountdown.org/tag.php?tag=icd; style=text-decoration: none; font-size: inherit; color: rgb(249, 249, 255);Icd /a/div/noscriptscript type=text/javascript src= http://mycountdown.org/countdown.php?cp2_Hex=040244cp1_Hex=F9F9FFimg=1hbg=fwdt=170lab=1ocd=conferencetext1=ICD-10text2=MyCountdowngroup=Eventcountdown=conferencewidget_number=3010event_time=1412121600timezone=America/New_York;/script/div again - works locally but not when deployed. Now comes the rub If a widget is in the format of: iframe width=350 height=240 src=//w2.countingdownto.com/468181 frameborder=0/iframepa href=http://countingdownto.com;Countdown Clocks/a/p It works both locally AND on hosted machine / deployed It doesn't have any mention of JS...and it is wrapped in iframe still...interesting bug or I am doing something wrong ? -- 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] Getting the count of a rows object.
Hello. I'm having a strange problem. I'm trying to get the count of a rows object from a query. Here is the code: def album_show(): album = db.t_album(request.args(0)) songs = db(db.t_song.f_album_id_reference==album.id).select() count = songs.count() return locals() And here is the error I get: AttributeError: 'Rows' object has no attribute 'count' This makes no sense. The web2py manual clearly states that count() is a function of the rows object. So, what am I doing wrong? I'm not able to do song.isempty() either. -- 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] web2py on BeagleBone Black: optimizing ajax
Thanks Michelle and Niphlod for your good advice and explanations. With 4 users connected the load from the ajax call is now down to 40%. I can live with that for this application. FWIW, I decided to adopt a name prefix, no_DAL, to tell web2py not to evaluate the models. That makes my test at the top of db.py look like if request.action == None or (not request.action.startswith('no_DAL')): db = DAL('sqlite://storage.sqlite', lazy_tables=True) etc ... Saves me having to remember to add new functions to a list to be checked in db.py. On Thursday, February 13, 2014 4:52:24 PM UTC-5, Michele Comitini wrote: If the session is still valid requires_login does not read the db but session.auth so you should be fine, but I am not sure and in any case it could change in the future. You can remove it and check explicitly for session.auth.user is not None in the body of the ajax action avoid unauthenticated users. 2014-02-13 22:29 GMT+01:00 Michael Ellis michael...@gmail.comjavascript: : That looks worth trying. Will I need to also remove the login_required decorator from my ajax function? On Thursday, February 13, 2014 3:57:02 PM UTC-5, Michele Comitini wrote: db = None def setup_dal(): db = DAL(...) db.define_table(...) db.define_table(...) return db if request.controller!='the frequent ajax controller and request.action!='the frequent ajax action': db = setup_dal() -- 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 javascript:. 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] Re: Getting the count of a rows object.
On Friday, February 14, 2014 10:56:09 AM UTC-5, John Drake wrote: Hello. I'm having a strange problem. I'm trying to get the count of a rows object from a query. Here is the code: def album_show(): album = db.t_album(request.args(0)) songs = db(db.t_song.f_album_id_reference==album.id).select() count = songs.count() return locals() And here is the error I get: AttributeError: 'Rows' object has no attribute 'count' This makes no sense. The web2py manual clearly states that count() is a function of the rows object. No, it's a method of the Set class, not the Rows class. song_set = db(db.t_song.f_album_id_reference==album.id) count = song_set.count() songs = song_set.select() 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.
[web2py] Re: why is auth.messages.... not working
thanks Anthony, that did the trick, cheers, Stef On 14-02-14 16:30, Anthony wrote: Field labels have to be set before calling auth.define_tables. Is that the case here? Anthony On Friday, February 14, 2014 10:28:21 AM UTC-5, aapaap wrote: hello, I want to redefine the texts of the login screen so in models/db.py I've : auth.messages.label_username='Gebruikersnaam' and my login controler: @auth.requires_login() def Inloggen(): redirect ( URL ( Show_Knutselen )) but I keep seeing : username thanks, Stef -- 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] Re: Javascript runs locally but not when deployed
It could, as browser would block it. Just change: script src=http://widgets.aapc.com/countdown/aapc_cdwidgetbox_220.js /script Too: script src=//widgets.aapc.com/countdown/aapc_cdwidgetbox_220.jshttp://widgets.aapc.com/countdown/aapc_cdwidgetbox_220.js /script -- 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] ReCaptcha: type 'exceptions.SyntaxError' setting key 'login_catpcha' does not exist?
I want to add a captcha to my login form. Eventually I want this to be conditional based on how many login attemps have been made. However, my first step is to get it to show on the login form. In my default.py controller I have: def user(): function = request.args(0) if function == 'register': # ... elif function == 'login': #import ipdb; ipdb.set_trace() auth.settings.login_onfail = login_failed from gluon.tools import Recaptcha public_key = 'xyz' private_key = 'xyz' auth.settings.login_catpcha = Recaptcha(request, public_key,private_key ) form = auth.login() return dict(form=form) When I visit the page I get: type 'exceptions.SyntaxError' setting key 'login_catpcha' does not exist Commenting out offending line and the code works (albeit without a captcha) Any ideas on what's going wrong here? -- 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: REF: Join query help!
Apologies if I was not clear, when you do a cross join as in the example you get Rows now, and your code is as I meant it was just a typo, my need is to represent the record set into json object...it works well if there is no join, but when another table comes in the picture the way to access fields changes db.table.field So I want a rows to be represented as ['fieldname', 'field value], ['fieldname', 'field value], ['fieldname', 'field value], etc It's easy with a single table but when your record set has fields from another table it becomes a problem...this is my working iteration with single table but joint does not apply: def get_json(rs): json = [ for row in rd: json += { for key, value in (row.as_dict()).values: json += ',key, ':', value,' json += }, json += ] On 14 Feb 2014 15:11, Leonel Câmara leonelcam...@gmail.com wrote: I'm not sure I'm understanding exactly what you're trying to do. You say you want to display the value of the foreign key (which would be an integer) but in your code you seem to be only interested in the names. So this may or may not be what you want. I've found a bug here rs = db(db.owner.id==db.dog.owner).select(db.owner.name, db.owner.name) This should be: rs = db(db.owner.id==db.dog.owner).select(db.owner.name, db.dog.namehttp://db.owner.name/ ) Then you can do: for r in rs: print r.owner.name + ' : ' + r.dog.name -- 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] My db wont allow to enter decimals lower than 1.0
requires=IS_IN_SET(SIZES) is what I am using but fails to accept values under 1.0. So, 0.1 to 0.99 prompt the error On Thursday, February 13, 2014 6:48:01 PM UTC-8, Richard wrote: So why not use IS_FLOAT_IN_RANGE()?? requires = IS_FLOAT_IN_RANGE(0, 100, dot=., error_message='too small or too large!') Do you really need to specify the value in a dropbox dynamically? If so, requires=IS_IN_SET(SIZES) don't work? Richard On Thu, Feb 13, 2014 at 5:07 PM, greenpoise danel@gmail.comjavascript: wrote: A list of decimal values from 0.1 to 50.0 On Thursday, February 13, 2014 1:47:53 PM UTC-8, Richard wrote: What is SIZES? Is it a validators? Richard On Thu, Feb 13, 2014 at 4:24 PM, greenpoise danel@gmail.com wrote: could it be SIZES = [v*0.05 for v in range(0,int(50/0.05))] which I use to populate a select box? On Thursday, February 13, 2014 1:06:14 PM UTC-8, Richard wrote: Hmm, the message says Foreign Key constraint... Not decimal issue... Richard On Thu, Feb 13, 2014 at 4:02 PM, greenpoise danel@gmail.comwrote: For the first time I had to enter a value that was 0.25, for some reason, it comes back with this error class 'sqlite3.IntegrityError' FOREIGN KEY constraint failed I have the field as a float type. It works with any value except from 0.1 to 0.99. I tried decimal (10,3) still nothing. -- 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+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+un...@googlegroups.com javascript:. 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] Re: Multi player game with Web2py
you need implement websocket, in python/web2py you can use Gevent or tornado other more easy alternative is : firebase( https://www.firebase.com ) -- 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] A few suggestions for fixes to the web2py book
Meta-question: Should I rather post things like this to the issue tracker? 1. In http://web2py.com/books/default/chapter/32/07/forms-and-validators#Validators, the paragraph IS_IN_SET says: The elements of the set must always be strings unless this validator is preceded by IS_INT_IN_RANGE (which converts the value to int) or IS_FLOAT_IN_RANGE (which converts the value to float). For example: requires = [IS_INT_IN_RANGE(0, 8), IS_IN_SET([2, 3, 5, 7], error_message='must be prime and less than 10')] This doesn't work for me in this case: requires = [ IS_INT_IN_RANGE(0, 4), IS_IN_SET([ (0, T(Option 1)), (1, T(Option 2)), (2, T(Option 3)), (3, T(Option 4)), ] ), ], I get a ticket: type 'exceptions.SyntaxError' widget cannot determine options of piece.piece_type and it seems web2py tries to derive the options from the first validator: if hasattr(requires[0], 'options') Changing the order in my code indeed works: requires = [ IS_IN_SET([ (0, T(Option 1)), (1, T(Option 2)), (2, T(Option 3)), (3, T(Option 4)), ] ), IS_INT_IN_RANGE(0, 4), ], So should the book perhaps say: The elements of the set must always be strings unless this validator is *followed* by IS_INT_IN_RANGE (which converts the value to int) or IS_FLOAT_IN_RANGE (which converts the value to float). ? 2. In http://www.web2py.com/book/default/chapter/10#JSONRPC-and-Pyjamas this part of the code example script language=javascript src={{=URL('static','output/pygwt.js')}} /script for more recent versions of pyjs should be changed to script language=javascript src={{=URL('static','output/bootstrap.js')}} /script However, JSONRPC in pyjamas 0.8.x is broken (due to this problem: http://osdir.com/ml/python-pyjamas-devel/2012-04/msg00246.html), and it doesn't look like it'd be fixed any time soon (or ever). I'd suggest to put a note on top of this chapter, to discourage people from trying it until pyjs development is continued, and there's a newer version than 0.8.1a. -- 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] Re: web2py secrets video part 2???
link : https://groups.google.com/forum/#!topic/web2py/Ow-x1D4__q0 -- 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] Re: A DAL mssql question. Connection with FreeTDS and Unicode data in a Unicode-only collation problem
I'm planning to include another tds pure python driver that **seems** to avoid all this freetds ugliness, but the adapter library is a tad bit experimental. keeps fingers crossed a little bit more. On Friday, February 14, 2014 4:38:32 PM UTC+1, Falk wrote: Hi, After some frenzied trying with codecs and views, I finally got it to work. It's a ugly hack, but works for the moment In dal.py I added: (TDS_VERSION=8.0) cnxn = 'SERVER=%s;PORT=%s;DATABASE=%s;UID=%s;PWD=%s*;TDS_VERSION=8.0*;%s' \ % (host, port, db, user, password, urlargs) I could not make it work with url name-values in the connection string like ?DRIVER={FreeTDS};TDS_VERSION=8.0.. I guess that there is some config error by me in the FreeTDS config, or that there are some interesting stuff going on in the remote mssql database settings. Beq, I need to do the connection with db_codec='latin1' to not get the 'exceptions.UnicodeDecodeError' 'utf8' codec can't decode byte 0xe4... So, this is sorta solved with duct tape and good intentions :) -- Regards Falk -- 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] Re: manage scheduler result with smartgrid
strange. I'm not a fan of smartgrid but could you try to include in fields also scheduler_task.id ? On Friday, February 14, 2014 1:33:36 PM UTC+1, Manuele wrote: Il 14/02/14 12:13, Manuele Pesenti ha scritto: Hi! does anybody can tell me what's wrong in this controller? Ok.. thanks to Mirek Zvolský I found that the main problem was linked to that I set up my scheduler db with lazy_tables=True. Now (changed that option to False) for every record the link to children runs is visible but the resulting grid says: Query Not Supported: no such column: scheduler_task.id What's the problem now? Thanks a lot Cheers Manuele -- 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] Re: Learning Management System survey
Any plans to wrap it up and sell it? Would love to take it to market. -- 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] del db.my_table[id] shortcut not working any more after enabling record versioning
I have a controller function for record deletion which worked reliably for quite some time. Today I've added added auth.enable_record_versioning(db) to my model file for the first time (my tables had auth.signature fields already). Since then, I get type 'exceptions.SyntaxError' No such record: 230 tickets whenever I call del db.piece[id] However, db(db.piece.id == id).delete() works fine. (And yes, the records *do* exist.) I've found this thread here https://groups.google.com/forum/#!topic/web2py/rNv8oARIttI where someone appears to have a similar problem. (There's no conclusion though.) -- 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] Is there a way to use parameters on --run (-R) ?
Hi Folks, Just a simple test... an external script: $: cat tito.py import sys print sys.argv Then running with web2py: $ python web2py.py -S welcome -M -R tito.py param1 param2 web2py Web Framework Created by Massimo Di Pierro, Copyright 2007-2014 Version 2.8.2-stable+timestamp.2013.11.28.13.54.07 Database drivers available: SQLite(sqlite3), MySQL(pymysql), PostgreSQL(pg8000), MSSQL(pyodbc), DB2(pyodbc), Teradata(pyodbc), Ingres(pyodbc), IMAP(imaplib) ['tito.py'] *How could I grab the parameters that I need for my script from shell?* Regards, Tito -- Linux User #387870 . _/_õ|__| ..º[ .-.___.-._| . . . . .__( o)__( o).:___ -- 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] Re: Cannot access virtual fields within a IS_IN_DB format function?
Unfortunately, row.translator.custom_name doesn't work either: type 'exceptions.AttributeError' 'Row' object has no attribute 'translator' -- 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] Re: Javascript runs locally but not when deployed
Tried it. Does work locally - does NOT work when deployed... On Friday, February 14, 2014 12:21:13 PM UTC-5, Leonel Câmara wrote: It could, as browser would block it. Just change: script src=http://widgets.aapc.com/countdown/aapc_cdwidgetbox_220.js /script To: script src=//widgets.aapc.com/countdown/aapc_cdwidgetbox_220.jshttp://widgets.aapc.com/countdown/aapc_cdwidgetbox_220.js /script -- 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] Re: Escaping '%' percent character
If you need it for running a SQL query using the LIKE operator...the following worked for me: sqlstring = SELECT * FROM tableX WHERE fieldY LIKE '%+something[0]+%' On Wednesday, February 12, 2014 12:28:35 PM UTC-5, Alejandro Garza Gracia wrote: Hello, I've looked through the documentation and the questions asked but I haven't been able to escape the '%' percent character in a string. I've tried using '\%' and '%%' in a label string, but none has worked so far. I'd appreciate the help. -- 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] Serving images uploaded with Field('file', 'upload') as static assets?
I'm building my first public facing app with web2py using the basic image blog example from the docs but I'm concerned about performance. I'd like to have an upload form so I can post images to a blog with basic captions. I don't need any security for viewing so I'd like to have them served directly by the web server statically. Can I do this using web2py's built-in upload functionality? Right now my app is still very close to the example: db.py: db = DAL(sqlite://storage.sqlite) db.define_table('post', Field('title', unique=True), Field('file', 'upload'), Field('caption', 'text'), format = '%(title)s') db.define_table('comment', Field('post_id', 'reference post'), Field('author'), Field('email'), Field('body', 'text')) db.post.title.requires = IS_NOT_IN_DB(db, db.post.title) db.comment.post_id.requires = IS_IN_DB(db, db.post.id, '%(title)s') db.comment.author.requires = IS_NOT_EMPTY() db.comment.email.requires = IS_EMAIL() db.comment.body.requires = IS_NOT_EMPTY() db.comment.post_id.writable = db.comment.post_id.readable = False -- 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] web2py API document, and method return values
Hello, I was looking at this specific method update_record, and found it to be useful. I would like to know what its return values are based on whether the update succeeded or failed. I realized that on success, the updated Row is returned. Not sure what happens if there is any sort of failure. The API document that am using is: http://127.0.0.1:8000/examples/static/epydoc ... the one that is accessible once I start a local instance of web2py. I see that the update_record is handled by Record_Updater(), which performs a colset.update()... and so on. Is there an easier way to figure out the return value for these functions? Thanks, Kiran -- Kiran Subbaraman http://subbaraman.wordpress.com/about/ -- 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] Setting DAL less strict from a model
I just tested it with Michele's proposed code: Created a 0_db.py with the following content: real_DAL = DAL def DAL(*args, **kwargs): kwargs['check_reserved'] = False kwargs['entity_quoting'] = True return real_DAL(*args, **kwargs) Cool: the https://github.com/acidjunk/web2py-pages is now working without touching your web2py code. A .w2p plugin will be released soon. Kind regards, Rene On Sunday, February 9, 2014 1:55:46 AM UTC+1, Rene Dohmen wrote: Hi, Just checked with trunk Version 2.8.2-stable+timestamp.2014.01.30.08.43.19 and entity_quoting=True in the DAL connection string; Then it works. (but I still have to remove the check_reserved from the DB connection URI) I really would like to build/release a .w2p/plugin that doesn't overwrite your existing db.py: or give a cryptic error on first time usage. I hope it will be a default value in the next release or that there is some simple way to set it with a function call in the future: entity_quoting and check_reserved seem to be a DAL connection argument only. Kind Regards Rene On Thursday, February 6, 2014 7:03:29 PM UTC+1, Rene Dohmen wrote: Hi Mic, I will test it later on. But i'm not sure how this would solve the problem; I still need to remove the check_reserved from the DAL connection string. The goal is to NOT change anything in db.py; so the page module can be used as a normal w2p plugin. Or are you saying check_reserved will be removed in the future; e.g. it wil be replaced by entity_quoting=True by default? Kind regards Rene On Tuesday, February 4, 2014 10:01:04 PM UTC+1, Michele Comitini wrote: Hi Rene, try testing with trunk, remove check_reserved and add the following to DAL parameters: DAL(., entity_quoting=True) after that you should have no conflict with reserved SQL words. You should be able to use any name, e.g. do things like define_table('table', Field('select'), Field('update')) Let us know if that works. mic 2014-02-04 Rene Dohmen re...@formatics.nl: Hi Web2py-users, I have developed a CMS kind of system based on web2py. https://github.com/acidjunk/web2py-pages I actually want to provide a release as a w2p file on a regular basis, so it can be used more easily. But I'm running into a problem if I don't overwrite any core web2py app files. https://github.com/acidjunk/web2py-pages/blob/master/README.md When I started the development (web2py 1.97.2) I made some DB naming choices that gave problems later on, when using strict(er) mode in DAL. The key problem is that we choose 'page' for our main table containing the pages. Obviously a lot of code in the page controller is using 'page' also for adding, editing and sorting pages; and I also have some projects in production that use it already. So a rename is not that straight forward or easy... I did investigate the web2py docs to see if I could relax the strict mode from a model that would be included after db.py; but that doesn't seem to be possible. Any help is appreciated. Kind Regards Rene -- 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.
[web2py] Re: New to Web2Py: Large Model
You could use extract_mysql_models.py (in the web2py/scripts folder) On Wednesday, February 12, 2014 4:58:29 PM UTC+1, Juslin Guo wrote: Hi, I have an application in PHP with 500 over tables, what's the best way to managed them in Web2Py, without repeating model definitions nor loading them all. -- 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] New to Web2Py: Large Model
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Em 12-02-2014 15:58, Juslin Guo escreveu: Hi, I have an application in PHP with 500 over tables, what's the best way to managed them in Web2Py, without repeating model definitions nor loading them all. Hi, You can follow this approach: http://www.web2pyslices.com/slice/show/1479/model-less-apps-using-data-models-and-modules-in-web2py Basicly, you move table defenitions from models to modules, only defining tables as needed. - -- Com os melhores cumprimentos, Carlos Correia = MEMÓRIA PERSISTENTE Tel.: 219 291 591 - GSM: 917 157 146 / 967 511 762 e-mail: ge...@memoriapersistente.pt - URL: http://www.memoriapersistente.pt Jabber: m...@jabber.org GnuPG: wwwkeys.eu.pgp.net URL Suporte: https://t5.m16e.com/gps -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.14 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iEYEARECAAYFAlL+zxMACgkQ90uzwjA1SJUPhQCdHJpv8zAT9Op4DPj2uoREswi4 WdAAnivDivp9nuiBhO5Ve5rbp+Rd9Dlr =aYSC -END PGP SIGNATURE- -- 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] Re: Custom Regisration Form
Can you show us the controller? On Tuesday, 11 February 2014 18:46:15 UTC-6, DMK wrote: I extended the auth_user table with additional profile fields (e.g. phone number, alert preference, etc.) and I'm trying to customize the registration form so that it shows only the desired fields (accomplished per documentation) and display the desired fields in a custom manner, including adding a drop down which is based on content which isn't in the database. I'm struggling to figure out a way to control the form's display and processing - I'm either not understanding the documentation and other instructions I found or trying to do something odd. - I'm exposing the user() function at /{app}/login rather than the standard location. - I tried to place a def register() function in the /{app}/long controller but that doesn't seem to have any effect. - I can display the custom registration form using an if statement in the login/user view, but I'm not sure how to process it afterwards when it submits (nor where it submits to). Any help/pointers would be much appreciated. -- 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] Re: A Select Tag Helper Code
def select_tag(name, options): return SELECT(*[OPTION(key,_value=options[key]) for key in options],_name=name) On Tuesday, 11 February 2014 18:51:47 UTC-6, DMK wrote: I wasn't able to find a simple function that would help generate a SELECT tag given a set of options (I did see the OPTION function) so created a simple one and thought it'd be useful to share. I'm new to Python so this may not be very elegant, but it works. The function takes the tag's name and a dictionary of options as input, returns an XML formatted completed select tag. def select_tag(name, options): select_tag='select name='+name+'' for key in options.keys(): select_tag=select_tag+'option value='+options[key]+''+key+ '/option\n' select_tag=select_tag+'/select' return XML(select_tag) -- 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] Re: Can the SQLFORM.grid show column headers even with no records?
No. but open a ticket, perhaps this should be an option. On Tuesday, 11 February 2014 21:34:02 UTC-6, A36_Marty wrote: If I open a grid with records and delete until none are left, the grid column headers are shown. However, if the grid is loaded with no matching records, no column headers are shown. Is there setting to make the columns show all the time? -- 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] Re: Treat Datetime field as Date?
If it does not support it, I cannot think of a better way. On Wednesday, 12 February 2014 11:31:06 UTC-6, Tim Nyborg wrote: I'm connecting to an MSSQL 2005 db, which only has the Datetime format (Date was added in 2008). Is there a standard way to treat a Datetime as a Date in web2py for forms and formatting? I've done the following, and it works thus far, but it seems a bit hackish. Field('BirthDte', 'datetime', widget=SQLFORM.widgets.date.widget, requires=IS_DATE(), represent = lambda value, row: value.strftime(%#d %b %Y)) -- 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] Re: auto.py converting mysql schema to web2py models?
https://github.com/web2py/web2py/blob/master/scripts/extract_mysql_models.py On Thursday, 13 February 2014 07:11:36 UTC-6, Osman Kazdal wrote: Hello, I searched in group for a tool to convert mysql schema to web2py models. There is talk about an auto.py script but link to that script seems broken. Is there another way to do this now or is it even possible? Osman Kazdal -- 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] Re: iterating form.custom.widget and set _class attribute
form.custom.widget[field] cannot be a str. Are you sure? On Thursday, 13 February 2014 07:19:39 UTC-6, Kök Eksi Bir wrote: As explained in the book I can modify a fields class by setting _class as follows: form.custom.widget.some_field['_class']=input-block-level however when I iterate form.cutom.widget as in following snippet: {{for field in form.custom.widget:}} {{=SPAN(form.custom.label[field])}} {{form.custom.widget[field][_class] = some-sample-class}} {{=form.custom.widget[field]}} {{pass}} TypeError is raised when I try to set _class, since form.custom.widget[field] is a str instance. How can I overcome this, do you have any suggestions? -- 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] queries from tables
hi, i wannna create report and have the queries from tables, the result is not expected. e.g. def product(): from_date = request.vars.from_date to_date = request.vars.to_date query_purchase = (db.purchase_header.purchase_date = from_date) (db.purchase_header.purchase_date = to_date) query_sale = (db.sale_header.sale_date = from_date) (db.sale_header.sale_date = to_date) purchase_result = 0 sale_result = 0 for row_purchase_header in db(query_purchase).select(): sum_quantity_purchase = db.purchase_detail.quantity.sum() query_purchase_detail = (row_purchase_header.id == db.purchase_detail.purchase_no) (db.purchase_detail.product == db.product.id) purchase_result = db(query_purchase_detail).select(sum_quantity_purchase).first()[sum_quantity_purchase] if db(query_purchase).select() else 0 # for row_purchase_detail in db(db.purchase_detail.purchase_no.belongs(query_purchase) ).select(): # for row_purchase_header in db(query_purchase).select(): # sum_quantity_purchase = db.purchase_detail.quantity.sum() # # query_purchase_detail = db.product.id.belongs(row_purchase_detail.product == db.product.id) # query_purchase_detail = db.product.id.belongs((row_purchase_header.id == db.purchase_detail.purchase_no) (db.purchase_detail.product == db.product.id) ) # query_purchase_detail = (row_purchase_header.id == db.purchase_detail.purchase_no) (db.purchase_detail.product == db.product.id) # # purchase_result = db(query_purchase_detail)._select(sum_quantity_purchase).first()[sum_quantity_purchase] if db(query_purchase).select() else 0 for row_sale_header in db(query_sale).select(): sum_quantity_sale = db.sale_detail.quantity.sum() query_sale_detail = (row_sale_header.id == db.sale_detail.sale_no) (db.sale_detail.product == db.product.id) sale_result = db(query_sale_detail).select(sum_quantity_sale).first()[sum_quantity_sale] if db(query_sale).select() else 0 product_links=[dict(header=T('In'), body=lambda row: DIV(purchase_result) ), dict(header=T('Out'), body=lambda row: DIV(sale_result) ), dict(header=T('Begining'), body=lambda row: DIV(row.quantity + sale_result - purchase_result) ) ] #query = (db.product.id == row_purchase_detail.product) (db.product.id == row_sale_detail.product) #query = ((db.purchase_header.purchase_date = from_date) (db.purchase_header.purchase_date = to_date) (db.sale_header.sale_date = from_date) (db.sale_header.sale_date = to_date) (db.purchase_header.id == db.purchase_detail.purchase_no) (db.sale_header.id == db.sale_detail.sale_no) (db.purchase_detail.product == db.product.id) (db.sale_detail.product == db.product.id) ) grid = SQLFORM.grid(db.product) return locals() the result is the value is all same for In (taken from purchase detail for all product) and out (taken from sale detail for all product) and the begining value calculation is wrong. i know i have the mistake on above code but can not figure it where. any hints how to achieve it? thanks and best regards, stifan -- 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] Re: New to Web2Py: Large Model
I have an application in PHP with 500 over tables did you already create the web2py models for your current database? i mean using the extract script. e.g. web2py\scripts\extract_mysql_models.py without repeating model definitions pardon me, don't know what do you mean about this, if you mean the repeating model definitions is migrate, i think you can achieve it after you extract the database into models (above steps is done) and set in the dal : migrate = False, fake_migrate_all = False nor loading them all. for this, i think the answer is same like the others suggestion, is to use the modelless (modules) or response.models_to_run(), your choice. if you follow the above steps (extract, and set the migrate value), i think you only can use response.models_to_run(), because in modelless (modules) you must redefine the tables again in modules. best regards, stifan -- 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] Re: logout error
You should have both: @auth.requires_login() @auth.requires_permission(request.function) the latter implies the former On Friday, 14 February 2014 04:27:31 UTC-6, ajith c t wrote: Hi I updated web2py 2.5 to 2.8, now the login and logout seems to work but with a problem, the login page redirects to errorpage and logout correctly redirects to login page. But my logs are: *** 2014-02-14 10:18:45,224 - DEBUG - web2py.scheduler.ip-10-0-0-175#25487 - defining tables (migrate=True) 2014-02-14 10:18:45,274 - DEBUG - app - login page 2014-02-14 10:18:45,315 - ERROR - app - Traceback (most recent call last): File /srv/trustvouch-fe/applications/app/controllers/default.py, line 25, in login form = auth.login() File /srv/trustvouch-fe/gluon/tools.py, line 2393, in login redirect(next, client_side=settings.client_side) File /srv/trustvouch-fe/gluon/http.py, line 147, in redirect Location=loc) HTTP: 303 SEE OTHER 2014-02-14 10:18:45,515 - DEBUG - web2py.scheduler.ip-10-0-0-175#25487 - defining tables (migrate=True) 2014-02-14 10:19:08,879 - DEBUG - web2py.scheduler.ip-10-0-0-175#25487 - defining tables (migrate=True) 2014-02-14 10:19:08,932 - DEBUG - app - logout 2014-02-14 10:19:08,934 - ERROR - app - Traceback (most recent call last): File /srv/trustvouch-fe/applications/app/controllers/default.py, line 38, in logout auth.logout(next=URL(r=request, c='default', f='index')) File /srv/trustvouch-fe/gluon/tools.py, line 2434, in logout redirect(next) File /srv/trustvouch-fe/gluon/http.py, line 147, in redirect Location=loc) HTTP: 303 SEE OTHER both of them shows http 303 error, seems both have tools.py error, what am I doing wrong. Can anyone help me here, because I need to push live data to my app very soon -- 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] Re: ReCaptcha: type 'exceptions.SyntaxError' setting key 'login_catpcha' does not exist?
auth.settings.login_catpcha = Recaptcha(request, public_key, private_key) should be auth.settings.login_captcha = Recaptcha(request, public_key, private_key) On Friday, 14 February 2014 11:31:57 UTC-6, User wrote: I want to add a captcha to my login form. Eventually I want this to be conditional based on how many login attemps have been made. However, my first step is to get it to show on the login form. In my default.py controller I have: def user(): function = request.args(0) if function == 'register': # ... elif function == 'login': #import ipdb; ipdb.set_trace() auth.settings.login_onfail = login_failed from gluon.tools import Recaptcha public_key = 'xyz' private_key = 'xyz' auth.settings.login_catpcha = Recaptcha(request, public_key,private_key ) form = auth.login() return dict(form=form) When I visit the page I get: type 'exceptions.SyntaxError' setting key 'login_catpcha' does not exist Commenting out offending line and the code works (albeit without a captcha) Any ideas on what's going wrong here? -- 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] Re: del db.my_table[id] shortcut not working any more after enabling record versioning
del table[id] is more picky. Raises an exception if id is not int and if the record does not exist. On Friday, 14 February 2014 16:23:04 UTC-6, Horst Horst wrote: I have a controller function for record deletion which worked reliably for quite some time. Today I've added added auth.enable_record_versioning(db) to my model file for the first time (my tables had auth.signature fields already). Since then, I get type 'exceptions.SyntaxError' No such record: 230 tickets whenever I call del db.piece[id] However, db(db.piece.id == id).delete() works fine. (And yes, the records *do* exist.) I've found this thread here https://groups.google.com/forum/#!topic/web2py/rNv8oARIttI where someone appears to have a similar problem. (There's no conclusion though.) -- 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] Re: Is there a way to use parameters on --run (-R) ?
python web2py.py -S welcome -M -R tito.py -A param1 param2 On Friday, 14 February 2014 16:35:15 UTC-6, Tito Garrido wrote: Hi Folks, Just a simple test... an external script: $: cat tito.py import sys print sys.argv Then running with web2py: $ python web2py.py -S welcome -M -R tito.py param1 param2 web2py Web Framework Created by Massimo Di Pierro, Copyright 2007-2014 Version 2.8.2-stable+timestamp.2013.11.28.13.54.07 Database drivers available: SQLite(sqlite3), MySQL(pymysql), PostgreSQL(pg8000), MSSQL(pyodbc), DB2(pyodbc), Teradata(pyodbc), Ingres(pyodbc), IMAP(imaplib) ['tito.py'] *How could I grab the parameters that I need for my script from shell?* Regards, Tito -- Linux User #387870 . _/_õ|__| ..º[ .-.___.-._| . . . . .__( o)__( o).:___ -- 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.