[web2py] MySQLdb connect() issues

2010-05-26 Thread Evan
Hey all,

I hit an issue in the MySQLAdapter class trying to establish a
database connection. It seems the "password" keyword argument in
connect() should be "passwd"? The python-mysql docs support this:
http://mysql-python.sourceforge.net/MySQLdb.html#mysqldb

If this is an issue of different versions of MySQLdb using different
keyword arguments and a newer version does indeed use "password" then
please ignore (I'm running python2.5). Otherwise, should this be
changed?

Thanks,

Evan


Re: [web2py] Pypy 2.0 beta2 - is there anyone testing this with web2py?

2013-04-27 Thread Evan Phelps
I also get the error but from a different line in dal.py.  Could you send 
me your patch so that I can see if I'm experiencing the same issue?  Or has 
it already been implemented in the web2py source (I didn't see a reference 
to it in the bugs list)?

running:

* Python 2.7.3 (c13457babbfb, Apr 22 2013, 17:59:01) [PyPy 2.0.0-beta2 with 
GCC 4.8.0]
* 2.4.6-stable+timestamp.2013.04.06.17.37.38 (Running on Rocket 1.2.6)

Could you send me the 
On Sunday, April 7, 2013 3:26:13 PM UTC-4, Niphlod wrote:
>
> you're right, there's a typo in dal.py.
> Patch sent to Massimo.
>
> On Sunday, April 7, 2013 8:54:51 PM UTC+2, Alfonso de la Guarda Reyes 
> wrote:
>>
>> Hi,
>>
>> Well i get an error 
>>  unbound method __setattr__() must be called 
>> with int instance as first argument (got Reference instance instead) 
>>
>> 1.
>> 2.
>> 3.
>> 4.
>> 5.
>> 6.
>> 7.
>> 8.
>> 9.
>> 10.
>> 11.
>> 12.
>> 13.
>> 14.
>> 15.
>> 16.
>> 17.
>> 18.
>> 19.
>> 20.
>> 21.
>> 22.
>> 23.
>> 24.
>> 25.
>> 26.
>> 27.
>> 28.
>> 29.
>> 30.
>> 31.
>> 32.
>>
>> Traceback (most recent call last):
>>   File "/home/alfonsodg/Devel/web2py/gluon/restricted.py", line 212, in 
>> restricted
>>
>>
>> exec ccode in environment
>>   File 
>> "/home/alfonsodg/Dropbox/Devel/web2py/applications/social_mapper/controllers/default.py"
>>  
>> ,
>>  line 43, in 
>>
>>
>>   File "/home/alfonsodg/Devel/web2py/gluon/globals.py", line 194, in 
>>
>>
>> self._caller = lambda f: f()
>>
>>
>>   File 
>> "/home/alfonsodg/Dropbox/Devel/web2py/applications/social_mapper/controllers/default.py"
>>  
>> ,
>>  line 8, in user
>>
>>
>> return dict(form=auth())
>>   File "/home/alfonsodg/Devel/web2py/gluon/tools.py", line 1245, in __call__
>>
>>
>> return getattr(self, args[0])()
>>
>>
>>   File "/home/alfonsodg/Devel/web2py/gluon/tools.py", line 2142, in login
>>
>>
>> self.login_user(user)
>>   File "/home/alfonsodg/Devel/web2py/gluon/tools.py", line 1817, in 
>> login_user
>>
>>
>> self.update_groups()
>>   File "/home/alfonsodg/Devel/web2py/gluon/tools.py", line 2895, in 
>> update_groups
>>
>>
>> table_membership.user_id == self.user.id).select()
>>
>>
>>   File "/home/alfonsodg/Devel/web2py/gluon/dal.py", line 9810, in select
>>
>>
>> return adapter.select(self.query,fields,attributes)
>>
>>
>>   File "/home/alfonsodg/Devel/web2py/gluon/dal.py", line 1676, in select
>>
>>
>> return self._select_aux(sql,fields,attributes)
>>
>>
>>   File "/home/alfonsodg/Devel/web2py/gluon/dal.py", line 1657, in _select_aux
>>
>>
>> return processor(rows,fields,self._colnames,cacheable=cacheable)
>>
>>
>>   File "/home/alfonsodg/Devel/web2py/gluon/dal.py", line 2028, in parse
>>
>>
>> value = self.parse_value(value,ft,blob_decode)
>>
>>
>>   File "/home/alfonsodg/Devel/web2py/gluon/dal.py", line 1876, in parse_value
>>
>>
>> return self.parsemap[key](value,field_type)
>>
>>
>>   File "/home/alfonsodg/Devel/web2py/gluon/dal.py", line 1882, in 
>> parse_reference
>>
>>
>> value._table, value._record = self.db[referee], None
>>
>>
>>   File "/home/alfonsodg/Devel/web2py/gluon/dal.py", line 8007, in __setattr__
>>
>>
>> int.__setattr__(self, key, value)
>>
>> TypeError: unbound method __setattr__() must be called with int instance as 
>> first argument (got Reference instance instead)
>>
>>
>> comes from dal.py
>>
>>
>> Saludos,
>>
>> 
>> Alfonso de la Guarda
>> Twitter: @alfonsodg
>> Redes sociales: alfonsodg
>>Telef. 991935157
>> 1024D/B23B24A4
>> 5469 ED92 75A3 BBDB FD6B  58A5 54A1 851D B23B 24A4
>>
>>
>> On Sun, Apr 7, 2013 at 1:17 PM, David Marko  wrote:
>>
>>> Is there anyone testing Pyp with web2py. Is it usable now or in future 
>>> as faster plarfotm?
>>>
>>> http://morepypy.blogspot.cz/2013/04/pypy-20-beta-2-released.html
>>>  
>>> -- 
>>>  
>>> --- 
>>> 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.
>>>  
>>>  
>>>
>>
>>

-- 

--- 
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 on Google Drive

2013-08-07 Thread Evan Caldwell
I use Google Drive on all my machines to keep things synced up. I installed 
web2py on my windows laptop in a folder in my Google Drive (I use the 
windows client). Then I opened up web2py on my windows machine at work from 
the same synced folder. I can open up the admin page an all but when I open 
a page that tries to access the database I get errors. I'm sure there is a 
good reason but I'm kind of a noob and learning web development via web2py 
so any help is much appreciated.

-- 

--- 
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 Google Drive

2013-08-13 Thread Evan Caldwell
Johann, 

I didn't realize you had responded. I am using MySQL and getting the error 
: no such table: auth_user


On Thursday, August 8, 2013 1:41:52 AM UTC-6, Johann Spies wrote:
>
> On 08/08/2013 01:10, Evan Caldwell wrote: 
> > I use Google Drive on all my machines to keep things synced up. I 
> > installed web2py on my windows laptop in a folder in my Google Drive 
> > (I use the windows client). Then I opened up web2py on my windows 
> > machine at work from the same synced folder. I can open up the admin 
> > page an all but when I open a page that tries to access the database I 
> > get errors. I'm sure there is a good reason but I'm kind of a noob and 
> > learning web development via web2py so any help is much appreciated. -- 
> Which database do you use? 
> What do the errors tell you? 
>
> Regards 
> Johann 
>
> -- 
> Johann SpiesTelefoon: 021-808 4699 
> Databestuurder /  Data managerFaks: 021-883 3691 
>
> Sentrum vir Navorsing oor Evaluasie, Wetenskap en Tegnologie 
> Centre for Research on Evaluation, Science and Technology 
> Universiteit Stellenbosch. 
>
>   "Rest in the LORD, and wait patiently for him: fret not 
>thyself because of him who prospereth in his way, 
>because of the man who bringeth wicked devices to pass." 
>  Psalms 37:7 
>
> E-pos vrywaringsklousule 
>
> Hierdie e-pos mag vertroulike inligting bevat en mag regtens 
> geprivilegeerd wees en is slegs bedoel vir die persoon aan wie dit 
> geadresseer is. Indien u nie die bedoelde ontvanger is nie, word u hiermee 
> in kennis gestel dat u hierdie dokument geensins mag gebruik, versprei of 
> kopieer nie. Stel ook asseblief die sender onmiddellik per telefoon in 
> kennis en vee die e-pos uit. Die Universiteit aanvaar nie aanspreeklikheid 
> vir enige skade, verlies of uitgawe wat voortspruit uit hierdie e-pos en/of 
> die oopmaak van enige lês aangeheg by hierdie e-pos nie. 
>
> E-mail disclaimer 
>
> This e-mail may contain confidential information and may be legally 
> privileged and is intended only for the person to whom it is addressed. If 
> you are not the intended recipient, you are notified that you may not use, 
> distribute or copy this document in any manner whatsoever. Kindly also 
> notify the sender immediately by telephone, and delete the e-mail. The 
> University does not accept liability for any damage, loss or expense 
> arising from this e-mail and/or accessing any files attached to this 
> e-mail. 
>

-- 

--- 
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: Performing database inserts with FORM( )

2013-08-13 Thread Evan Caldwell
Ross, I am currently trying to build a time clock app as well but I'm new 
to web2py (and fairly new to programming in general), I would love to be 
able to ask some questions.

On Thursday, March 10, 2011 7:18:34 AM UTC-7, Ross Peoples wrote:
>
> Let's not forget about SQLFORM.factory either. This lets you create a 
> SQLFORM based on a virtual table that you create as an argument to 
> SQLFORM.factory. For example, I used this code to provide edit capabilities 
> when editing time clock entries for an app I'm writing. It includes form 
> validation, and I wrote a module that handles the actual db update. When 
> you see "timeclock.edit_entry()", this is just handing off the form 
> variables to the module, which performs extra validation on the data before 
> committing it to the db. NOTE: All of this code is inside my "def edit():" 
> function.
>
> def validate_form(form):
> users = [auth.user.id]
> for user in user_security.get_subordinates(auth.user):
> users.append(user.auth_user.id)
> 
> if int(form.vars.auth_user) not in users:
> form.errors.adjusted_start = "You do not have permission to 
> modify this person's time clock."
>
> if not request.args(0): raise HTTP(400, 'Timeclock ID not found')
> timeclock_id = request.args(0)
> timeclock_entry = db(db.timeclock.id==timeclock_id).select().first()
> if timeclock_entry is None: raise HTTP(400, 'Timeclock ID not found')
> 
> form = SQLFORM.factory(
> Field('adjusted_start', 'datetime', requires=IS_NOT_EMPTY()),
> Field('adjusted_end', 'datetime'),
> Field('reason', 'text', requires=IS_NOT_EMPTY()),
> Field('auth_user', db.auth_user, readable=False, writable=False),
> hidden = {'id': timeclock_id, 'auth_user': 
> timeclock_entry.auth_user.id}
> )
> form.vars.auth_user = timeclock_entry.auth_user.id
> form.vars.adjusted_start = timeclock_entry.adjusted_start
> form.vars.adjusted_end = timeclock_entry.adjusted_end
> if form.accepts(request.vars, session, keepvalues=True, 
> onvalidation=validate_form(form)):
> row_id = timeclock.edit_entry(auth.user, timeclock_entry, 
> form.vars.reason, form.vars.adjusted_start, form.vars.adjusted_end)
> if isinstance(row_id, str):
> response.flash = row_id
> else:
> redirect(URL('index'))
>
> return dict(form=form, timeclock_entry=timeclock_entry, 
> history=history)
>

-- 

--- 
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 Google Drive

2013-08-14 Thread Evan Caldwell
Johann, apparently I'm not sure.. I'll check it out. Thank you.

On Wednesday, August 14, 2013 6:03:43 AM UTC-6, Johann Spies wrote:
>
> On 13 August 2013 19:29, Evan Caldwell >wrote:
>
> Johann, 
>>
>> I didn't realize you had responded. I am using MySQL 
>>
>
>
> Are you sure? 
>
> and getting the error :
>>
>  no such table: auth_user
>>
>
> The error comes from sqlite!
>
> Anyhow your problem is that you have to have a portable database if you 
> want to work like that.  Others have suggested solutions to your problem. 
> The easiest will probably be to use sqlite.
>
> Regards
> Johann
>  
>

-- 

--- 
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 a dynamic total for a smartgrid

2013-11-01 Thread Evan Caldwell
I am new to web2py so please excuse any obvious questions. I have the 
following table:
db.define_table('timeclock',
Field('project','string', required=True, label='Project'),
Field('work_date','date', required=True, label='Work Date'),
Field('time_in','time', required=True, label='Time In'),
Field('time_out','time', required=True, label='Time Out'),
Field('description', 'text', required=True, label='Description'),
Field('hours','double', label='hours'),
Field('usr_id','reference auth_user', label='ID', readable=False)
)
db.timeclock.project.requires = IS_IN_DB(db,'siri_projects.name')
db.timeclock.work_date.requires = IS_DATE(format='%m/%d/%Y')
db.timeclock.time_in.requires = IS_NOT_EMPTY()
db.timeclock.time_out.requires = IS_NOT_EMPTY()
db.timeclock.description.requires = IS_NOT_EMPTY()
db.timeclock.usr_id.writable = db.timeclock.usr_id.readable = False
if auth.is_logged_in():
db.timeclock.usr_id.default=auth.user.id

and the following function in the controller:
@auth.requires_login()
def displaytime():
"""
Shows the entries for the user that is logged in
"""
grid = SQLFORM.smartgrid(db.timeclock, deletable=False, editable=False, 
create=False, orderby=~db.timeclock.work_date)
return dict(grid=grid)

how do I total the hours worked column for the smartgrid? I would like for 
it to be totaled based on the current subset so that if I filter the 
smartgrid the total only shows for the filtered results (e.g. an employee 
wants to be able to view hours worked in a certain pay period).

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] cannot figure out invalid load key, '<'.

2013-12-13 Thread Evan Caldwell
I got this error today after doing a git pull from my repo (there is one 
other person working on this code as well). I'm sure I'm missing something 
small but I don't know what. I also cannot get into database administration 
due to the same error. Thanks in advance for the help.

 invalid load key, '<'. Version  web2py™ 
Version 
2.7.4-stable+timestamp.2013.11.14.13.28.53  Python Python 2.7: 
C:\web2py\web2py_no_console.exe (prefix: C:\web2py)  Traceback 

1.
2.
3.
4.
5.
6.
7.
8.

Traceback (most recent call last):
  File "C:\web2py\gluon\restricted.py", line 217, in restricted
  File "C:/web2py/applications/siriadmin/models/db.py" 
, line 136, in 

  File "C:\web2py\gluon\dal.py", line 8129, in define_table
  File "C:\web2py\gluon\dal.py", line 8166, in lazy_define_table
  File "C:\web2py\gluon\dal.py", line 1079, in create_table
UnpicklingError: invalid load key, '<'.

Error snapshot [image: help] 

 

(invalid load key, '<'.) 

inspect attributes 
 Frames 
   
   -  
   
   *File C:\web2py\gluon\restricted.py in restricted at line 217* code 
   arguments variables 
-  
   
   *File C:\web2py\applications\siriadmin\models\db.py in  at line 
   136* code arguments variables 
-  
   
   *File C:\web2py\gluon\dal.py in define_table at line 8129* code arguments 
   variables 
-  
   
   *File C:\web2py\gluon\dal.py in lazy_define_table at line 8166* code 
   arguments variables 
-  
   
   *File C:\web2py\gluon\dal.py in create_table at line 1079* code arguments 
   variables 
Function argument list 
   
   (self=, table=,
 
   migrate=True, fake_migrate=False, polymodel=None)
Code listing 
   
   1074.
   1075.
   1076.
   1077.
   1078.
   1079.
   
   1080.
   1081.
   1082.
   1083.
   
   else:
   self.log('success!\n', table)
   else:
   tfile = self.file_open(table._dbt, 'r')
   try:
   sql_fields_old = pickle.load(tfile)
   
   except EOFError:
   self.file_close(tfile)
   raise RuntimeError('File %s appears corrupted' % table._dbt)
   self.file_close(tfile)
   
Variables   

 Context 

locals request session response 
 In file: C:\web2py\applications\siriadmin\models\db.py 

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.

# -*- coding: utf-8 -*-

#
## This scaffolding model makes your app work on Google App Engine too
## File is released under public domain and you can use without limitations
#

## if SSL/HTTPS is properly configured and you want all HTTP requests to
## be redirected to HTTPS, uncomment the line below:
# request.requires_https()

if not request 
.env.web2py_runtime_gae:
## if NOT running on Google App Engine use SQLite or other DB
db = DAL 
('sqlite://storage.sqlite',pool_size=1,check_reserved=['all'])
else:
## connect to Google BigTable (optional 'google:datastore://namespace')
db = DAL 
('google:datastore')
## store sessions and tickets there
session 
.connect(request 
, response 
, db=db)
## or store session in Memcache, Redis, etc.
## from gluon.contrib.memdb import MEMDB
## from google.appengine.api.memcache import Client
## session.connect(request, response, db = MEMDB(Client()))

## by default give a view/generic.extension to all actions from localhost
## none otherwise. a pattern can be 'controller/function.extension'
response .generic_patterns 
= ['*'] if request 
.is_local else []
## (optional) optimize handling of static files
# response.optimize_css = 'concat,minify,inline'
# response.optimize_js = 'concat,minify,inline'

#
## Here is sample code if you need for
## - email capabilities
## - authentication (registratio

[web2py] Ordering a dropdown in SQLFORM alphabetically

2015-12-16 Thread Evan Caldwell

I am having a hard time ordering a dropdown in a SQLFORM alphabetically.

In my model:
db.define_table('departments',
Field('name', notnull=True, unique=True),
Field('college_id','reference college', label='College'),
Field('department_rep_user_id','reference auth_user', label='Department 
Representative'),
auth.signature,
format='%(name)s')

db.define_table('mentors',
Field('auth_user_id', 'reference auth_user', unique=True),
Field('department_id', 'reference departments', label='Department'),
auth.signature,
format=repr_mentor_table)

db.define_table('abstracts',
Field('title', notnull=True, unique=True),
Field('college_id', 'reference college', label='College'),
Field('department_id', 'reference departments', label='Abstract 
Department'),
Field('mentor_id', 'reference mentors', label='Mentor'),
Field('classes_id', 'reference classes', label='Class', comment="If 
your abstract is connected to a specific class (perhaps as a class 
project), select your class. Otherwise, select 'Does not apply'"),
Field('session_id', 'reference sessions', label='Session'),
Field('presentation_format_id', 'reference presentation_formats', 
label='Presentation Format'),
Field('body','text'),
Field('attatchment', 'upload'),
Field('location_id', 'reference locations', label='Location'),
Field('conference_id', 'reference conferences', label='Conference'),
Field('presentation_time', 'time', notnull=False, requires=IS_TIME(), 
label='Presentation Time'),
Field('booth_space', label='Booth Space'),
Field('initial_approval', 'boolean', label='Initial Approval', 
default=None),
Field('final_approval', 'boolean', label='Final Approval', 
default=None),
Field('competing_status', 'boolean', label='Competing Status', 
default=None),
auth.signature,
format='%(title)s',
singular="Abstract",
plural="Abstracts",
)

In the controller
def abstracts():
response.title = "Abstracts"

def get_primary_author(abstract_row):
author_row = db(
(db.abstract_author.primary_author==True) &
(db.abstract_author.abstract_id==abstract_row.id) &
(db.abstract_author.auth_user_id==db.auth_user.id)
).select(
db.auth_user.first_name,
db.auth_user.last_name).first()
return author_row.first_name + ' ' + author_row.last_name

def abstracts_body_represent(body, row):
sanitized = str(rcwc_sanitizer(body))

# This is really fragile. For some reason the grid isn't enforcing
# maxtextlength if the represent is called.
if len(request.args) == 1: # not on the grid page
sanitized = "{0}...".format(sanitized[:100])
return XML(sanitized) # If this returns a string it isn't used

db.abstracts.body.represent = abstracts_body_represent

grid = SQLFORM.smartgrid(
db.abstracts,
user_signature=False,
searchable=True,
linked_tables=['abstract_author'],
links=[
{"header": "Primary Author", "body":get_primary_author},
],
links_placement="left",
paginate=75,
)

return locals()

When I go to create a new abstract in the abstracts table the dropdown for 
Mentors (mentor_id field) is not alphabetically ordered. Can this be 
accomplished in the model or would I need to work it out in the controller?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Ordering a dropdown in SQLFORM alphabetically

2015-12-16 Thread Evan Caldwell
I tried:
db.mentors.auth_user_id.requires = IS_IN_DB(db, 'auth_user.id', '%(name)s', 
orderby = db.auth_user.first_name)
but it had no effect. I read on another question about building and 
ordering a set and then using IS_IN_SET on that but I'm not sure how to go 
about doing that; can I do a query right below my mentor table definition 
in the model? Sorry for being such a noob.


On Wednesday, December 16, 2015 at 12:48:10 PM UTC-7, Niphlod wrote:
>
> a proper IS_IN_DB with the correct orderby in models should be the easiest 
> way to go.
>
> On Wednesday, December 16, 2015 at 8:33:06 PM UTC+1, Evan Caldwell wrote:
>>
>>
>> I am having a hard time ordering a dropdown in a SQLFORM alphabetically.
>>
>> In my model:
>> db.define_table('departments',
>> Field('name', notnull=True, unique=True),
>> Field('college_id','reference college', label='College'),
>> Field('department_rep_user_id','reference auth_user', 
>> label='Department Representative'),
>> auth.signature,
>> format='%(name)s')
>>
>> db.define_table('mentors',
>> Field('auth_user_id', 'reference auth_user', unique=True),
>> Field('department_id', 'reference departments', label='Department'),
>> auth.signature,
>> format=repr_mentor_table)
>>
>> db.define_table('abstracts',
>> Field('title', notnull=True, unique=True),
>> Field('college_id', 'reference college', label='College'),
>> Field('department_id', 'reference departments', label='Abstract 
>> Department'),
>> Field('mentor_id', 'reference mentors', label='Mentor'),
>> Field('classes_id', 'reference classes', label='Class', comment="If 
>> your abstract is connected to a specific class (perhaps as a class 
>> project), select your class. Otherwise, select 'Does not apply'"),
>> Field('session_id', 'reference sessions', label='Session'),
>> Field('presentation_format_id', 'reference presentation_formats', 
>> label='Presentation Format'),
>> Field('body','text'),
>> Field('attatchment', 'upload'),
>> Field('location_id', 'reference locations', label='Location'),
>> Field('conference_id', 'reference conferences', label='Conference'),
>> Field('presentation_time', 'time', notnull=False, requires=IS_TIME(), 
>> label='Presentation Time'),
>> Field('booth_space', label='Booth Space'),
>> Field('initial_approval', 'boolean', label='Initial Approval', 
>> default=None),
>> Field('final_approval', 'boolean', label='Final Approval', 
>> default=None),
>> Field('competing_status', 'boolean', label='Competing Status', 
>> default=None),
>> auth.signature,
>> format='%(title)s',
>> singular="Abstract",
>> plural="Abstracts",
>> )
>>
>> In the controller
>> def abstracts():
>> response.title = "Abstracts"
>>
>> def get_primary_author(abstract_row):
>> author_row = db(
>> (db.abstract_author.primary_author==True) &
>> (db.abstract_author.abstract_id==abstract_row.id) &
>> (db.abstract_author.auth_user_id==db.auth_user.id)
>> ).select(
>> db.auth_user.first_name,
>> db.auth_user.last_name).first()
>> return author_row.first_name + ' ' + author_row.last_name
>>
>> def abstracts_body_represent(body, row):
>> sanitized = str(rcwc_sanitizer(body))
>>
>> # This is really fragile. For some reason the grid isn't enforcing
>> # maxtextlength if the represent is called.
>> if len(request.args) == 1: # not on the grid page
>> sanitized = "{0}...".format(sanitized[:100])
>> return XML(sanitized) # If this returns a string it isn't used
>>
>> db.abstracts.body.represent = abstracts_body_represent
>>
>> grid = SQLFORM.smartgrid(
>> db.abstracts,
>> user_signature=False,
>> searchable=True,
>> linked_tables=['abstract_author'],
>> links=[
>> {"header": "Primary Author", "body":get_primary_author},
>> ],
>> links_placement="left",
>> paginate=75,
>> )
>>
>> return locals()
>>
>> When I go to create a new abstract in the abstracts table the dropdown 
>> for Mentors (mentor_id field) is not alphabetically ordered. Can this be 
>> accomplished in the model or would I need to work it out in the controller?
>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Importing a csv I get (name 'step' is not defined)?

2015-06-09 Thread Evan Caldwell
I'm getting this same error and cannot figure it out. Any help would be 
much appreciated.



On Wednesday, July 16, 2014 at 4:12:28 PM UTC-6, Jakob Hartman wrote:
>
>  name 'step' is not definedVersionweb2py™Version 
> 2.9.5-stable+timestamp.2014.03.16.02.35.39PythonPython 2.7.8: 
> /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
>  
> (prefix: /Library/Frameworks/Python.framework/Versions/2.7)Traceback
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
>
> Traceback (most recent call last):
>   File "/Users/Jakob/Desktop/web2py/gluon/restricted.py", line 220, in 
> restricted
> exec ccode in environment
>   File "/Users/Jakob/Desktop/web2py/applications/mqr/views/appadmin.html" 
> , line 183, 
> in 
> {{=T("DISK")}}
> NameError: name 'step' is not defined
>
> Error snapshot [image: help] 
> 
>
> (name 'step' is not defined)
>
> inspect attributes
> Frames
>
>- 
>
>*File /Users/Jakob/Desktop/web2py/gluon/restricted.py in restricted at 
>line 220* code arguments variables
>- 
>
>*File /Users/Jakob/Desktop/web2py/applications/mqr/views/appadmin.html 
>in  at line 183* code arguments variables
>Function argument list
>
>()
>Code listing
>
>174.
>175.
>176.
>177.
>178.
>179.
>180.
>181.
>182.
>183.
>
>184.
>185.
>186.
>187.
>188.
>189.
>190.
>191.
>192.
>193.
>
>response.write(T('"update" is an optional expression like 
> "field1=\'newvalue\'". You cannot update or delete the results of a JOIN'))
>response.write('\n\n', escape=False)
>response.write(T("%s selected", nrows))
>response.write('\n', escape=False)
>if start>0:
>response.write(A(T('previous %s rows') % 
> step,_href=URL('select',args=request.args[0],vars=dict(start=start-step)),_class="btn"))
>pass
>response.write('\n', escape=False)
>if stopresponse.write(A(T('next %s rows') % 
> step,_href=URL('select',args=request.args[0],vars=dict(start=start+step)),_class="btn"))
>
>pass
>response.write('\n', escape=False)
>if rows:
>response.write('\nwidth="80%">\n   ', escape=False)
>linkto = lambda f, t, r: URL('update', args=[request.args[0], r, 
> f]) if f else "#"
>response.write('\n   ', escape=False)
>upload=URL('download',args=request.args[0])
>response.write('\n   ', escape=False)
>
> response.write(SQLTABLE(rows,linkto,upload,orderby=True,_class='sortable'))
>response.write('\n   \n', 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/d/optout.