jackson.read | 29 Jun 22:16 2015

How do I get rid design request response session db tables db stats buttons in a sqlform

This  what I have. I want to get rid of the row of buttons at the bottom of the form that says 'design request response session db tables db stats'



View

{{extend 'layout.html'}}
<h2>Input form</h2>
{{=form}}
<h2>Submitted variables</h2>
{{=BEAUTIFY(request.vars)}}
<h2>Accepted variables</h2>
{{=BEAUTIFY(form.vars)}}
<h2>Errors in form</h2>
{{=BEAUTIFY(form.errors)}}


Controller

def display_common_params():
    db3.common_parameters.id.readable=False # Since we do not want to expose the id field on the grid

    form = SQLFORM(db3.common_parameters, buttons = [TAG.button('Back',_type="button",
                                                                _onClick = "parent.location='%s' " % URL('display_all_analysis_stations')),
                                                     TAG.button('Save',_type="submit")])

    if form.accepts(request,session):
        response.flash = 'form accepted'
    elif form.errors:
        response.flash = 'form has errors'
    else:
        response.flash = 'please fill the form'

    return dict(form=form)

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Chaitu P | 30 Jun 04:56 2015
Picon

Dynamic upload folder path

Hello all,
I have a form for student name, email and upload. For each student I want to create a seperate folder and save his upload dynamically.
Can anyone let me know how can I do this.

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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Chaitu P | 30 Jun 01:31 2015
Picon

multifile uploading

In my application, I want the user to upload as may files as he wants.
I have seen few of the websites. But those seem to be more difficult. Is there a better way to do this.


--
Chaitanya Pochampally

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Antonio Salazar | 30 Jun 02:52 2015
Picon

Copying row fields to a structure in memory

I have a task periodically generating a handful of records which may or may not be already in a versioned table. To minimize versioning logs, I want to generate the records in-memory and only update the changed ones.

Is there a simple way to copy a row structure to a dictionary or list, for example?

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Auden RovelleQuartz | 29 Jun 23:48 2015
Picon

IOError: [Errno 21] Is a directory:

does anyone know what this means?

{
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2015
Version 2.11.2-stable+timestamp.2015.05.30.16.33.24
Database drivers available: sqlite3, psycopg2, pg8000, pymysql, imaplib
Traceback (most recent call last):
  File "/home/www-data/web2py/gluon/shell.py", line 262, in run
    execfile(startfile, _env)
IOError: [Errno 21] Is a directory: 'applications/omniavx_joe'
}

isn't it supposed to be a directory?

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Alex Glaros | 29 Jun 21:56 2015
Picon

How to make role inheritable?

Example: Role is "Citizen" (In db.auth_group)

Object (as in Subject/Predicate/Object) of role is "City of New Orleans" (Added extra field in db.auth_group "superObject" for this object role.)

In db.auth_membership, user_id is "Bob" with FK to db.auth_group.role. Result: "Bob is citizen of New Orleans."

So far so good, all New Orleans citizens are handled by being added to db.auth_membership

But Bob is also a citizen of Louisiana. And also a citizen of U.S.

How to have Louisiana and U.S. automatically inherit attributes so that system knows Bob is also citizen at state and federal level?

Goal is to have function in controller able to answer question "Is Bob a US citizen?" without having to redundantly place Bob in additional role groups (db.auth_group: state citizen role, db.auth_group: federal citizen role).

thanks,

Alex Glaros

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Robert Porter | 29 Jun 19:38 2015
Picon

Only one table fails to create in MySQL... and there's nothing special about it.

I got everything working fine at home on my Ubuntu 14.04 server.  Then I did a git push to pythonanywhere.com.  Web2py created all my new tables except for one, and it continues to fail to create this table.  Tech support at pythonanywhere can't find the problem.

Here's my table that is having problems:

db.define_table('restaurants',
Field('place_id', 'text', required=True),
Field('place_name', 'text'),
Field('rest_lat', 'text'),
Field('rest_lng', 'text'))

I can take off the "required=True" but that doesn't help.  Here's the error chain:

<class '_mysql_exceptions.ProgrammingError'> (1146, "Table 'trytha$test.restaurants' doesn't exist")

Traceback (most recent call last):
  File "/var/www/sites/trytha/gluon/restricted.py", line 227, in restricted
    exec ccode in environment
  File "/var/www/sites/trytha/applications/trytha/models/db.py", line 112, in <module>
    Field('rest_lng', 'text'))
  File "/var/www/sites/trytha/gluon/packages/dal/pydal/base.py", line 817, in define_table
    table = self.lazy_define_table(tablename,*fields,**args)
  File "/var/www/sites/trytha/gluon/packages/dal/pydal/base.py", line 856, in lazy_define_table
    polymodel=polymodel)
  File "/var/www/sites/trytha/gluon/packages/dal/pydal/adapters/base.py", line 491, in create_table
    fake_migrate=fake_migrate
  File "/var/www/sites/trytha/gluon/packages/dal/pydal/adapters/base.py", line 604, in migrate_table
    self.execute(sub_query)
  File "/var/www/sites/trytha/gluon/packages/dal/pydal/adapters/base.py", line 1326, in execute
    return self.log_execute(*a, **b)
  File "/var/www/sites/trytha/gluon/packages/dal/pydal/adapters/base.py", line 1320, in log_execute
    ret = self.cursor.execute(command, *a[1:], **b)
  File "/usr/local/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 205, in execute
    self.errorhandler(self, exc, value)
  File "/usr/local/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
ProgrammingError: (1146, "Table 'trytha$test.restaurants' doesn't exist")


Since this works at home, it's obviously a pythonanywhere problem, but they requested I ask you guys for help troubleshooting it.

So here's my question:  Anyone know a good web hosting company for Web2py?  I really just need vanilla Ubuntu on a server.  Alternatively, if you can figure out the error, that might work too, but given pythonanywhere's weird MySQL requirement of having your username as part of your DB name caused an hour of annoyance when I set everything up the first time, I'm not keen on giving them many more chances.

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
St. Pirsch | 29 Jun 18:04 2015
Picon

Help/documentation on auth.wiki

Hi, 
I'am trying to get familiar with the auth.wiki, which I think is great to use for simple cms tasks. 
The documentation in the book is a bit short, a least from the perspective of a novice. I couldn't find much more information on auth.wiki here nor elsewhere. Maybe it would help other users too,  to sum up some questions and best practice somewhere.
In detail, I have two questions:
1. The editor offers a dropown for templates to choose from.
- How can this field be populated, howhave the templates to be designed?
2. I am trying to LOAD wiki pages in other web2py-views. The wiki-pages take their styles with them, i.e. as defined in the standard wiki view. How to avoid that without removing the style from the wiki itself?
Thanks, Stephan

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Massimo Di Pierro | 29 Jun 17:43 2015
Picon

bounty for window users

I offer $50 is you can do this in a couple of days:

In the web2py admin interface there is a "pack custom page" which redirects to
http://127.0.0.1:8000/admin/default/pack_custom/<yourapp>
and has a button "download w2p".

I would like one addition button there that says "download as exe" which will do the following:
- download the latest web2py_win.zip
- unzip it (using the python API)
- copy the web2pp app in question (selected files/folders) under the unzipped web2py/applications/
- create a file routes.py under the unzipped web2py/ folder which contains
routers = dict( BASE=dict(default_application='....') )  
  where ... is the name of the app in question
- zips the unzip folder again with name web2py.app.<name>.exe and downloads it

The zip/unzip should be done in RAM using the python zip module. 
This is for those uses who develop on windows for window and expect the end users to run web2py locally with a single app. And yes, they exist. It would make their life easier and avoid zipping/unzipping mistakes and information leakage.

This should not take more than 10-20 lines in the admin app. It is also a good exercise.
I will only pay the first to deliver (if it works well) so post your solution in the form of a pull request on github.

Massimo

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Sai Harsh Tondomker | 29 Jun 14:33 2015
Picon

Error in database giving 'NoneType' object has no attribute 'first_name'.

db.define_table("Questions",
  Field('quesno', unique=True),
  Field('question', 'text'),
  Field('optionA', 'string'),
  Field('optionB', 'string'),
  Field('optionC', 'string'),
  Field('optionD', 'string'),
  Field('answer', 'string'),
  Field('extra1','string'),
  Field('extra2','string'))

db.define_table("secret",
  Field('name','string'),
  Field('quesstatus', 'integer',default=1),
  Field('score', 'integer',default=0),
  Field('score1', 'integer',default=0),
  Field('Test', 'integer',default=1),
  Field('correct', 'integer',default=0),
  Field('wrong', 'integer',default=0),
  Field('unanswered', 'integer',default=0),
  Field('Level1Hint','integer'))

auth_count = db(db.auth_user.id >= 0).count()
secret_count = db(db.secret.id >= 0).count()
if(auth_count > secret_count):
    db.secret.insert(name = auth.user.first_name)
    db(db.secret.name == auth.user.first_name).update(quesstatus= 1)
    db(db.secret.name == auth.user.first_name).update(score = 0)
    db(db.secret.name == auth.user.first_name).update(Test = 1)
    db(db.secret.name == auth.user.first_name).update(correct = 0)
    db(db.secret.name == auth.user.first_name).update(wrong = 0)
    db(db.secret.name == auth.user.first_name).update(unanswered = 0)
    db(db.secret.name == auth.user.first_name).update(Level1Hint = 0)
elif(auth_count == secret_count):
    db.secret(name = auth.user.first_name).update(quesstatus= 1)
    db.secret(name = auth.user.first_name).update(score1 = 0)
    db.secret(name = auth.user.first_name).update(Test = 1)
    db.secret(name = auth.user.first_name).update(correct = 0)
    db.secret(name = auth.user.first_name).update(wrong = 0)
    db.secret(name = auth.user.first_name).update(unanswered = 0)
    db.secret(name = auth.user.first_name).update(Level1Hint = 0)

Giving Error as 

<type 'exceptions.AttributeError'> 'NoneType' object has no attribute 'first_name'

db(db.secret.name == auth.user.first_name).update(correct = 0)
db(db.secret.name == auth.user.first_name).update(wrong = 0)
db(db.secret.name == auth.user.first_name).update(unanswered = 0)
db(db.secret.name == auth.user.first_name).update(Level1Hint = 0)
elif(auth_count == secret_count):
db.secret(name = auth.user.first_name).update(quesstatus= 1)

db.secret(name = auth.user.first_name).update(score1 = 0)
db.secret(name = auth.user.first_name).update(Test = 1)
db.secret(name = auth.user.first_name).update(correct = 0)
db.secret(name = auth.user.first_name).update(wrong = 0)
Showing there is an error in color line. I am unable to find the error please help me to solve to problem argent.Regards,T.SaiHarsh

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
MS | 29 Jun 09:17 2015
Picon

Query failing in Taskqueue


 

We have a Web2py application hosted on Google app engine.

We are trying to implement Taskqueue for fetching record from tables, we are passing the filter field (date type) and number of years as parameters. These parameters will be then passed to a Query to fetch the data from the Database.

Please find the code snippet as given below:

Task_handler() function accepts the 2 input parameters and calls the taskqueue which is defined in the task_process() function. In task_process() function we are calculating the date based on the number of years parameters and using it in the query to fetch the records older than the calculated date.

def task_handler():

      if len(request.args):

                field= request.args[0]

filter=int(request.args[1])

       return taskqueue.add(url=URL('task_process'),params={’field’:field,'diff': filter,},method="POST")

      

def task_process():

                field= request.form.get(‘field’)

diff = request.form.get('diff')

    filter_date = datetime.date.today() + datetime.timedelta(-(365*(diff)))

    result = []

    result = db(field < filter_date).select()

 

Note :
field in this case is db.<tablename>.<columnname>

 

If we directly use the input parameter in query, it fails due to datatype mismatch.

So we tried by hard-coding the table field name in the query but got Attribute Error for that.

 

Kindly provide your inputs on what are we missing here or doing wrong.

 

Thanks.

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.

Gmane