[web2py] Re: Radio Buttons basic inline editing in SQLFORM.grid

2020-07-24 Thread 'Matthew J Watts' via web2py-users
Hi jacob, i am trying to do the same thing, did you find a solution for 
this?

On Saturday, April 27, 2019 at 4:20:10 AM UTC+2 Jacob wrote:

> Thank you for the response it appears that they do have the same name . 
> I'm sorry I'm still new to programming in general, I've read around about 
> how to use append but I'm failing to understand how it can be applied to 
> the radio widget function which looks like this
>
>
>- def radio_widget(field,value,**kwargs):
>- return SQLFORM.widgets.radio.widget(field,value,**kwargs)
>
>
> Please if you are able to help guide me further I'll be very grateful. 
>
>
> Thursday, April 25, 2019 at 9:58:22 PM UTC+1, Dave S wrote:
>
>>
>>
>> On Wednesday, April 24, 2019 at 4:16:56 PM UTC-7, Jacob wrote:
>>>
>>> Hello I'm still new to web2py and I'm currently working on an a grid 
>>> which utilises basic inline editing using the example from 
>>> http://www.web2pyslices.com/slice/show/1928/basic-inline-editing-in-sqlformgrid-no-plugin-no-javascript
>>>  
>>>
>>> When I change the options widget to a radio widget for some reason only 
>>> one value for a whole set of seperate records can be selected rather than 
>>> each record having only 1 radio button field selected. In other words a 
>>> record has 4 possible values and they are displayed in a grid and can be 
>>> edited there is a field with a set which I'm trying to use radio buttons 
>>> for instead of a drop down menu. When I press a value for the first record 
>>> this is fine when I move onto the record beneath it the radio button value 
>>> is selected however the first one becomes empty and this carries on 
>>> throughout all the records on the grid only 1 field can be selected at a 
>>> time. If someone could help me please I would be very grateful.  
>>>
>>
>> My first thought is that you've got a bunch of buttons with the same 
>> name.  You can check this fairly easily by using your browser's inspect 
>> tool, and looking at the buttons for name=.  If that's the case, then 
>> you need to work out a way for each item's buttons to get a unique name; 
>> perhaps append item.id on the end of the name.
>>
>> /dps
>>  
>>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/8e48fbb0-488f-4f38-85e5-80eac0d0999an%40googlegroups.com.


[web2py] SQL grid groupby work around using posgres

2019-02-25 Thread 'Matthew J Watts' via web2py-users
Hi all

I have recently moved from SQLite to Postgres, I've had to change all the  
'groupby' to 'distinct'. However, I'm also using the 'groupby; command in 
the SQLgrids, but this does not have a distinct option.
Does anyone know of a workaround? Example code below


def re_standardise_taxon():

   
query = ((db.study_meta_data.publication_info_id == publication_info_id) &
 (db.gbif_taxon.taxon_id == db.study_meta_data.taxon_id))

form = SQLFORM.grid(query,
field_id=db.study_meta_data.id,
groupby=db.study_meta_data.taxon,
fields=[db.study_meta_data.taxon,
db.study_meta_data.taxon_id],
headers={'study_meta_data.taxon': 'Original Taxon Name',
 'study_meta_data.taxon_id': 'Replacement Taxon 
Name'},
maxtextlength=200, searchable=True, 
advanced_search=False,
deletable=False, editable=False,
details=False, create=False, csv=False
)
return locals()

-- 
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] Select_or_add

2018-11-28 Thread 'Matthew J Watts' via web2py-users
Hi all

Anyone using this feature with the current version of web2py. I tried to 
get the feature working using the code from the link below but it isnt 
working propery i.e. can´t close pop up box, form doesn't refesh when i 
insert a new entry. I still have to learn Jquery and javascript

https://github.com/mdipierro/web2py-recipes-source/blob/master/source/05_adding_ajax_effects/02_Creating_a_select_or_add_widget/default.py

cheers

Matt


-- 
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: Object not found

2018-09-28 Thread 'Matthew J Watts' via web2py-users
Looks like you are not sending/recieving your args properly (

For example You need to send args=Customer.id ,  from a button or redirect 
for example

You then need to request the Customer.id in the 'Client_Update' function

So you'd need 

def Client_Update():
client=request.args(0,cast=int)






On Friday, September 28, 2018 at 8:04:57 AM UTC+2, mostwanted wrote:
>
> I have 3 table, Items, Client & Purchases, the Client table stores the 
> details of the customer, the items table has a list of sold items and 
> Purchases stores what the customer purchased on what day. I have a function 
> in the controller that allows the editing of Customer and Purchases details 
> in one view by clicking on the owner's name but i keep getting the *Object 
> not found *message caused an attempt at opening an edit for the Purchases 
> table, what am i doing wrong, is there a better way of doing this?
>
> Regards
>
> Mostwanted
>
> *MODELS*
> db.define_table('Customer',
> Field('Name', requires=IS_NOT_EMPTY(), label=SPAN('First 
> Name', _style="font-weight: bold;")),
> Field('Surname', requires=IS_NOT_EMPTY(), label=SPAN('Last 
> Name', _style="font-weight: bold;")),
> Field('ID_Number', requirs=IS_NOT_EMPTY(), label=SPAN('Client 
> ID No', _style="font-weight: bold;")),
> Field('Company', requirs=IS_NOT_EMPTY(), label=SPAN(
> 'Company', _style="font-weight: bold;")),format='%(Surname)s ),
>
> db.define_table('Items',
> Field('Item', requires=IS_NOT_EMPTY()),
> format='%(Item)s')
>
> db.define_table('Purchases',
> Field('Client', 'reference Customer', label=SPAN('Client', 
> _style="font-weight: bold")),
> Field('Item', 'reference Item', unique=True, label=SPAN('
> Item Purchased', _style="font-weight: bold;")),
> Field('Booking_Date', 'datetime', default=request.now, 
> writable=False, label=SPAN('Date of Registration', _style="font-weight: 
> bold;")),
> Field('Serviced_By', 'reference auth_user', 
> default=auth.user_id, writable=False, label=SPAN('Serviced By', 
> _style="font-weight: bold;")))
>
>
> *CONTROLLER*
> def Client_Update():
> client=db.Customer(request.args(0))
> clientDetails=SQLFORM(db.Customer, client.id, deletable=True, showid=
> False).process()
> addRooms=SQLFORM(db.Purchases, client.id, deletable=True, showid=False
> ).process()
> return locals()
>
> *VIEW*
> {{extend 'layout.html'}}
>
> 
> VIEW & UPDATE CLIENT DETAILS
> {{=clientDetails}}
> 
> VIEW & UPDATE CLIENT PURCHASES
> {{=addRooms}}
> 
> {{pass}}
>
>
>

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


Re: [web2py] Re: default search string in SQL.grid

2018-09-17 Thread 'Matthew J Watts' via web2py-users
thanks that worked a treat! So was that done using jquery? I still have to
learn about it

On Thu, Sep 13, 2018 at 5:39 PM Anthony  wrote:

> On Thursday, September 13, 2018 at 8:36:11 AM UTC-4, Marcelo Huerta wrote:
>>
>> El jueves, 13 de septiembre de 2018, 8:10:48 (UTC-3), Matthew J Watts
>> escribió:
>>>
>>> Hello all
>>>
>>> Is there a way  to pre populate the  'search field' of the SQLFORM.grid?
>>>
>>>
>>>
>> In your URL to the function containing the grid, you can pass the search
>> string in the vars dictionary. Just assign it to the "keywords" key.
>>
>
> That's the way to go if you want the grid to show the actual results of
> the search. If you want the standard set of records but simply want to
> pre-populate the search box, you can do:
>
>  grid = SQLFORM.grid(db.mytable)
>  search_input = grid.element('#w2p_keywords')
>  if search_input:
>  search_input['_value'] = 'My keywords'
>
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/yohSjabLPCE/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/d/optout.
>

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


Re: [web2py] Re: default search string in SQL.grid

2018-09-13 Thread 'Matthew J Watts' via web2py-users
great, thanks all i´ll give that a go tomorrow!

On Thu, Sep 13, 2018 at 5:39 PM Anthony  wrote:

> On Thursday, September 13, 2018 at 8:36:11 AM UTC-4, Marcelo Huerta wrote:
>>
>> El jueves, 13 de septiembre de 2018, 8:10:48 (UTC-3), Matthew J Watts
>> escribió:
>>>
>>> Hello all
>>>
>>> Is there a way  to pre populate the  'search field' of the SQLFORM.grid?
>>>
>>>
>>>
>> In your URL to the function containing the grid, you can pass the search
>> string in the vars dictionary. Just assign it to the "keywords" key.
>>
>
> That's the way to go if you want the grid to show the actual results of
> the search. If you want the standard set of records but simply want to
> pre-populate the search box, you can do:
>
>  grid = SQLFORM.grid(db.mytable)
>  search_input = grid.element('#w2p_keywords')
>  if search_input:
>  search_input['_value'] = 'My keywords'
>
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/yohSjabLPCE/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/d/optout.
>

-- 
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] default search string in SQL.grid

2018-09-13 Thread 'Matthew J Watts' via web2py-users
Hello all

Is there a way  to pre populate the  'search field' of the SQLFORM.grid? 

For example i can populate fields in an SQLFORM with variables using 
something like

db.study_data.taxon.default = request.get_vars.tax_species


However, could i do something like?


grid.search.default = request.get_vars.tax_species






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


Re: [web2py] Re: update_or_insert doesn't always return the corresponding row id

2018-08-08 Thread 'Matthew J Watts' via web2py-users
Hi Manuele

Thanks for your feedback, i've got it sorted now Anthony kindly helped me
with the code. I'm still adding some things. But i'll upload the final code
once i'm done!

On Wed, Aug 8, 2018 at 9:46 AM, Manuele Pesenti 
wrote:

> or just let you be inspired from the update_or_insert method itself:
>
> https://github.com/web2py/pydal/blob/70929a6dc03e6296c34944d2d232f2
> 57b78337d7/pydal/objects.py#L822
>
> something like the following lines maybe will fit your needs:
>
> def update_or_insert(self, _key=DEFAULT, **values):
> if _key is DEFAULT:
> record = self(**values)
> elif isinstance(_key, dict):
> record = self(**_key)
> else:
> record = self(_key)
> if record:
> record.update_record(**values)
> newid = record.id # <- Here is the only code modification you
> need
> else:
> newid = self.insert(**values)
> return newid
>
> for example you can define it and call it passing the table to update or
> insert into as _first argument_
>
>
> On 01/08/2018 17:20, Anthony wrote:
>
> On Wednesday, August 1, 2018 at 6:46:09 AM UTC-4, Matthew J Watts wrote:
>>
>> Hi all
>>
>> I'm having the same problem, i'm trying to return an ID after an
>> 'update_or_insert', but I need the ID whether it inserts or updates to add
>> as a forign key to a related table.
>>
>
> Yes, the workaround is simple -- don't use .update_or_insert(). It is a
> simple function and you can easily replicate the logic on your own. See
> https://stackoverflow.com/a/51634265/440323.
>
> 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/d/optout.
>
>
> --
> 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/vjU9sYCoxU0/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/d/optout.
>

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


Re: [web2py] Re: update multiple tables from one csv and get row id after update_or_insert

2018-08-02 Thread &#x27;Matthew J Watts' via web2py-users
Many thanks for your help all, i'm slowly getting my head around it.
I'll post the code once it's finished in case anyone needs it in future

cheers

Matt

On Wed, Aug 1, 2018 at 7:41 AM, sandeep patel 
wrote:

> @Mattew J Watts,
> #Model
>
> db.define_table('person',
> Field('name'),
> Field('age'),
> Field('country'),
> format='%(name)s')
>
> db.define_table('thing',
>
>Field('person_id,'reference preson')
> Field('thing_name'),
> Field('value'),
> Field('location'))
>
> #controller
> def import_csv():
>  form = FORM(DIV(LABEL('file input',_for='exampleInputFile'
> ),INPUT(_type='file',_name='csvsheet',_id="exampleInputFile"),_class='
> from-group'),BUTTON('click',_type='submit',_class="btn btn-default"))
> if form.process().accepted:
> try:
> for i in csv.DictReader(request.vars.csvsheet.file):
> # db['things'].insert(person_id= db['person'].insert(**i)
> ,.)
> a = db['person'].insert(**i)
> db['things'].insert(person_id=a,.)
> except:
> form.errors.csvfile = 'Invalid file format.'
> return locals()
>
> Hope, this will help you!
>
> Best/
>
> On Wed, Aug 1, 2018 at 12:51 AM Anthony  wrote:
>
>> On Tuesday, July 31, 2018 at 2:24:51 PM UTC-4, pbreit wrote:
>>>
>>> I know db.thing.insert will return the ID of the newly created record
>>> and am pretty sure update_or_insert does as well. I'm not exactly sure how
>>> you would determine if an update or insert was performed (but perhaps you
>>> do not need to know?).
>>>
>>
>> Actually, update_or_insert does *not* return the ID in case of an
>> update. If you need the ID, then don't use update_or_insert but instead
>> write your own logic (the method is fairly simple -- see
>> https://github.com/web2py/pydal/blob/c954d1a22a0b83d90f728a4ab2daaa
>> 954e3f16c8/pydal/objects.py#L822).
>>
>> 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/d/optout.
>>
> --
> 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/EIFyKq78le4/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/d/optout.
>

-- 
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: update_or_insert doesn't always return the corresponding row id

2018-08-01 Thread &#x27;Matthew J Watts' via web2py-users
Hi all

I'm having the same problem, i'm trying to return an ID after an 
'update_or_insert', but I need the ID whether it inserts or updates to add 
as a forign key to a related table. 

Does anyone have a work around, someone mentioned that you could just 
'db(condition).select(table.id) after that.' but i don't quite get this, 
could someone please explain.  

On Friday, December 30, 2011 at 6:31:37 PM UTC+1, olivier wrote:
>
> The "insert" method returns the id of the inserted row. 
> The "update_or_insert" method returns the id of the inserted row, but 
> returns None in case of an update... 
>
> Why is it so? 
>
> I have a case in which I want to update_or_insert and then further 
> update the corresponding row (to track the status of a long running 
> process). 
> I would rather have the method to always output the id of the updated/ 
> inserted row... 
> Or is there any use-case you would like to discriminate between the 
> fact you inserted or update a row? 
>
> What do you think? 
>
>   -Olivier 
>
>
> From dal.py (I added the proposed modification) 
> === 
>
> def update_or_insert(self, key=DEFAULT, **values): 
>   if key==DEFAULT: 
> record = self(**values) 
>   else: 
> record = self(key) 
>if record: 
> record.update_record(**values) 
> newid = None  #--> why not record['id']  
>else: 
>  newid = self.insert(**values) 
>return newid

-- 
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: update multiple tables from one csv and get row id after update_or_insert

2018-07-31 Thread &#x27;Matthew J Watts' via web2py-users
ps - i'm getting the file locally as i havent worked out the .retrieve: 
method yet 



On Tuesday, July 31, 2018 at 6:51:41 PM UTC+2, Matthew J Watts wrote:
>
> Hello all
>
> I'm trying to build a .csv data upload facility which will update two 
> tables in sequence. So, i have my 'person' table which has a one to many 
> relationship with the 'thing' table i.e. one person can own many different 
> things.  
>
> What i need to do is get the primary key from a 'person' row after an 
> 'update_or_insert ', this ID will then go into the 'owner_id' for the 
> correseponding row in the  'thing' table . 
>
> Any ideas as to how i can do this? Excuse my programming i'm a beginner!
>
> model
>
> db.define_table('person',
> Field('name'),
> Field('age'),
> Field('country'),
> format='%(name)s')
>
> db.define_table('thing',
> Field('thing_name'),
> Field('value'),
> Field('location'),
> Field('owner_id'))
>
>
> controller
>
> import csv
>
> def importer():
> form = FORM(INPUT(_type='submit',_class="btn btn-primary"))
> if form.process().accepted:
> with 
> open('C:/Users/matt/PycharmProjects/all_projects/web2py/applications/uploadTest/private/test.csv')
>  as csvfile:
> readCSV = csv.reader(csvfile, delimiter=',')
> next(readCSV, None)
> for row in readCSV:
> name = row[0]
> age = row[1]
> country = row[2]
> thing_name = row[3]
> value = row[4]
> location = row[5]
> db.person.update_or_insert(name=name,age=age, country=country)
> 
> db.thing.insert(thing_name=thing_name,value=value,location=location)
> return dict(form=form)
>
>
> and the following data 
>
>
> person.name,person.age,person.country,thing.name,thing.value,thing.location
> matt,38,uk,teddy,12,house
> matt,38,uk,kite,13,outside
> matt,38,uk,screen,14,shed
> matt,38,uk,teddy,15,garden
> will,24,us,table,16,house
> will,24,us,teddy,17,outside
> will,24,us,kite,18,shed
> will,24,us,screen,19,garden
> pete,56,bel,teddy,20,house
> pete,56,bel,table,21,outside
> pete,56,bel,teddy,22,shed
> pete,56,bel,kite,23,garden
> pete,56,bel,screen,24,house
> pete,56,bel,teddy,25,outside
> matt,38,aus,teddy,26,shed
> matt,38,can,kite,27,garden
> matt,38,fr,screen,23,shed
> pete,25,bel,teddy,22,shed
> pete,25,bel,screen,74,shed
>
>

-- 
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] update multiple tables from one csv and get row id after update_or_insert

2018-07-31 Thread &#x27;Matthew J Watts' via web2py-users
Hello all

I'm trying to build a .csv data upload facility which will update two 
tables in sequence. So, i have my 'person' table which has a one to many 
relationship with the 'thing' table i.e. one person can own many different 
things.  

What i need to do is get the primary key from a 'person' row after an 
'update_or_insert ', this ID will then go into the 'owner_id' for the 
correseponding row in the  'thing' table . 

Any ideas as to how i can do this? Excuse my programming i'm a beginner!

model

db.define_table('person',
Field('name'),
Field('age'),
Field('country'),
format='%(name)s')

db.define_table('thing',
Field('thing_name'),
Field('value'),
Field('location'),
Field('owner_id'))


controller

import csv

def importer():
form = FORM(INPUT(_type='submit',_class="btn btn-primary"))
if form.process().accepted:
with 
open('C:/Users/matt/PycharmProjects/all_projects/web2py/applications/uploadTest/private/test.csv')
 as csvfile:
readCSV = csv.reader(csvfile, delimiter=',')
next(readCSV, None)
for row in readCSV:
name = row[0]
age = row[1]
country = row[2]
thing_name = row[3]
value = row[4]
location = row[5]
db.person.update_or_insert(name=name,age=age, country=country)

db.thing.insert(thing_name=thing_name,value=value,location=location)
return dict(form=form)


and the following data 


person.name,person.age,person.country,thing.name,thing.value,thing.location
matt,38,uk,teddy,12,house
matt,38,uk,kite,13,outside
matt,38,uk,screen,14,shed
matt,38,uk,teddy,15,garden
will,24,us,table,16,house
will,24,us,teddy,17,outside
will,24,us,kite,18,shed
will,24,us,screen,19,garden
pete,56,bel,teddy,20,house
pete,56,bel,table,21,outside
pete,56,bel,teddy,22,shed
pete,56,bel,kite,23,garden
pete,56,bel,screen,24,house
pete,56,bel,teddy,25,outside
matt,38,aus,teddy,26,shed
matt,38,can,kite,27,garden
matt,38,fr,screen,23,shed
pete,25,bel,teddy,22,shed
pete,25,bel,screen,74,shed

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


Re: [web2py] Re: Send args from a button in views

2018-05-26 Thread &#x27;Matthew J Watts' via web2py-users
Great thanks Sandeep!

On Sat, May 26, 2018 at 3:47 PM, Sandeep Patel  wrote:

> @Matthew J Watts
> That is my fault, I apologized for my mistake
>
> If you are trying to redirect one view to another view page.
>
> you can try this
>
> 
>
> Cancle
>
> 
>
> maybe that's some help you
>
> Thanks
> sp
>
>
> On Sat, May 26, 2018 at 3:17 PM, 'Matthew J Watts' via web2py-users <
> web2py@googlegroups.com> wrote:
>
>> Thanks for your help all!
>>  i'll give these a go. Sorry if i want that clear, but i'm not trying to
>> use a grid, i'm trying to redirect from a button in views
>>
>> 
>>{{=A('Cancel',_href=URL('my_collections'),_class="btn btn-primary")}}
>> 
>>
>>
>>
>> On Sat, May 26, 2018 at 8:21 AM, Sandeep Patel 
>> wrote:
>>
>>> @Matthew J Watts
>>> You can try this
>>> grid = SQLFORM.grid(query,selectable=[('Name',lambda ids
>>> :redirect(URL('default','func',args=ids)))])
>>>
>>>
>>> best
>>> sandeep
>>>
>>> On Fri, May 25, 2018 at 4:00 AM, 黄祥 
>>> wrote:
>>>
>>>> pls try (not tested)
>>>> {{=A('Finish',_href=URL('my_collections/%s/%s', % ('args0', 'args1')
>>>> ),_class="btn btn-primary")}}
>>>> or
>>>> {{=A('Finish',_href=URL('my_collections', args = ['args0', 'args1']
>>>> ),_class="btn btn-primary")}}
>>>>
>>>> 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/d/optout.
>>>>
>>>
>>> --
>>> 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/to
>>> pic/web2py/jtzQVBzQU6Y/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/d/optout.
>>>
>>
>> --
>> 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.
>>
>
> --
> 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/jtzQVBzQU6Y/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/d/optout.
>

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


Re: [web2py] Re: Send args from a button in views

2018-05-26 Thread &#x27;Matthew J Watts' via web2py-users
Thanks for your help all!
 i'll give these a go. Sorry if i want that clear, but i'm not trying to
use a grid, i'm trying to redirect from a button in views


   {{=A('Cancel',_href=URL('my_collections'),_class="btn btn-primary")}}




On Sat, May 26, 2018 at 8:21 AM, Sandeep Patel  wrote:

> @Matthew J Watts
> You can try this
> grid = SQLFORM.grid(query,selectable=[('Name',lambda ids
> :redirect(URL('default','func',args=ids)))])
>
>
> best
> sandeep
>
> On Fri, May 25, 2018 at 4:00 AM, 黄祥  wrote:
>
>> pls try (not tested)
>> {{=A('Finish',_href=URL('my_collections/%s/%s', % ('args0', 'args1')
>> ),_class="btn btn-primary")}}
>> or
>> {{=A('Finish',_href=URL('my_collections', args = ['args0', 'args1']
>> ),_class="btn btn-primary")}}
>>
>> 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/d/optout.
>>
>
> --
> 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/jtzQVBzQU6Y/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/d/optout.
>

-- 
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] Send args from a button in views

2018-05-24 Thread &#x27;Matthew J Watts' via web2py-users
Hi all

How do i  send args via a button from views. 

For example, i'd like to send variables to the 'my_collections URL'  {{=A(
'Finish',_href=URL('my_collections'),_class="btn btn-primary")}}

I can do something similar from the grid in a controller, however i cant 
find the right way to it from a button in views

links = [lambda row: A('Select', _class="btn 
btn-primary",_href=URL('my_collections'),
 
vars={'collection_info_id': collection_info_id}))]

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


Re: [web2py] python anywhere deployment issues

2018-05-02 Thread &#x27;Matthew J Watts' via web2py-users
fixed it,

For anyone else who gets this problem follow these steps

1. Reset the password following these instructions
http://help.pythonanywhere.com/pages/Web2pyAdminPassword/

2. then log onto the admin using **https:/**

See instructions
http://help.pythonanywhere.com/pages/AdminIsDisabledBecauseInsecureChannel/

On Wed, May 2, 2018 at 2:09 PM, 'Matthew J Watts' via web2py-users <
web2py@googlegroups.com> wrote:

> Hi everyone
>
>
> I am trying to deploy an app, built with version 2.16.1,  on the python
> anywhere server  using version 2.14.6
>
> However, i get a message telling me i need the latest version of the app
> on the server.
>
> What do i need to do with the app to make it compatible with  2.14.6?
>
> Any ideas what's up, or how i can work around this?
>
>
> Thanks
>
>
> Matthew
>
> --
> 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/zqpbLa2SN2o/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/d/optout.
>

-- 
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] python anywhere deployment issues

2018-05-02 Thread &#x27;Matthew J Watts' via web2py-users


Hi everyone


I am trying to deploy an app, built with version 2.16.1,  on the python 
anywhere server  using version 2.14.6

However, i get a message telling me i need the latest version of the app on 
the server. 

What do i need to do with the app to make it compatible with  2.14.6?

Any ideas what's up, or how i can work around this?


Thanks


Matthew

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


Re: [web2py] Re: Help with cascading drop down list

2018-03-04 Thread &#x27;Matthew J Watts' via web2py-users
Ok thanks for your tips Val, i'll focus my efforts on learning basic java
script then and libraries

Cheers

Matt

On Sat, Mar 3, 2018 at 3:43 PM, Val K  wrote:

> just for clarity:
> JQuery is a Javascript library. Javascript doesn't have any relation to
> Java. Web2py also has nothing to do with Java. There is a misunderstanding
> when you talk about Java.
> And yes, to do what you need, you should have understanding javascript.
> JQuery is quite enough for a simple application with some ajax tricks like
> yours. If you want to develop  a complex application with a rich UI, you
> have to study javascript much deeper, after that you won't have any
> questions about which library/framework  you'd better use (D3, Vue,
> Angular, React, Backbone, Knockout,  Ember ...+tons of others)
>
>
> On Saturday, March 3, 2018 at 2:54:24 PM UTC+3, Matthew J Watts wrote:
>>
>> Ciao Massimo
>>
>> Thanks for getting back to me. Where do i start! As a beginner i'm
>> struggling to understand how i go developing the dependent /cascading drop
>> down list.
>>
>> There seems to be several concepts i need to learn to be able build this
>> - i could do with a few pointers - what should i study ? Should i put my
>> efforts into learn java ,Jquery and ajax, then things will get clearer?  i
>> also want to incorporate data visualization into the app, so will think
>> about d3 too
>>
>> Sorry if i'm not making sense!
>>
>> Grazie
>>
>> Matt
>>
>>
>>
>> what do you want to do exctely? call a Java function from web2py?
>>>
>>>
>>> On Monday, 12 February 2018 11:56:59 UTC-6, Matthew J Watts wrote:
>>>>
>>>> Can anyone point me in the right direction with this, any good tutorial
>>>> out there on how i can integrate java and web2py?
>>>>
>>>> On Friday, February 9, 2018 at 12:05:32 PM UTC+1, Matthew J Watts wrote:
>>>>>
>>>>> Thanks for your reponse David!
>>>>>
>>>>> On Thursday, February 8, 2018 at 8:56:19 PM UTC+1, Dave S wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Thursday, February 8, 2018 at 9:55:25 AM UTC-8, Matthew J Watts
>>>>>> wrote:
>>>>>>>
>>>>>>> Hi community
>>>>>>>
>>>>>>> I'm having a few problems trying to understand how create
>>>>>>> a cascading drop down list. I've followed this recipe -
>>>>>>>
>>>>>>> http://www.web2pyslices.com/slice/show/1526/cascading-drop-
>>>>>>> down-lists-with-ajax-2
>>>>>>>
>>>>>>> i've managed to adapt it slightly, but i'm having trouble trying to
>>>>>>> add more tables to the cascade/sequence
>>>>>>>
>>>>>>
>>>>>> I'm not much of a menu person (I make use of ordinary anchor links
>>>>>> for the most part), but that example was probably written when BootStrap2
>>>>>> was the css/javascript in use.  Currently,  web2py ships with BootStrap3,
>>>>>> which doesn't support more than 1 level of submenus.  If you use 
>>>>>> stupid.css
>>>>>> (as in applications/example), you might not have that limitation, but I
>>>>>> can't show you what you want.
>>>>>>
>>>>>>
>>>>>>> It is quite difficult for me (a beginner) to suss out the logic
>>>>>>> behind it
>>>>>>>
>>>>>>>
>>>>>> Menus typically control what is shown by using javascript to
>>>>>> manipulate CSS.  Simple menus may be CSS only, but then they'd be
>>>>>> statically defined.
>>>>>>
>>>>>> Good luck!
>>>>>>
>>>>>> /dps
>>>>>>
>>>>>>
>>>>>>
>>>>>>> So at the moment i have the code below, what i'm trying to do is
>>>>>>> return a list of values from  the "tax_class" table, based  on a
>>>>>>> selection from the "tax_phylum" table( based on sececting an entry
>>>>>>> from the kingdom table)
>>>>>>>
>>>>>>> *model*
>>>>>>>
>>>>>>> db.define_table('tax

Re: [web2py] Re: Help with cascading drop down list

2018-03-03 Thread &#x27;Matthew J Watts' via web2py-users
Ciao Massimo

Thanks for getting back to me. Where do i start! As a beginner i'm
struggling to understand how i go developing the dependent /cascading drop
down list,  eventually i also want to start using the d3 library with my
app.
There seems to be several concepts i need to learn to be able build the
'drop down' this - i could do with a few pointers - what should i study
other than the web2py book

Should i put my efforts into learn java ,Jquery and ajax, then things will
get clearer?

Sorry if i'm not making sense!

Grazie

Matt



On Sun, Feb 25, 2018 at 3:27 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> what do you want to do exctely? call a Java function from web2py?
>
>
> On Monday, 12 February 2018 11:56:59 UTC-6, Matthew J Watts wrote:
>>
>> Can anyone point me in the right direction with this, any good tutorial
>> out there on how i can integrate java and web2py?
>>
>> On Friday, February 9, 2018 at 12:05:32 PM UTC+1, Matthew J Watts wrote:
>>>
>>> Thanks for your reponse David!
>>>
>>> On Thursday, February 8, 2018 at 8:56:19 PM UTC+1, Dave S wrote:
>>>>
>>>>
>>>>
>>>> On Thursday, February 8, 2018 at 9:55:25 AM UTC-8, Matthew J Watts
>>>> wrote:
>>>>>
>>>>> Hi community
>>>>>
>>>>> I'm having a few problems trying to understand how create a cascading
>>>>> drop down list. I've followed this recipe -
>>>>>
>>>>> http://www.web2pyslices.com/slice/show/1526/cascading-drop-
>>>>> down-lists-with-ajax-2
>>>>>
>>>>> i've managed to adapt it slightly, but i'm having trouble trying to
>>>>> add more tables to the cascade/sequence
>>>>>
>>>>
>>>> I'm not much of a menu person (I make use of ordinary anchor links for
>>>> the most part), but that example was probably written when BootStrap2 was
>>>> the css/javascript in use.  Currently,  web2py ships with BootStrap3, which
>>>> doesn't support more than 1 level of submenus.  If you use stupid.css (as
>>>> in applications/example), you might not have that limitation, but I can't
>>>> show you what you want.
>>>>
>>>>
>>>>> It is quite difficult for me (a beginner) to suss out the logic behind
>>>>> it
>>>>>
>>>>>
>>>> Menus typically control what is shown by using javascript to manipulate
>>>> CSS.  Simple menus may be CSS only, but then they'd be statically defined.
>>>>
>>>> Good luck!
>>>>
>>>> /dps
>>>>
>>>>
>>>>
>>>>> So at the moment i have the code below, what i'm trying to do is
>>>>> return a list of values from  the "tax_class" table, based  on a
>>>>> selection from the "tax_phylum" table( based on sececting an entry
>>>>> from the kingdom table)
>>>>>
>>>>> *model*
>>>>>
>>>>> db.define_table('tax_kingdom',
>>>>> Field('name'))
>>>>>
>>>>> db.define_table('tax_phylum',
>>>>> Field('name', 'string'),
>>>>> Field('kingdom_id'))
>>>>> db.tax_phylum.kingdom_id.requires = IS_IN_DB(db, db.tax_kingdom.id, 
>>>>> '%(name)s')
>>>>>
>>>>> db.define_table('tax_class',
>>>>> Field('name', 'string'),
>>>>> Field('phylum_id'))
>>>>> db.tax_class.phylum_id.requires = IS_IN_DB(db, db.tax_phylum.id, 
>>>>> '%(name)s')
>>>>>
>>>>>
>>>>> *Controller*
>>>>>
>>>>> def index():
>>>>> kingdoms = db().select(db.tax_kingdom.ALL)
>>>>>
>>>>> if request.vars.kingdom_name:
>>>>> phylum_select = db(db.tax_phylum.id == 
>>>>> request.vars.kingdom_name).select(db.tax_phylum.ALL)
>>>>> else:
>>>>> phylum_select = db(db.tax_phylum.id == 
>>>>> 1).select(db.tax_phylum.ALL)
>>>>> return dict(kingdoms=kingdoms, phylum_select=phylum_select)
>>>>>
>>>>>
>>>>> def phylum():
>>>>

[web2py] Re: Help with cascading drop down list

2018-02-12 Thread &#x27;Matthew J Watts' via web2py-users
Can anyone point me in the right direction with this, any good tutorial out 
there on how i can integrate java and web2py? 

On Friday, February 9, 2018 at 12:05:32 PM UTC+1, Matthew J Watts wrote:
>
> Thanks for your reponse David!
>
> On Thursday, February 8, 2018 at 8:56:19 PM UTC+1, Dave S wrote:
>>
>>
>>
>> On Thursday, February 8, 2018 at 9:55:25 AM UTC-8, Matthew J Watts wrote:
>>>
>>> Hi community
>>>
>>> I'm having a few problems trying to understand how create a cascading 
>>> drop down list. I've followed this recipe -
>>>
>>>
>>> http://www.web2pyslices.com/slice/show/1526/cascading-drop-down-lists-with-ajax-2
>>>
>>> i've managed to adapt it slightly, but i'm having trouble trying to add 
>>> more tables to the cascade/sequence 
>>>
>>
>> I'm not much of a menu person (I make use of ordinary anchor links for 
>> the most part), but that example was probably written when BootStrap2 was 
>> the css/javascript in use.  Currently,  web2py ships with BootStrap3, which 
>> doesn't support more than 1 level of submenus.  If you use stupid.css (as 
>> in applications/example), you might not have that limitation, but I can't 
>> show you what you want.
>>
>>
>>> It is quite difficult for me (a beginner) to suss out the logic behind it
>>>
>>>
>> Menus typically control what is shown by using javascript to manipulate 
>> CSS.  Simple menus may be CSS only, but then they'd be statically defined.  
>>
>> Good luck!
>>
>> /dps
>>
>>  
>>
>>> So at the moment i have the code below, what i'm trying to do is return 
>>> a list of values from  the "tax_class" table, based  on a selection 
>>> from the "tax_phylum" table( based on sececting an entry  from the 
>>> kingdom table)
>>>
>>> *model*
>>>
>>> db.define_table('tax_kingdom',
>>> Field('name'))
>>>
>>> db.define_table('tax_phylum',
>>> Field('name', 'string'),
>>> Field('kingdom_id'))
>>> db.tax_phylum.kingdom_id.requires = IS_IN_DB(db, db.tax_kingdom.id, 
>>> '%(name)s')
>>>
>>> db.define_table('tax_class',
>>> Field('name', 'string'),
>>> Field('phylum_id'))
>>> db.tax_class.phylum_id.requires = IS_IN_DB(db, db.tax_phylum.id, '%(name)s')
>>>
>>>
>>> *Controller*
>>>
>>> def index():
>>> kingdoms = db().select(db.tax_kingdom.ALL)
>>>
>>> if request.vars.kingdom_name:
>>> phylum_select = db(db.tax_phylum.id == 
>>> request.vars.kingdom_name).select(db.tax_phylum.ALL)
>>> else:
>>> phylum_select = db(db.tax_phylum.id == 1).select(db.tax_phylum.ALL)
>>> return dict(kingdoms=kingdoms, phylum_select=phylum_select)
>>>
>>>
>>> def phylum():
>>> phylums = db(db.tax_phylum.kingdom_id == 
>>> request.vars.kingdom_name).select(db.tax_phylum.ALL)
>>> result = ""
>>> for p in phylums:
>>> result += "" + p.name + 
>>> ""
>>> return XML(result)
>>>
>>>
>>>
>>> *view*
>>>
>>>
>>>
>>> {{extend 'layout.html'}}
>>>
>>> 
>>> >> onchange="jQuery('#kingdom_name').empty();
>>> ajax('phylum', ['kingdom_name'], 'phylum_name');">
>>> {{for kingdom in kingdoms:}}
>>> >> {{=" selected='selected'" if 
>>> str(kingdom.id)==request.vars.kingdom_name else ""}}>
>>> {{=kingdom.name}}
>>> 
>>> {{pass}}
>>> 
>>>
>>>
>>> 
>>> 
>>> {{for phylum in phylum_select:}}
>>> >> {{=XML(" selected='selected'") if 
>>> str(phylum.id)==request.vars.phylum_name else ""}}>
>>> {{=phylum.name}}
>>> {{pass}}
>>> 
>>>
>>>
>>> 
>>>
>>>

-- 
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: Help with cascading drop down list

2018-02-09 Thread &#x27;Matthew J Watts' via web2py-users
Thanks for your reponse David!

On Thursday, February 8, 2018 at 8:56:19 PM UTC+1, Dave S wrote:
>
>
>
> On Thursday, February 8, 2018 at 9:55:25 AM UTC-8, Matthew J Watts wrote:
>>
>> Hi community
>>
>> I'm having a few problems trying to understand how create a cascading 
>> drop down list. I've followed this recipe -
>>
>>
>> http://www.web2pyslices.com/slice/show/1526/cascading-drop-down-lists-with-ajax-2
>>
>> i've managed to adapt it slightly, but i'm having trouble trying to add 
>> more tables to the cascade/sequence 
>>
>
> I'm not much of a menu person (I make use of ordinary anchor links for the 
> most part), but that example was probably written when BootStrap2 was the 
> css/javascript in use.  Currently,  web2py ships with BootStrap3, which 
> doesn't support more than 1 level of submenus.  If you use stupid.css (as 
> in applications/example), you might not have that limitation, but I can't 
> show you what you want.
>
>
>> It is quite difficult for me (a beginner) to suss out the logic behind it
>>
>>
> Menus typically control what is shown by using javascript to manipulate 
> CSS.  Simple menus may be CSS only, but then they'd be statically defined.  
>
> Good luck!
>
> /dps
>
>  
>
>> So at the moment i have the code below, what i'm trying to do is return a 
>> list of values from  the "tax_class" table, based  on a selection from 
>> the "tax_phylum" table( based on sececting an entry  from the kingdom 
>> table)
>>
>> *model*
>>
>> db.define_table('tax_kingdom',
>> Field('name'))
>>
>> db.define_table('tax_phylum',
>> Field('name', 'string'),
>> Field('kingdom_id'))
>> db.tax_phylum.kingdom_id.requires = IS_IN_DB(db, db.tax_kingdom.id, 
>> '%(name)s')
>>
>> db.define_table('tax_class',
>> Field('name', 'string'),
>> Field('phylum_id'))
>> db.tax_class.phylum_id.requires = IS_IN_DB(db, db.tax_phylum.id, '%(name)s')
>>
>>
>> *Controller*
>>
>> def index():
>> kingdoms = db().select(db.tax_kingdom.ALL)
>>
>> if request.vars.kingdom_name:
>> phylum_select = db(db.tax_phylum.id == 
>> request.vars.kingdom_name).select(db.tax_phylum.ALL)
>> else:
>> phylum_select = db(db.tax_phylum.id == 1).select(db.tax_phylum.ALL)
>> return dict(kingdoms=kingdoms, phylum_select=phylum_select)
>>
>>
>> def phylum():
>> phylums = db(db.tax_phylum.kingdom_id == 
>> request.vars.kingdom_name).select(db.tax_phylum.ALL)
>> result = ""
>> for p in phylums:
>> result += "" + p.name + ""
>> return XML(result)
>>
>>
>>
>> *view*
>>
>>
>>
>> {{extend 'layout.html'}}
>>
>> 
>> > onchange="jQuery('#kingdom_name').empty();
>> ajax('phylum', ['kingdom_name'], 'phylum_name');">
>> {{for kingdom in kingdoms:}}
>> > {{=" selected='selected'" if 
>> str(kingdom.id)==request.vars.kingdom_name else ""}}>
>> {{=kingdom.name}}
>> 
>> {{pass}}
>> 
>>
>>
>> 
>> 
>> {{for phylum in phylum_select:}}
>> > {{=XML(" selected='selected'") if 
>> str(phylum.id)==request.vars.phylum_name else ""}}>
>> {{=phylum.name}}
>> {{pass}}
>> 
>>
>>
>> 
>>
>>

-- 
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] Help with cascading drop down list

2018-02-08 Thread &#x27;Matthew J Watts' via web2py-users
Hi community

I'm having a few problems trying to understand how create a cascading drop 
down list. I've followed this tutorial -

http://www.web2pyslices.com/slice/show/1526/cascading-drop-down-lists-with-ajax-2

i've managed to adapt it slightly, but i'm having trouble trying to add 
more tables to the cascade/sequence

It is quite difficult for me (a beginner) to suss out the logic behind it. 

So at the moment i have the code below, what i'm trying to do is return a 
list of values from  the "tax_class" table based selecting results from 
the  "tax_phylum" table

*model*

db.define_table('tax_kingdom',
Field('name'))

db.define_table('tax_phylum',
Field('name', 'string'),
Field('kingdom_id'))
db.tax_phylum.kingdom_id.requires = IS_IN_DB(db, db.tax_kingdom.id, '%(name)s')

db.define_table('tax_class',
Field('name', 'string'),
Field('phylum_id'))
db.tax_class.phylum_id.requires = IS_IN_DB(db, db.tax_phylum.id, '%(name)s')


*Controller*

def index():
kingdoms = db().select(db.tax_kingdom.ALL)

if request.vars.kingdom_name:
phylum_select = db(db.tax_phylum.id == 
request.vars.kingdom_name).select(db.tax_phylum.ALL)
else:
phylum_select = db(db.tax_phylum.id == 1).select(db.tax_phylum.ALL)
return dict(kingdoms=kingdoms, phylum_select=phylum_select)


def phylum():
phylums = db(db.tax_phylum.kingdom_id == 
request.vars.kingdom_name).select(db.tax_phylum.ALL)
result = ""
for p in phylums:
result += "" + p.name + ""
return XML(result)



*view*



{{extend 'layout.html'}}



{{for kingdom in kingdoms:}}

{{=kingdom.name}}

{{pass}}





{{for phylum in phylum_select:}}

{{=phylum.name}}
{{pass}}





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


Re: [web2py] Re: Is Web2py suitable for my project

2017-12-01 Thread &#x27;Matthew J Watts' via web2py-users
great, thanks for your help Leoanal. I will give it a go!

and thanks for your response Eric.

I'll post the results of my work here in case anyone needs it in the future

cheers

Matt

On Sat, Nov 25, 2017 at 4:29 PM, Eric's Gmail  wrote:

> Matt,
>
> Sorry to say that the project never progressed so I can’t help you with
> web2py and Bokeh.
>
> Eric
>
> On Nov 25, 2017, at 5:53 AM, 'Matthew J Watts' via web2py-users <
> web2py@googlegroups.com> wrote:
>
> Hi Eric
>
> Did you end up using web2py for this project?
>
> Like you i'm a Biologist trying to use Web2py by to query, process and
> visualize data, I was wondering if you could show me an example of how you
> integrated Bokeh into web2py
>
> Thanks
>
> Matt
>
>
> On Saturday, January 24, 2015 at 5:23:22 PM UTC+1, Eric wrote:
>>
>> Hi all,
>>
>> I'm new to web2py and have been working my way through the learning
>> materials. I have a specific application and am wondering if web2py is a
>> good choice for a framework or something simpler such as Flask.
>> Specifically I want to create a web application (for an intranet) where a
>> user would upload a data file using the standard browser file dialog, have
>> it analyzed by an algorithm I've written in Python and then responses
>> plotted on the page and also a file of results savable using the browsers
>> standard save file dialog. I know enough Python to handle the file parsing,
>> data analysis and result file generation. I'll need access to Python
>> libraries such as Numpy. I've discovered Bokah (http://bokeh.pydata.org)
>> as an attractive plotting library. They use Flask in their tutorial. I
>> haven't found anything particularly clear about how to invoke the browser
>> file dialogs. Eventually I'd like to use a database to archive the uploaded
>> data files and resulting result files along with other information such as
>> user, date, instrument serial number, etc.
>>
>> Thanks,
>>
>> Eric
>>
>
> --
> 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/moYhW9ydpyA/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/d/optout.
>
>
> --
> 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/moYhW9ydpyA/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/d/optout.
>

-- 
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: Is Web2py suitable for my project

2017-11-25 Thread &#x27;Matthew J Watts' via web2py-users
Hi Eric

Did you end up using web2py for this project?

Like you i'm a Biologist trying to use Web2py by to query, process and 
visualize data, I was wondering if you could show me an example of how you 
integrated Bokeh into web2py

Thanks

Matt


On Saturday, January 24, 2015 at 5:23:22 PM UTC+1, Eric wrote:
>
> Hi all,
>
> I'm new to web2py and have been working my way through the learning 
> materials. I have a specific application and am wondering if web2py is a 
> good choice for a framework or something simpler such as Flask. 
> Specifically I want to create a web application (for an intranet) where a 
> user would upload a data file using the standard browser file dialog, have 
> it analyzed by an algorithm I've written in Python and then responses 
> plotted on the page and also a file of results savable using the browsers 
> standard save file dialog. I know enough Python to handle the file parsing, 
> data analysis and result file generation. I'll need access to Python 
> libraries such as Numpy. I've discovered Bokah (http://bokeh.pydata.org) 
> as an attractive plotting library. They use Flask in their tutorial. I 
> haven't found anything particularly clear about how to invoke the browser 
> file dialogs. Eventually I'd like to use a database to archive the uploaded 
> data files and resulting result files along with other information such as 
> user, date, instrument serial number, etc.
>
> Thanks,
>
> Eric
>

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


Re: [web2py] Re: Update database (multiple tables) with CSV in sequence

2017-10-26 Thread &#x27;Matthew J Watts' via web2py-users
great, thanks for your help Dave. I'll have a go and if i have any luck
will post my code for future reference

On Mon, Oct 23, 2017 at 10:02 PM, Dave S  wrote:

>
>
> On Saturday, October 21, 2017 at 2:25:47 PM UTC-7, Matthew J Watts wrote:
>>
>> Hi all
>>
>> I'm pretty new to web2py and web development in general. I'm really stuck
>> with something and haven't been able to find a tutorial which can help me
>> out etc. I was wondering if some one could point me in the right direction.
>>
>> I have three tables. I want to upload a csv, and update each table in
>> sequence, so a newly generated primary key  can be passed to each
>> successive table.
>>
>> (1)
>> db.define_table('study_info',
>> Field('title'))
>>  One
>> to many relationship
>> (2)
>> db.define_table('',
>>
>> Field('study_info_id', 'reference study_info'),
>> Field('taxon_name', type = 'string',
>> comment='Classification of sample collected'))
>>
>> (3)
>> db.define_table('sample_data',
>>  One to many relationship
>> Field('Core_data_id', 'reference core_data'),
>> Field('value', type = 'double'))
>>
>>
>> So just to clarify , data gets entered into the first table,  the primary
>> key from table 1 is then passed to the foreign key of 2, then same again
>> for 2 to 3.
>>
>> I managed to get the function working to update one table from a csv,
>>  Would i somehow modify this with a for loop to insert one line from the
>> csv at a time?
>>
>> def import_csv():
>> from gluon.sqlhtml import form_factory
>> form = SQLFORM.factory(Field('csvfile','upload',uploadfield=False))
>> if form.process().accepted:
>> db.study_info.import_from_csv_file(request.vars.csvfile.file)
>> redirect(URL('index'))
>> return dict(form=form)
>>
>>
>>
> I see 3 possible ways to go:
>
> Probably the cleanest is to do what import_from_csv_file() does:
>
>  import csv  # it's in the standard Python library,
> csv.reader(mycsvfile, etc)
> # https://docs.python.org/2.7/library/csv.html>
> # for each line in the file:
> lineno, line in enumerate(reader):
>validate line
>new_id = update_or_insert()
># take a look at gluon/packages/dal/pydal/objects.py, lines 911-949
># to see how column headers are handled, etc
>handle_next_table_here(..., new_id,...)
>
> The second way is similar, but puts more burden on you in preparing the
> insert
>
> file = open(mycsvfile)
> while not eof:
>line = readline(file)
>pieces = line.split(",")
>pieces = pieces.cleanup()
># cleanup is a routine you supply to validate the format of the fields
># the split and the cleanup may need to handle different delimiters
> ("csv" may actually be tab-seperated, or space-seperated)
># and if you have what looks like a delimiter in a quoted field, you
> have to deal with that, too.
># but if your csv is controlled enough, you can do this without too
> much trouble.
>new_id = update_or_insert()
>handle_next_table_here(..., new_id,...)
>
> The third choice is easy [1] but ugly, and may be slow:
>
> file1 = open(mycsvflle, "rb")
> while not eof:
>line = files1.readline()
>file2 = open(mytmpfile, "wb")
>file2.write(line)
>file2.close()
>import_from_csv_file(file2)
>newrow = db(query).select().last()
>handle_next_table_here(..., newrow.id,...)
>
>
>
> [1] okay, not dramatically easier than the first 2
>
> Good luck!
>
> /dps
>
> --
> 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/JDVUaWb26ns/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/d/optout.
>

-- 
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] Update database (multiple tables) with CSV in sequence

2017-10-21 Thread &#x27;Matthew J Watts' via web2py-users
Hi all

I'm pretty new to web2py and web development in general. I'm really stuck 
with something and haven't been able to find a tutorial which can help me 
out etc. I was wondering if some one could point me in the right direction. 

I have three tables. I want to upload a csv, and update each table in 
sequence, so a newly generated primary key  can be passed to each 
successive table. 

(1)
db.define_table('study_info',  
Field('title'))
 One to 
many relationship
(2)
db.define_table('core_data',

Field('study_info_id', 'reference study_info'),
Field('taxon_name', type = 'string', 
comment='Classification of sample collected'))

(3)
db.define_table('sample_data',   
 One to many relationship
Field('Core_data_ID', 'reference'),
Field('value', type = 'double'))


So just to clarify , data gets entered into the first table,  the primary 
key from table 1 is then passed to the foreign key of 2, then same again 
for 2 to 3. 

I managed to the function working to update one table from a csv, but tried 
a few things out from there but nothing worked. Would i somehow modify this 
using a for loop?

def import_csv(): 
from gluon.sqlhtml import form_factory
form = SQLFORM.factory(Field('csvfile','upload',uploadfield=False))
if form.process().accepted:
db.study_info.import_from_csv_file(request.vars.csvfile.file)
redirect(URL('index'))
return dict(form=form) 


Thanks in advance

Matt

-- 
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] select_or_add_widget - can't get recipes, tutorials and example app to work

2017-10-12 Thread &#x27;Matthew J Watts' via web2py-users
Hi there, does anyone know how to get this working with the latest version 
of web2py - i can't get it working, not even in the sample app below

https://github.com/mdipierro/web2py-recipes-source/blob/master/apps/05_adding_ajax_effects/web2py.app.select_or_add_widget.w2p

thanks

Matt

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


Re: [web2py] Re: Help - Grid with left joins and sending arguments/variables to other functions

2017-07-21 Thread &#x27;Matthew J Watts' via web2py-users
Ok thanks for your help Jim, i was getting confused - i introudced a bug
into my app but all working fine now i moved all the code to a fresh app

On Fri, Jul 21, 2017 at 3:51 PM, Jim Steil  wrote:

> I'm assuming you're talking about a primary key made up of multiple
> fields.  Is that correct.
>
> I've never done that, but I don't see how it would change anything other
> than the 'left' setup.
>
> -Jim
>
> On Fri, Jul 21, 2017 at 5:54 AM, 'Matthew J Watts' via web2py-users <
> web2py@googlegroups.com> wrote:
>
>>
>> Hi, do you know if this is the same when i use primary keys of legacy
>> tables - doesn't seem to be working when i change my tables to primary key.
>> thanks
>>
>> On Wed, Jul 19, 2017 at 4:10 PM, Jim S  wrote:
>>
>>> We were all there once.  Glad I was able to help.  Part of the beauty of
>>> web2py is the community and the friendly help you can get on this group.
>>>
>>> -Jim
>>>
>>> On Wednesday, July 19, 2017 at 9:26:08 AM UTC-5, Matthew J Watts wrote:
>>>>
>>>> Great thanks Jim, that did it for me - it's hard being a beginner!!
>>>>
>>>> On Wed, Jul 19, 2017 at 2:09 PM, Jim S  wrote:
>>>>
>>>>> I'd start first with changing this:
>>>>>
>>>>> links = [lambda ids: A('Download data set',_href=URL("default","down
>>>>> load_dataset.csv",args=[ids.id]))]
>>>>>
>>>>> to this:
>>>>>
>>>>> links = [lambda ids: A('Download data set',_href=URL("default","down
>>>>> load_dataset.csv",args=[ids.MAIN.id <http://ids.id/>]))]
>>>>>
>>>>> When you add the LEFT join you then need to specify which table to get
>>>>> the field from.
>>>>>
>>>>> -Jim
>>>>>
>>>>>
>>>>> On Wednesday, July 19, 2017 at 6:44:45 AM UTC-5, Matthew J Watts wrote:
>>>>>>
>>>>>> Hi all
>>>>>>
>>>>>> I'm having some problems  trying to achieve the following
>>>>>>
>>>>>> I have a grid with left joins which selects a subset of entries in my
>>>>>> database -(query between 3 tables)
>>>>>>
>>>>>>  i then want to be able to set up links within the grid that sends
>>>>>> the id from each row (MAIN table) to a seperate function (another query
>>>>>> between many tables).
>>>>>>
>>>>>> I then want to trigger a download 'csv' file.
>>>>>>
>>>>>> So far, I have managed to get this working if I use one table in the
>>>>>> grid  (no left joins), however when i set up left joins within the grid,i
>>>>>> get an 'AttributeError' message. Somehow, by setting up the left
>>>>>> joins, i loose the main id that i  want to send to the seperate function 
>>>>>> -
>>>>>> although i have set up  'field_id=db.MAIN.id <http://db.main.id/>'
>>>>>> in the grid
>>>>>>
>>>>>> Here's the code:
>>>>>>
>>>>>> *Controller*
>>>>>>
>>>>>> def vec_dyn_query():
>>>>>> links = [lambda ids: A('Download data
>>>>>> set',_href=URL("default","download_dataset.csv",args=[ids.id]))]
>>>>>> grid = SQLFORM.grid((db.MAIN),
>>>>>> field_id=db.MAIN.id,
>>>>>> left = [db.StudyLocation.on(db.MAIN.LocationID
>>>>>> == db.StudyLocation.id), db.TAXON.on(db.MAIN.TaxonID == db.TAXON.id
>>>>>> )],
>>>>>> links=links,
>>>>>> deletable=False, editable=False,
>>>>>> details=False, selectable=False, create=False, csv=False)
>>>>>> return locals()
>>>>>>
>>>>>> def download_dataset():
>>>>>> main_id = request.args(0,cast=int)
>>>>>> dataset = db(db.MAIN.id == request.args[0]).select()
>>>>>> return dict(dataset=dataset)
>>>>>>
>>>>>> *Views*
>>>>>>
>>>>>> {{
>>>>>> import c

Re: [web2py] Re: Help - Grid with left joins and sending arguments/variables to other functions

2017-07-21 Thread &#x27;Matthew J Watts' via web2py-users
Hi, do you know if this is the same when i use primary keys of legacy
tables - doesn't seem to be working when i change my tables to primary key.
thanks

On Wed, Jul 19, 2017 at 4:10 PM, Jim S  wrote:

> We were all there once.  Glad I was able to help.  Part of the beauty of
> web2py is the community and the friendly help you can get on this group.
>
> -Jim
>
> On Wednesday, July 19, 2017 at 9:26:08 AM UTC-5, Matthew J Watts wrote:
>>
>> Great thanks Jim, that did it for me - it's hard being a beginner!!
>>
>> On Wed, Jul 19, 2017 at 2:09 PM, Jim S  wrote:
>>
>>> I'd start first with changing this:
>>>
>>> links = [lambda ids: A('Download data set',_href=URL("default","down
>>> load_dataset.csv",args=[ids.id]))]
>>>
>>> to this:
>>>
>>> links = [lambda ids: A('Download data set',_href=URL("default","down
>>> load_dataset.csv",args=[ids.MAIN.id <http://ids.id/>]))]
>>>
>>> When you add the LEFT join you then need to specify which table to get
>>> the field from.
>>>
>>> -Jim
>>>
>>>
>>> On Wednesday, July 19, 2017 at 6:44:45 AM UTC-5, Matthew J Watts wrote:
>>>>
>>>> Hi all
>>>>
>>>> I'm having some problems  trying to achieve the following
>>>>
>>>> I have a grid with left joins which selects a subset of entries in my
>>>> database -(query between 3 tables)
>>>>
>>>>  i then want to be able to set up links within the grid that sends the
>>>> id from each row (MAIN table) to a seperate function (another query between
>>>> many tables).
>>>>
>>>> I then want to trigger a download 'csv' file.
>>>>
>>>> So far, I have managed to get this working if I use one table in the
>>>> grid  (no left joins), however when i set up left joins within the grid,i
>>>> get an 'AttributeError' message. Somehow, by setting up the left
>>>> joins, i loose the main id that i  want to send to the seperate function -
>>>> although i have set up  'field_id=db.MAIN.id <http://db.main.id/>' in
>>>> the grid
>>>>
>>>> Here's the code:
>>>>
>>>> *Controller*
>>>>
>>>> def vec_dyn_query():
>>>> links = [lambda ids: A('Download data set',_href=URL("default","down
>>>> load_dataset.csv",args=[ids.id]))]
>>>> grid = SQLFORM.grid((db.MAIN),
>>>> field_id=db.MAIN.id,
>>>> left = [db.StudyLocation.on(db.MAIN.LocationID
>>>> == db.StudyLocation.id), db.TAXON.on(db.MAIN.TaxonID == db.TAXON.id)],
>>>> links=links,
>>>> deletable=False, editable=False, details=False,
>>>> selectable=False, create=False, csv=False)
>>>> return locals()
>>>>
>>>> def download_dataset():
>>>> main_id = request.args(0,cast=int)
>>>> dataset = db(db.MAIN.id == request.args[0]).select()
>>>> return dict(dataset=dataset)
>>>>
>>>> *Views*
>>>>
>>>> {{
>>>> import cStringIO
>>>> stream = cStringIO.StringIO()
>>>> dataset.export_to_csv_file(stream)
>>>> response.headers['Content-Type'] = 'text/csv'
>>>> response.write(stream.getvalue(), escape=False)
>>>> }}
>>>>
>>>> Note - if i take away the 'left = [db.StudyLocation.on(db.MAIN.LocationID
>>>> == db.StudyLocation.id), db.TAXON.on(db.MAIN.TaxonID == db.TAXON.id)],'
>>>> Everything works fine
>>>>
>>>> Thanks for your help in advance
>>>>
>>>> Matt
>>>>
>>> --
>>> 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/to
>>> pic/web2py/pH_iiWr43UI/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to
>>> web2py+un...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> 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/pH_iiWr43UI/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/d/optout.
>

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


Re: [web2py] Re: Help - Grid with left joins and sending arguments/variables to other functions

2017-07-19 Thread &#x27;Matthew J Watts' via web2py-users
Great thanks Jim, that did it for me - it's hard being a beginner!!

On Wed, Jul 19, 2017 at 2:09 PM, Jim S  wrote:

> I'd start first with changing this:
>
> links = [lambda ids: A('Download data set',_href=URL("default","down
> load_dataset.csv",args=[ids.id]))]
>
> to this:
>
> links = [lambda ids: A('Download data set',_href=URL("default","down
> load_dataset.csv",args=[ids.MAIN.id <http://ids.id/>]))]
>
> When you add the LEFT join you then need to specify which table to get the
> field from.
>
> -Jim
>
>
> On Wednesday, July 19, 2017 at 6:44:45 AM UTC-5, Matthew J Watts wrote:
>>
>> Hi all
>>
>> I'm having some problems  trying to achieve the following
>>
>> I have a grid with left joins which selects a subset of entries in my
>> database -(query between 3 tables)
>>
>>  i then want to be able to set up links within the grid that sends the id
>> from each row (MAIN table) to a seperate function (another query between
>> many tables).
>>
>> I then want to trigger a download 'csv' file.
>>
>> So far, I have managed to get this working if I use one table in the grid
>>  (no left joins), however when i set up left joins within the grid,i get an
>> 'AttributeError' message. Somehow, by setting up the left joins, i loose
>> the main id that i  want to send to the seperate function - although i have
>> set up  'field_id=db.MAIN.id <http://db.main.id/>' in the grid
>>
>> Here's the code:
>>
>> *Controller*
>>
>> def vec_dyn_query():
>> links = [lambda ids: A('Download data set',_href=URL("default","down
>> load_dataset.csv",args=[ids.id]))]
>> grid = SQLFORM.grid((db.MAIN),
>> field_id=db.MAIN.id,
>> left = [db.StudyLocation.on(db.MAIN.LocationID
>> == db.StudyLocation.id), db.TAXON.on(db.MAIN.TaxonID == db.TAXON.id)],
>> links=links,
>> deletable=False, editable=False, details=False,
>> selectable=False, create=False, csv=False)
>> return locals()
>>
>> def download_dataset():
>> main_id = request.args(0,cast=int)
>> dataset = db(db.MAIN.id == request.args[0]).select()
>> return dict(dataset=dataset)
>>
>> *Views*
>>
>> {{
>> import cStringIO
>> stream = cStringIO.StringIO()
>> dataset.export_to_csv_file(stream)
>> response.headers['Content-Type'] = 'text/csv'
>> response.write(stream.getvalue(), escape=False)
>> }}
>>
>> Note - if i take away the 'left = [db.StudyLocation.on(db.MAIN.LocationID
>> == db.StudyLocation.id), db.TAXON.on(db.MAIN.TaxonID == db.TAXON.id)],'
>> Everything works fine
>>
>> Thanks for your help in advance
>>
>> Matt
>>
> --
> 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/pH_iiWr43UI/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/d/optout.
>

-- 
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] Help - Grid with left joins and sending arguments/variables to other functions

2017-07-19 Thread &#x27;Matthew J Watts' via web2py-users
Hi all

I'm having some problems  trying to achieve the following  

I have a grid with left joins which selects a subset of entries in my 
database -(query between 3 tables) 

Once i get the desired result, i want to be able to set up links within the 
table that then send the id from each row (MAIN table) to a seperate 
function (another query between many tables). 
 
I then want to trigger a download 'csv' file. 

So far, I have managed to get this working if I use one table in the grid 
 (no left joins), however when i set up left joins within the grid,i get an 
'AttributeError' message. Somehow, by setting up the left joins, i loose 
the main id that i  want to send to the seperate function. 

Here's the code:

*Controller*

def vec_dyn_query():
links = [lambda ids: A('Download data 
set',_href=URL("default","download_dataset.csv",args=[ids.id]))]
grid = SQLFORM.grid((db.MAIN), 
field_id=db.MAIN.id,
left = [db.StudyLocation.on(db.MAIN.LocationID == 
db.StudyLocation.id), db.TAXON.on(db.MAIN.TaxonID == db.TAXON.id)],
links=links,
deletable=False, editable=False, details=False, 
selectable=False, create=False, csv=False)
return locals()

def download_dataset():
main_id = request.args(0,cast=int)
dataset = db(db.MAIN.id == request.args[0]).select()
return dict(dataset=dataset)

*Views*

{{
import cStringIO
stream = cStringIO.StringIO()
dataset.export_to_csv_file(stream)
response.headers['Content-Type'] = 'text/csv'
response.write(stream.getvalue(), escape=False)
}}

Note - if i take away the 'left = [db.StudyLocation.on(db.MAIN.LocationID 
== db.StudyLocation.id), db.TAXON.on(db.MAIN.TaxonID == db.TAXON.id)],' 
Everything works fine

Thanks for your help in advance

Matt

-- 
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: Grid - limit searches to specified fields not whole tables

2017-07-07 Thread &#x27;Matthew J Watts' via web2py-users
Ok thanks Antony i'll look into it, this looks like it could take some 
time!!

On Friday, July 7, 2017 at 2:42:37 PM UTC+2, Matthew J Watts wrote:
>
> Hi all
>
>  
>
> I’m having problems trying to tailor the grid to my needs
>
> I've set up a grid to query my db and it retrieves the data successfully, 
> great!
>
>  
>
> Example: def gridquery():
>
> grid = SQLFORM.grid((db.MAIN.TaxonID == db.TAXON.TaxonID), field_id = 
> db.MAIN.MainID, fields=[db.TAXON.TaxonName, db.TAXON.CommonName, 
> db.TAXON.TaxonomicPhylum])
>
> return locals() 
>
>  
>
> However, the search box contains all of the columns in all of the 
> connected tables.  I want to limit the searches only to the fields i have 
> specified e.g. 'fields=[db.TAXON.TaxonName, db.TAXON.CommonName, 
> db.TAXON.TaxonomicPhylum])'. 
>
>  
>
> 1.  I've tried to do a few things i.e.  setting the unwanted search 
> fields to 'writable = False & readable = False' 
>
> 2.   also tried this method [setattr(f, 'readable', False) for f in 
> mydb if f.name not in ('mydb.field')]
>
>  
>
> However, this limits the query results - i want to include all the tables 
> fields in the query results, just not in the searches. 
>
>  
>
> Does anyone have any suggestions? As I understand I might need to build a 
> custom widget, at my current level this seems rather complicated,is there a 
> simpler work around?. 
>
>  
>
> 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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Grid - limit searches to specified fields not whole tables

2017-07-07 Thread &#x27;Matthew J Watts' via web2py-users


Hi all

 

I’m having problems trying to tailor the grid to my needs 

 

I've set up a grid to query my db and it retrieves the data successfully, 
great!

 

Example: def gridquery():

grid = SQLFORM.grid((db.MAIN.TaxonID == db.TAXON.TaxonID), field_id = 
db.MAIN.MainID, fields=[db.TAXON.TaxonName, db.TAXON.CommonName, 
db.TAXON.TaxonomicPhylum])

return locals() 

 

 

However, the search box contains all of the columns in all of the connected 
tables.  I want to limit the searches only to the fields i have specified 
e.g. 'fields=[db.TAXON.TaxonName, db.TAXON.CommonName, 
db.TAXON.TaxonomicPhylum])'. 

 

1.  I've tried to do a few things i.e.  setting the unwanted search 
fields to 'writable = False & readable = False' 

2.   also tried this method [setattr(f, 'readable', False) for f in 
mydb if f.name not in ('mydb.field')]

 

However, this limits the query results - i want to include all the tables 
fields in the query results, just not in the searches. 

 

Does anyone have any suggestions? As I understand I might need to build a 
custom widget, at my current level this seems rather complicated, are there 
any simpler work arounds. 

 

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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Limit the field to search in sqlgrid?

2017-07-07 Thread &#x27;Matthew J Watts' via web2py-users
I'm trying to do the same, can anyone help? 


On Friday, June 28, 2013 at 3:03:12 AM UTC+2, fun man wrote:
>
> Hi all,
>
> I have a couple tables joined in the sqlform.grid. They both have around 
> 20 fields. I am only displaying around 10~15 fields for a particular 
> purpose. 
>
> When I click on the search widget, it gives me way more option that I need 
> (all the 40 fields to choose from).
>
> Is there a possible way that I could pass a list of "searchable fields" to 
> the search widget?  The current search widget is great, and I hope not to 
> re-create it for only searching for less fields.
>
> Many thanks
> funman
>
> schedule = SQLFORM.grid( query, \
> left=[db.order_item.on(db.order_item.purchase_id == 
> db.purchase.id)],\
> user_signature=True,\
> fields=[db.purchase.id, db.purchase.facility_id, 
> db.purchase.supplier_id, \
> db.purchase.pr, db.purchase.so, 
> db.purchase.quote_ref, db.purchase.funding, \
> db.order_item.product_partnum, db.order_item.status, 
> db.order_item.quantity, db.order_item.qtdqtyship, \
> db.order_item.schedule_shipdate, 
> db.order_item.hold_info, 
> ],\
> exportclasses=dict(csv_with_hidden_cols=False,xml=False, 
> html=False, tsv_with_hidden_cols=False, tsv=False, json=False),\
> showbuttontext=False, create=False, editable= False, 
> deletable = False, details=False,searchable = True,
> )
>
>
>

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


Re: [web2py] Re: SQLFORM.grid with selectable checkboxes that export CSV files on submit

2017-07-07 Thread &#x27;Matthew J Watts' via web2py-users
thanks Peter, as for the grid i'm currently  trying to work out how to 
customize it, but yes i think the  "buttons_placement = 'right' " puts the 
buttons on the right

On Wednesday, July 5, 2017 at 4:39:17 AM UTC+2, Peter wrote:
>
>
> Glad you got something out of it Matt!
>
> I decided to try and follow it through to the end but couldn't.  (I did 
> get the grid check-boxes working but only if I selected just one report at 
> a time).
>
> Your solution with the links is more user friendly (one click generates 
> the report) if you haven't thought of it... using right click on the link 
> might be a good 
> option (keeps the reports list in its own tab for subsequent requests) 
>
> In my case selecting multiple reports doesn't work, probably because 
> control passes to the first report_function and the calling function is 
> simply 
> dropped so the loop in the calling function doesn't continue to any 
> subsequent request)
>
> I would be interested to hear if "buttons_placement = 'right' " does what 
> I think it is is supposed to...
> Did the check-boxes, in your initial coding, appear on right?
>
> I would be happy to hear from more advance users if it is possible to 
> chain a sequence of reports outputting to csv files with user interaction 
> i.e. when first dialogue is dealt with the second one pops up or multiple 
> dialogues appear at the same time..) 
>
> Regards
> Peter
>
>
>   
>

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


Re: [web2py] Re: SQLFORM.grid with selectable checkboxes that export CSV files on submit

2017-07-04 Thread &#x27;Matthew J Watts' via web2py-users
Thanks Peter - that was very helpful indeed. I didn't manage to get a
'download to CSV from checkboxes' function working, don't quite get why
as i managed to set up a  'download links from rows ' function in the
SQLFORM.grid.

Here is  the code for you just in case it is any help for you in the future

*##So in models I have my Db*

db.define_table('animal',
Field('species'),
Field('genus'),
Field('family'))


*##in controllers - default i have the following*

links = [lambda row: A('Download data
set',_href=URL("default","download_animal_dataset",args=[row.id]))]

def animal_data():
db.animal.id.readable = False
animals = SQLFORM.grid(db.animal, links = links,deletable=False,
editable=False, details=False, selectable=False, create=False, csv=False,
buttons_placement = 'right')
return locals()

def download_animal_dataset():
animal_id = request.args(0,cast=int)
animals = db(db.animal.id == request.vars[0]).select()
return dict(animals=animals)


*## and then in the view i have default/download_animal_dataset.html*

{{
import cStringIO
stream = cStringIO.StringIO()
animals.export_to_csv_file(stream)
response.headers['Content-Type'] = 'application/vnd.ms-excel'
response.headers['Content-Disposition'] = 'attachment; filename="%s"' %
your_file_name
response.write(stream.getvalue(), escape=False)
}}


cheers

matt





On Tue, Jul 4, 2017 at 7:04 PM, Peter  wrote:

>
>
> Based on previous code, the companies query/function would look something
> like...
>
>
> def csv_companies():
> # assumes there is a table called 'company'with field 'name'
> query = db.company.id > 0
> companies = db(query).select(db.company.id,
>   db.company.name,
>   # ...
>   # the list of 'company' fields you want in your query
>   # you can join other tables and include fields from
> them here as well
>   # ...
>  )
>
> return dict(companies=companies)
>
>
>
>
>
> The view (csv_companies.html) would be something like...
>
> {{
> import cStringIO
> stream = cStringIO.StringIO()
> companies.export_to_csv_file(stream)
> response.headers['Content-Type'] = 'application/vnd.ms-excel'
> response.headers['Content-Disposition'] = 'attachment; filename="%s"'
> % your_file_name
> response.write(stream.getvalue(), escape=False)
> }}
>
>
> Note it doesn't have
>
> {{extend 'layout.html'}}
>
> as it pushes the output to a user dialogue asking if they want to
> open/save it somewhere on their machine.
> (You may want to do something different like simply write it to a
> directory or create a db entry referencing it...)
>
>
>
> --
> 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/UiCqbO9nnDw/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/d/optout.
>

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


Re: [web2py] Re: SQLFORM.grid with selectable checkboxes that export CSV files on submit

2017-07-04 Thread &#x27;Matthew J Watts' via web2py-users
thanks for your help Peter!

Actually, i've been playing around with it but  need some into on
the functions/views too!

 'The report_functions should point to valid report functions/views
that you have created (I can provide some info on this if needed)'




On Tue, Jul 4, 2017 at 4:37 AM, Peter  wrote:

>
> Hi Matt,
>
> I'm no expert (only discovered the wonders of the grid in the last couple
> of weeks) and maybe others
> will have a better way but I have tested this and it might get you going...
>
> (Also you might want to give a little more information on the
> requirements...
> Where have you got to?
> Do the reports require further interaction/parameters when selected?
> Have you developed the reports themselves?)
>
> # So as far as I understand it, the grid requires a table (or possibly a
> dummy table? I went with a real one)
>
> db.define_table('reports',
> Field('report_name',),
> Field('report_function',)
> )
>
> and added two records...
> 1, Activities Report, csv_activities
> 2, Companies Report, csv_companies
>
>
> The report_functions should point to valid report functions/views
> that you have created (I can provide some info on this if needed)
>
>
> def output_reports():
> print "output reports: received vars %s" % request.vars
> for record_id in request.vars.id:
> print "run report %s" % db.reports[record_id].report_function
> redirect(URL('report_factory',[]))
>
>
> def report_factory():
> query = db.reports.id > 0
> fields = (db.reports.id, db.reports.report_name)
> grid = SQLFORM.grid(query,
> field_id= db.reports.id,
> fields=fields,
> searchable=False,
> create=False,
> selectable=lambda ids: redirect(URL('default',
> 'output_reports', vars=dict(id=ids))),
> editable=False,
> deletable=False,
> details=False,
> buttons_placement='right',
> csv=False
> )
>
> return dict(grid=grid)
>
>
>
> The print output below shows what is happening and simulates 'running
> report/s'
> after selecting each report separately and then the two together
>
>
> output reports: received vars 
> run report csv_activities
>
> output reports: received vars 
> run report csv_companies
>
> output reports: received vars 
> run report csv_activities
> run report csv_companies
>
>
> Hope this helps!
> Peter
>
> --
> 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/UiCqbO9nnDw/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/d/optout.
>

-- 
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] SQLFORM.grid with selectable checkboxes that export CSV files on submit

2017-06-29 Thread &#x27;Matthew J Watts' via web2py-users
Hi all

 I'm trying to modify an SQLFORM.grid so it has selectable check boxes, 
 which allow the user to download selected queries as CSV files once the 
submit button has been clicked. 

Can anyone help me with this?

Thanks in advance

Matt

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


Re: [web2py] Re: Editing an SQLFORM.grid - use check boxes to select downloads.

2017-05-23 Thread &#x27;Matthew J Watts' via web2py-users
Ok great thanks , i will check it out

On Tue, May 23, 2017 at 1:53 AM, 黄祥  wrote:

> i think you can use widget to show checkbox : SQLFORM.widgets.checkboxes.
> widget
> ref:
> http://web2py.com/books/default/chapter/29/07/forms-and-validators#Widgets
> and use record representation for download
> ref:
> http://web2py.com/books/default/chapter/29/06/the-
> database-abstraction-layer#format--Record-representation
>
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/web2py/94Alk9NOJhU/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/d/optout.
>

-- 
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] Editing an SQLFORM.grid - use check boxes to select downloads.

2017-05-22 Thread &#x27;Matthew J Watts' via web2py-users
Hi all
 
I'm new to web2py and i'm stuck on the following issue. 

I am trying to Edit an SQLFORM.grid so that  I can use the check boxes 
(selectable) to select which rows to download.   

Can anyone give me a few pointers on this. 

Thanks

Matt

-- 
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: exporting selected rows from a grid

2017-05-22 Thread &#x27;Matthew J Watts' via web2py-users
hello, did you ever find a better solution for this?
 I want to do the same thing

On Monday, September 30, 2013 at 11:33:57 AM UTC+2, step wrote:
>
> I want to use SQLFORM.grid with selectable checkboxes to serve a custom 
> export function. Unlike web2py's default exportformats manager, which 
> triggers each exporter function to an  tag, I want my exporter to 
> trigger when the user clicks the form submit button. So the user flow 
> involves ticking some grid row checkboxes, clicking submit, getting a Save 
> As dialog, and finally saving the downloaded export data as a local file.
>
> controller:
> def export_rows(selected_ids):
> def export():
> ret = []
> rows = db(db.mytable.id.belongs(selected_ids).select()
> for row in rows:
> ret.append('%s\r\n' % myformatter(row))
> return ret
>
>
> fileext = 'tab'
> content_type = "text/tab-separated-values"
> filename = '.'.join(('test', file_ext))
> response.headers['Content-Type'] = content_type
> response.headers['Content-Disposition'] = \
> 'attachment;filename=' + filename + ';'
> raise HTTP(200, export(), **response.headers)
>
>
> return dict(grid = SQLFORM.grid(db.mytable, selectable=export_rows))
>
>
> The above code works to export the rows according to the user flow. 
> However, web2py.js disables the submit button when the user clicks it and 
> the button is never re-enabled, because raise HTTP transfers control away 
> from the page and back to web2py, so the page is never refreshed.
> How to re-enable the submit button, or not disable it to begin with? 
> TIA
>
>

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


Re: [web2py] Re: Help with building query functions in a web app - links to tutorials etc

2017-05-04 Thread &#x27;Matthew J Watts' via web2py-users
Thanks Marlysson. I'm just going through that chapter now. What i really
need to know is how I can trigger queries through various drop down boxes.
For example, for one query, i need to create a cascading drop box that can
select data sets at different taxonomic levels (animal kingdoms, family,
species etc).

On Tue, May 2, 2017 at 12:21 PM, Marlysson Silva 
wrote:

> There are the documentarion in section of DAL to declare and handle your
> data ..
>
> http://web2py.com/books/default/chapter/29/06/the-
> database-abstraction-layer
>
> Basically you using the define_table and queries dal..
>
> What you already done?
>
> Em sábado, 29 de abril de 2017 14:09:13 UTC-3, Matthew J Watts escreveu:
>>
>> Hi there everyone!
>>
>> I'm new to Web2py, i'm really enjoying using the framework so far.
>>
>> I am trying to rebuild a legacy database.
>>
>> I want to produce a web app that can query data from multiple tables
>> using drop down boxes e.g. locations, species etc.. I want to be able to
>> select info using drop down boxes,  Then i want to display the result and
>> get the option to download them.
>>
>> Could someone please point me in the right direction in regards to a
>> tutorials and methods
>>
>> Thanks
>>
>> matt
>>
> --
> 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/8WWiltvulgw/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/d/optout.
>

-- 
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] Help with building query functions in a web app - links to tutorials etc

2017-04-29 Thread &#x27;Matthew J Watts' via web2py-users
Hi there everyone!

I'm new to Web2py, i'm really enjoying using the framework so far. 

I am trying to rebuild a legacy database. 

I want to produce a web app that can query data from multiple tables using 
drop down boxes e.g. locations, species etc.. I want to be able to select 
info using drop down boxes,  Then i want to display the result and get the 
option to download them. 

Could someone please point me in the right direction in regards to a 
tutorial 

Thanks

matt

-- 
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: Resetting the database

2017-04-16 Thread &#x27;Matthew J Watts' via web2py-users
I had to log out of my webapp before deleting the database data, otherwise 
i would get an error message

cheers

On Monday, November 14, 2011 at 1:38:15 AM UTC+1, Archibald Linx wrote:
>
> Dear Web2py users, 
>
> How can I reset the database of my Web2py project ? 
>
> Thanks, 
> Archibald

-- 
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: web2py 2.6.1 is OUT - IMPORTANT READ

2013-09-17 Thread Matthew Spence
Hi Massimo-

I took a look in gluon/tools.py as you recommended, and I do not see class 
Config! So I'm not sure why that might be. 

Could it be that the command line updating (unzipping web2py_src) works 
fine, but the GUI-based button updater on the admin interface halts partway 
through or something?

Thanks, -Matt

On Saturday, September 14, 2013 10:02:46 PM UTC-4, Massimo Di Pierro wrote:
>
> This is the error in the ticket you posted:
>
> Traceback (most recent call last):\n  File 
> "/home/mattspence/web2py/gluon/restricted.py", line 212, in restricted\n   
>  exec ccode in environment\n  File 
> "/home/mattspence/web2py/applications/admin/controllers/default.py", line 
> 14, in \nfrom gluon.tools import Config\nImportError: cannot 
> import name Config
>
> You can see in 
> /home/mattspence/web2py/applications/admin/controllers/default.py 
> line
> from gluon.tools import Config
> Now check if gluon/tools.py contains class Config. I know it is there in 
> 2.6.1 and 2.6.2.
>
> The issue is if PythonAnywhere reloading failing? Or is there a path issue 
> and it is looking at the wrong gluon/tools.py somewhere else?
>
>
> On Saturday, 14 September 2013 18:55:08 UTC-5, Matthew Spence wrote:
>>
>> Hi guys-
>>
>> I just tried a fresh install of web2py on PythonAnywhere. (So, only the 
>> "stock" applications of welcome, admin, and examples.) It auto-installs 
>> with 2.5.1, so I hit the button to upgrade to 2.6.2. It looks like it 
>> starts to install, but then I get "Internal Error" again. I pasted the 
>> error message here: http://pastebin.com/uABGmGgV
>>
>> Thanks!!
>>
>> On Thursday, September 12, 2013 6:27:37 PM UTC-4, Massimo Di Pierro wrote:
>>>
>>> Web2py 2.6.1 is finally OUT. It needs some more testing.
>>>
>>> READ BELOW BEFORE UPGRADING
>>>
>>>  Attention all users: For pre 2.6 applications to work with web2py 
>>> >=2.6, you must copy static/js/web2py.js, controllers/appadmin.py, and 
>>> views/appadmin.html from the welcome app to your own apps (all of them).
>>>
>>>  Attention production users: The updated handlers and examples are 
>>> in handlers/ and examples/. The updated ones will not override the existing 
>>> ones. To use the new ones it is not sufficient to upgrade web2py, you also 
>>> need to copy the desired handler/example in the root web2py/ folder.
>>>
>>>  Attention MySQL users: The length of string fields changed from 255 
>>> to 512 bytes. If you have migrations enabled this will trigger a large 
>>> migration. To prevent it, first set migrate_enabled=False, upgrade, check 
>>> everything is ok, then add length=255 to your string Fields, then re-enable 
>>> migrations with migrate_enabled=True if needed.
>>>
>>> - better directory structure: handlers/ extras/ examples/
>>> - better MongoDb support, thanks Alan
>>> - better Admin editor interface, thanks Paolo, Roberto (codemirror 3), 
>>> and Lightdot
>>> - better layout.html and web2py_bootstrap.css, thanks Paolo
>>> - refactored web2py.js makes code more readable, thanks Niphlod
>>> - compute fields can depend on other compute(d) fields
>>> - more functions in appadmin (/manage/auth), thanks Anthony
>>> - support for CAST in SQL generation
>>> - new API jQuery('#component').reload()
>>> - new API rows.render()
>>> - new API table.field.referent, table._references
>>> - new API db(...).validate_and_update(...)
>>> - new API Wiki(..., force_render=True) renders the page source again 
>>> instead of using cached
>>> - Wiki now automatically parses named component arguments 
>>> @{f:a=1,b='twp',c=variable}
>>> - auth.get_or_create_user(login=False)
>>> - auth = Auth(crsf_protection = False) prevents creating sessions in 
>>> login/register forms.
>>> - enable multiple renderers in wiki, thanks Alan
>>> - log messages from Auth are no longer translated (for speed and 
>>> readability)
>>> - update jQuery mobile to 1.3.1
>>> - reduced memory footprint by conditionally loading Tk
>>> - faster pbkdf2 uses OpenSSL, thanks Michele
>>> - many speed improvements, thanks Michele
>>> - better session logic, prevents false positive when detecting session 
>>> changes.
>>> - scripts/import_static.py converts a static site to a web2py app 
>>> (experimental)
>>> - support for new http error code 451
>>> - profiler saves dump in dir, thanks Niphlod

[web2py] Re: web2py 2.6.1 is OUT - IMPORTANT READ

2013-09-14 Thread Matthew Spence
Hey Massimo, I tried reloading all of my domains multiple times, and it 
still throws the same error, even with a stock, automatic fresh install of 
web2py from PA.

On Saturday, September 14, 2013 8:34:18 PM UTC-4, Massimo Di Pierro wrote:
>
> I believe the problem is that the pythonanywhere process has not 
> restarted. Your are still running the old one with the new applications, 
> the new applications expect the new modules, but find the old ones in 
> memory. 
>
> To fix the problem: In the Dashboard click on [web] and press the button 
> [Reload ]. If you have multiple domains you must do it for 
> every domain. 
>
> Massimo
>
>
> On Saturday, 14 September 2013 18:55:08 UTC-5, Matthew Spence wrote:
>>
>> Hi guys-
>>
>> I just tried a fresh install of web2py on PythonAnywhere. (So, only the 
>> "stock" applications of welcome, admin, and examples.) It auto-installs 
>> with 2.5.1, so I hit the button to upgrade to 2.6.2. It looks like it 
>> starts to install, but then I get "Internal Error" again. I pasted the 
>> error message here: http://pastebin.com/uABGmGgV
>>
>> Thanks!!
>>
>> On Thursday, September 12, 2013 6:27:37 PM UTC-4, Massimo Di Pierro wrote:
>>>
>>> Web2py 2.6.1 is finally OUT. It needs some more testing.
>>>
>>> READ BELOW BEFORE UPGRADING
>>>
>>>  Attention all users: For pre 2.6 applications to work with web2py 
>>> >=2.6, you must copy static/js/web2py.js, controllers/appadmin.py, and 
>>> views/appadmin.html from the welcome app to your own apps (all of them).
>>>
>>>  Attention production users: The updated handlers and examples are 
>>> in handlers/ and examples/. The updated ones will not override the existing 
>>> ones. To use the new ones it is not sufficient to upgrade web2py, you also 
>>> need to copy the desired handler/example in the root web2py/ folder.
>>>
>>>  Attention MySQL users: The length of string fields changed from 255 
>>> to 512 bytes. If you have migrations enabled this will trigger a large 
>>> migration. To prevent it, first set migrate_enabled=False, upgrade, check 
>>> everything is ok, then add length=255 to your string Fields, then re-enable 
>>> migrations with migrate_enabled=True if needed.
>>>
>>> - better directory structure: handlers/ extras/ examples/
>>> - better MongoDb support, thanks Alan
>>> - better Admin editor interface, thanks Paolo, Roberto (codemirror 3), 
>>> and Lightdot
>>> - better layout.html and web2py_bootstrap.css, thanks Paolo
>>> - refactored web2py.js makes code more readable, thanks Niphlod
>>> - compute fields can depend on other compute(d) fields
>>> - more functions in appadmin (/manage/auth), thanks Anthony
>>> - support for CAST in SQL generation
>>> - new API jQuery('#component').reload()
>>> - new API rows.render()
>>> - new API table.field.referent, table._references
>>> - new API db(...).validate_and_update(...)
>>> - new API Wiki(..., force_render=True) renders the page source again 
>>> instead of using cached
>>> - Wiki now automatically parses named component arguments 
>>> @{f:a=1,b='twp',c=variable}
>>> - auth.get_or_create_user(login=False)
>>> - auth = Auth(crsf_protection = False) prevents creating sessions in 
>>> login/register forms.
>>> - enable multiple renderers in wiki, thanks Alan
>>> - log messages from Auth are no longer translated (for speed and 
>>> readability)
>>> - update jQuery mobile to 1.3.1
>>> - reduced memory footprint by conditionally loading Tk
>>> - faster pbkdf2 uses OpenSSL, thanks Michele
>>> - many speed improvements, thanks Michele
>>> - better session logic, prevents false positive when detecting session 
>>> changes.
>>> - scripts/import_static.py converts a static site to a web2py app 
>>> (experimental)
>>> - support for new http error code 451
>>> - profiler saves dump in dir, thanks Niphlod
>>> - upgraded pyfpdf, thanks Mariano
>>> - gluon/contrib/pdfinvoice.py for generating PDF invoices (assumes 
>>> reportlab)
>>> - no more double submission of forms (even without crsf protection), 
>>> thanks Niphlod
>>> - speedup for define_table, thanks Michele
>>> - settings.cfg to admin, thanks Paolo
>>> - many bugs fixed, thanks Niphlod, Michele, Roberto, Jonathan, and many 
>>> others
>>>
>>

-- 
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 2.6.1 is OUT - IMPORTANT READ

2013-09-14 Thread Matthew Spence
Hi guys-

I just tried a fresh install of web2py on PythonAnywhere. (So, only the 
"stock" applications of welcome, admin, and examples.) It auto-installs 
with 2.5.1, so I hit the button to upgrade to 2.6.2. It looks like it 
starts to install, but then I get "Internal Error" again. I pasted the 
error message here: http://pastebin.com/uABGmGgV

Thanks!!

On Thursday, September 12, 2013 6:27:37 PM UTC-4, Massimo Di Pierro wrote:
>
> Web2py 2.6.1 is finally OUT. It needs some more testing.
>
> READ BELOW BEFORE UPGRADING
>
>  Attention all users: For pre 2.6 applications to work with web2py 
> >=2.6, you must copy static/js/web2py.js, controllers/appadmin.py, and 
> views/appadmin.html from the welcome app to your own apps (all of them).
>
>  Attention production users: The updated handlers and examples are in 
> handlers/ and examples/. The updated ones will not override the existing 
> ones. To use the new ones it is not sufficient to upgrade web2py, you also 
> need to copy the desired handler/example in the root web2py/ folder.
>
>  Attention MySQL users: The length of string fields changed from 255 
> to 512 bytes. If you have migrations enabled this will trigger a large 
> migration. To prevent it, first set migrate_enabled=False, upgrade, check 
> everything is ok, then add length=255 to your string Fields, then re-enable 
> migrations with migrate_enabled=True if needed.
>
> - better directory structure: handlers/ extras/ examples/
> - better MongoDb support, thanks Alan
> - better Admin editor interface, thanks Paolo, Roberto (codemirror 3), and 
> Lightdot
> - better layout.html and web2py_bootstrap.css, thanks Paolo
> - refactored web2py.js makes code more readable, thanks Niphlod
> - compute fields can depend on other compute(d) fields
> - more functions in appadmin (/manage/auth), thanks Anthony
> - support for CAST in SQL generation
> - new API jQuery('#component').reload()
> - new API rows.render()
> - new API table.field.referent, table._references
> - new API db(...).validate_and_update(...)
> - new API Wiki(..., force_render=True) renders the page source again 
> instead of using cached
> - Wiki now automatically parses named component arguments 
> @{f:a=1,b='twp',c=variable}
> - auth.get_or_create_user(login=False)
> - auth = Auth(crsf_protection = False) prevents creating sessions in 
> login/register forms.
> - enable multiple renderers in wiki, thanks Alan
> - log messages from Auth are no longer translated (for speed and 
> readability)
> - update jQuery mobile to 1.3.1
> - reduced memory footprint by conditionally loading Tk
> - faster pbkdf2 uses OpenSSL, thanks Michele
> - many speed improvements, thanks Michele
> - better session logic, prevents false positive when detecting session 
> changes.
> - scripts/import_static.py converts a static site to a web2py app 
> (experimental)
> - support for new http error code 451
> - profiler saves dump in dir, thanks Niphlod
> - upgraded pyfpdf, thanks Mariano
> - gluon/contrib/pdfinvoice.py for generating PDF invoices (assumes 
> reportlab)
> - no more double submission of forms (even without crsf protection), 
> thanks Niphlod
> - speedup for define_table, thanks Michele
> - settings.cfg to admin, thanks Paolo
> - many bugs fixed, thanks Niphlod, Michele, Roberto, Jonathan, and many 
> others
>

-- 
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: web2py 2.6.1 is OUT - IMPORTANT READ

2013-09-14 Thread Matthew Spence
Hi Massimo-

I took a look through the error file and I suspect the relevant line is:

from gluon.tools import Config\nImportError: cannot import name Config\n'

Let me know if you want the whole error file. 

Thanks!
-Matt

On Sep 14, 2013, at 9:14 AM, Massimo Di Pierro  
wrote:

> I need to see one of these tickets. I suspect the problem is that in 2.6.1 
> one admin file was missing but it is now in 2.6.2. In pythonanywhere you have 
> a web based shell. You can just do:
> 
> cd ~
> wget http://web2py.com/examples/static/web2py_src.zip
> unzip web2py_src.zip
> 
> and the problem should go away.
> 
> Massimo
> 
> On Saturday, 14 September 2013 02:05:41 UTC-5, 黄祥 wrote:
>> 
>> sorry for my previous email, i've paste the wrong error. this is the error i 
>> got after upgrade :
>> 
>> Internal error
>> 
>> Ticket issued: 
>> admin/139.192.164.192.2013-09-14.07-00-36.1c5f90cc-b8dd-4104-9b5c-0febff88170a
>> 
>> even after reload, delete and create webapps still got the old version 
>> (2.5.2), then during upgrade process (click the upgrade from the admin menu) 
>> the error message above is appear.
>> is there any steps i missed during upgrade on pythonanywhere?
>> 
>> 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 a topic in the Google 
> Groups "web2py-users" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/web2py/dUX6XAID7Ks/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.


[web2py] Re: web2py 2.6.1 is OUT - IMPORTANT READ

2013-09-13 Thread Matthew Spence
Hi all-

I'm very excited about the upgrade. I'm deployed on PythonAnywhere, and 
when I clicked on the button to "upgrade now to Version 2.6.1", it looks 
like it downloads, but then suddenly I get "Internal error. Ticket issued 
admin/" and now my admin interface does not work. (The site still 
works, though, and so does appadmin  -- but no main admin interface.)

I went in to PythonAnywhere's filesystem and changed the files as the 
changelog requested (copying static/js/web2py.js, controllers/appadmin.py, 
and views/appadmin.html from the welcome app to my apps), and I tried 
reloading the site after making those changes, but I still have the problem.

Any help would be much appreciated! Thanks!!

-Matt

On Thursday, September 12, 2013 6:27:37 PM UTC-4, Massimo Di Pierro wrote:
>
> Web2py 2.6.1 is finally OUT. It needs some more testing.
>
> READ BELOW BEFORE UPGRADING
>
>  Attention all users: For pre 2.6 applications to work with web2py 
> >=2.6, you must copy static/js/web2py.js, controllers/appadmin.py, and 
> views/appadmin.html from the welcome app to your own apps (all of them).
>
>  Attention production users: The updated handlers and examples are in 
> handlers/ and examples/. The updated ones will not override the existing 
> ones. To use the new ones it is not sufficient to upgrade web2py, you also 
> need to copy the desired handler/example in the root web2py/ folder.
>
>  Attention MySQL users: The length of string fields changed from 255 
> to 512 bytes. If you have migrations enabled this will trigger a large 
> migration. To prevent it, first set migrate_enabled=False, upgrade, check 
> everything is ok, then add length=255 to your string Fields, then re-enable 
> migrations with migrate_enabled=True if needed.
>
> - better directory structure: handlers/ extras/ examples/
> - better MongoDb support, thanks Alan
> - better Admin editor interface, thanks Paolo, Roberto (codemirror 3), and 
> Lightdot
> - better layout.html and web2py_bootstrap.css, thanks Paolo
> - refactored web2py.js makes code more readable, thanks Niphlod
> - compute fields can depend on other compute(d) fields
> - more functions in appadmin (/manage/auth), thanks Anthony
> - support for CAST in SQL generation
> - new API jQuery('#component').reload()
> - new API rows.render()
> - new API table.field.referent, table._references
> - new API db(...).validate_and_update(...)
> - new API Wiki(..., force_render=True) renders the page source again 
> instead of using cached
> - Wiki now automatically parses named component arguments 
> @{f:a=1,b='twp',c=variable}
> - auth.get_or_create_user(login=False)
> - auth = Auth(crsf_protection = False) prevents creating sessions in 
> login/register forms.
> - enable multiple renderers in wiki, thanks Alan
> - log messages from Auth are no longer translated (for speed and 
> readability)
> - update jQuery mobile to 1.3.1
> - reduced memory footprint by conditionally loading Tk
> - faster pbkdf2 uses OpenSSL, thanks Michele
> - many speed improvements, thanks Michele
> - better session logic, prevents false positive when detecting session 
> changes.
> - scripts/import_static.py converts a static site to a web2py app 
> (experimental)
> - support for new http error code 451
> - profiler saves dump in dir, thanks Niphlod
> - upgraded pyfpdf, thanks Mariano
> - gluon/contrib/pdfinvoice.py for generating PDF invoices (assumes 
> reportlab)
> - no more double submission of forms (even without crsf protection), 
> thanks Niphlod
> - speedup for define_table, thanks Michele
> - settings.cfg to admin, thanks Paolo
> - many bugs fixed, thanks Niphlod, Michele, Roberto, Jonathan, and many 
> others
>

-- 
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: alternates to pyjamas/pyjs?

2012-10-04 Thread matthew lange
Please do shae--i have issues myself.

On Wednesday, May 30, 2012 11:37:05 AM UTC-7, stefaan wrote:
>
>
> > solved some of the issues...time to get crackin'! 
> > 
> Glad to hear it :) 
>
> I have found the "inspect element" tool in chromium to be very valuable 
> in diagnosing trouble with my application. 
>
>
>

-- 





[web2py] Re: Question about Human-readable forms + REST CRUD APIs.

2012-08-16 Thread Matthew Wood
I'v been fiddling with these ideas.  They are very similar to the 
flask/sqlalchemy solutions I've seen in my other queries.  Thanks a ton for 
the suggestions.  This is a pretty nice community.

On Sunday, July 29, 2012 11:16:53 PM UTC-6, Anthony wrote:
>
>  - if you define your models carefully with requires parameters 
>> (validators) in web2py, the SQLFORM object will use them, and you can 
>> trigger the use of those validators via your REST API (i forget the exact 
>> call, but there is something that does validation and insert/update in the 
>> recent releases of web2py)
>
>
> db.mytable.validate_and_insert(...)
> db.mytable.validate_and_update(...)
>
> Those methods will run all the validators defined for the table fields 
> before doing the insert/update.
>
> Anthony
>

-- 





[web2py] Re: Question about Human-readable forms + REST CRUD APIs.

2012-08-16 Thread Matthew Wood
"If you have any advice".  :-)
I most certainly don't!  I wish I had enough experience to really get in on 
this conversation.

Your ajax solution seems pretty doable, but you're absolutely correct that 
it would require javascript at all times.


For what it's worth, the suggestions from the flask team seem to be 
similar.  So...  I think I'll just have to live with the 
two independent code streams.

That said, I really like web2py thus far.  There's still a bunch of magic 
I'm trying to unlock, but damn is this an easy to learn platform!


On Saturday, July 28, 2012 9:32:35 PM UTC-6, Massimo Di Pierro wrote:
>
> This is an excellent point.
>
> The closest we came to what you asked is the crud object. If a page 
> contains a single crud form and if the page is called with the json 
> extension, it reads the form variable from ?json. This allows one to 
> interact with the Crud object (create,read, update, delete) using html and 
> or rest-like approach.
> I say rest-like because it is not really restful. This is because we do 
> not use PUT and DELETE for Crud.
>
> Anyway, we are considering deprecating Crud because nobody used it this 
> way.
>
> The problem is that html forms and rest services are very different. html 
> forms assume a state (for preventing crsf, for checking permissions, etc.) 
> while rest services are not supposed to. One html page (one url) can 
> contain more crud elements while a restful URL deals with only one service 
> at the time. Html pages do not use PUT and DELETE (unless doing ajax) while 
> rest services do. Usually information in html and rest services is filtered 
> differently.
>
> Therefore we have developed different APIs for forms (SQLFORM, FORM) and 
> rest (@request.restful()).
>
> The only way to build a uniform APIs would be to have html forms and pages 
> get all their data via Ajax restful calls. Yet many users do not 
> want functional parts of their web site depending on JavaScript.
>
> In my view there is no simple solution to this problem and it is easier to 
> actually implement html forms and rest services separately. If you have any 
> advice on how to built a better system, I would like to hear your ideas. It 
> could help make web2py better.
>
> massimo
>
>
>
>
>
>
>
> On Saturday, 28 July 2012 21:41:34 UTC-5, Matthew Wood wrote:
>>
>> A quick question about basic CRUD for both humans (basic HTML) and 
>> computers
>> (REST)
>>
>> I'm trying to pick a solid python framework for a project at work.  We 
>> have a
>> lot of situations where we need to expose datbase tables for data CRUD.
>>
>> I'm trying to pick between Flask and Web2py at this time, but I've got a
>> specific need that I'm not sure is solved by either framework.
>>
>> Obviously for human consumption, I'll be using some sort of form-library 
>> that
>> will read the table-schema auto-create the form for me.  (Built in with 
>> Web2py,
>> WTForms + SQL-Alchemy for Flask.)  For the REST interfaces, I'll use a 
>> similar
>> library (Built in with Web2py, flask-rest for flask).
>>
>> What I'd REALLY like, is to have both the REST interfaces and html-forms 
>> use as
>> much of a common code-path as possible.  It's really frustrating when 
>> things
>> like data-validation work differently between one's REST interfaces and 
>> one's
>> html forms.
>>
>> Thusfar, in my investigations with both frameworks, I've felt that both
>> mechanisms appear quite different, and/or I have to do a lot of manual 
>> parsing
>> of XML in the Post/Put REST case.
>>
>> HOWEVER...  I've really only spent a little time investigating either one.
>> It's extremely likely that I'm just completely missing the best way to 
>> solve
>> the issue I'm describing.
>>
>> Can anyone point me to an example that works the way I'm describing?
>>
>> Hopefully, I have asked my question well enough.  :-) I'm feeling horribly
>> inelequent right now.
>>
>

-- 





[web2py] Can web2py serve REST data of many-to-may tables via parse_as_rest?

2012-08-16 Thread Matthew Wood
I'm posting this question here as well as on 
stackoverflow.
 
So hopefully the extra exposure will help me out!

I need to serve REST data about a many-to-many relationship.  I've been 
playing with web2py's lovely parse_as_rest functionality, but can't quite 
get the many-to-many thing working.

As an example, let's take standard users and groups.

Tables:

   - user
   - id
  - user_name
   - group
   - id
  - group_name
   - membership
   - id
  - user_id
  - group_id
   


What pattern do I need to use to serve a url that will give me all 
group_name's that a user belongs to?

patterns = [
"/user[user]",
"/user[user]/id/{user.id}",
"/user[user]/id/{user.id}/membership[membership.user_id]",

# This is the line that I can't make yet:
#"/user[user]/id/{user.id}/membership[membership.user_id]/group",

"/group[group]",
"/group[group]/id/{group.id}",
]
parser = db.parse_as_rest(patterns, args, vars)


With the non-commented lines above, I can get to these urls:


   1. .../user
   2. .../user/id/1
   3. .../user/id/1/membership
   4. .../group
   5. .../group/id/3
   

URL #3 shows me all my memberships, and I can then make several separate 
calls to URL #5 to get the group_name values, but there's got to be a way 
to do this with one call.


Help me web2py google forum!  You're my only hope. (Besides 
stackoverflow
 of 
course!)

-- 





[web2py] Question about Human-readable forms + REST CRUD APIs.

2012-07-28 Thread Matthew Wood
A quick question about basic CRUD for both humans (basic HTML) and computers
(REST)

I'm trying to pick a solid python framework for a project at work.  We have 
a
lot of situations where we need to expose datbase tables for data CRUD.

I'm trying to pick between Flask and Web2py at this time, but I've got a
specific need that I'm not sure is solved by either framework.

Obviously for human consumption, I'll be using some sort of form-library 
that
will read the table-schema auto-create the form for me.  (Built in with 
Web2py,
WTForms + SQL-Alchemy for Flask.)  For the REST interfaces, I'll use a 
similar
library (Built in with Web2py, flask-rest for flask).

What I'd REALLY like, is to have both the REST interfaces and html-forms 
use as
much of a common code-path as possible.  It's really frustrating when things
like data-validation work differently between one's REST interfaces and 
one's
html forms.

Thusfar, in my investigations with both frameworks, I've felt that both
mechanisms appear quite different, and/or I have to do a lot of manual 
parsing
of XML in the Post/Put REST case.

HOWEVER...  I've really only spent a little time investigating either one.
It's extremely likely that I'm just completely missing the best way to solve
the issue I'm describing.

Can anyone point me to an example that works the way I'm describing?

Hopefully, I have asked my question well enough.  :-) I'm feeling horribly
inelequent right now.

-- 





Re: [web2py] How do I aggregate accounts using OAuth & web2py?

2011-12-23 Thread Matthew
Thank you, Mic!

[web2py] Re: haml and sass

2011-12-19 Thread Matthew
I've used HamlPy before: https://github.com/jessemiller/HamlPy. It
works really well for those familiar with Python syntax. All you have
to do is "listen" on a directory, or set up an Eclipse job that
executes a script every time you save a file.

If anyone is interested, I could dig back and find the script I used.

On Dec 19, 11:41 am, António Ramos  wrote:
> when will we have haml and sass inside web2py?
>
> Thank you


[web2py] How do I aggregate accounts using OAuth & web2py?

2011-12-18 Thread Matthew
Tumblr provides a very simple interface to link your Twitter and
Facebook accounts for posting through their service. I'd like to do
something similar in my application - provide a single point for
people to aggregate different accounts like Flickr, Facebook, Twitter,
etc. - and I don't want to spend $1,000 per year for Janrain's Account
Mapping to do so.

How do I link multiple accounts in aggregate using web2py?

I have a feeling I should start at
http://web2py.com/book/default/chapter/08?search=oauth#Other-Login-Methods-and-Login-Forms,
but was hoping there were more concrete tutorials or best practices
documented. Does anyone know of any?

Thanks,
Matthew


[web2py] Re: Default field value with lambda

2011-12-02 Thread Matthew
I did try with a computed field, but it did not work. It kept giving None 
as the value. Here is what I've tried so far: 

Field('name', compute=lambda r: 'Node ' + r['id'] or 'Node'), 

and 

Field('name', default=lambda r: 'Node ' + r['id'] or 'Node'), 

I understand that *default* does not take arguments, but *compute* did not 
work for me either. Can you include an example so I am sure to try the 
exact syntax you're suggesting? 

Thanks, 
Matthew


[web2py] Default field value with lambda

2011-12-01 Thread Matthew
Is it possible to define a default field value using lambda like the a
Computed Field? http://web2py.com/book/default/chapter/06#Computed-Fields

I want to name nodes using their own ID fields, e.g., "Node 1", "Node
2", etc. Can I do this with lambda and not rely on a separate counter
field?

Thanks,
Matthew


[web2py] Re: Navigation links with Plugin & CRUD

2011-12-01 Thread Matthew
Thanks for the tips.

The real reason for my trouble was not understanding the relationship
between crud's HTML default views, and where to place the line "def
data(): return dict(form=crud())". I assumed this was but in the
controller of the *plugin*, when in actuality (if you want to use the
default HTML views) you need to place it in the "default.py" file of
the application.

Also, for reference, here's the slice for SQLFORM.grid:
http://www.web2pyslices.com/slices/take_slice/148

On Oct 20, 10:18 pm, greenpoise  wrote:
> got it..thanks
>
> On Oct 20, 8:04 pm, Cliff  wrote:
>
>
>
>
>
>
>
> > The very long thread (~115 posts) about grid and smartgrid is the best
> > source.  Sorry, don't recall the title.
>
> > On Oct 20, 10:57 pm, greenpoise  wrote:
>
> > > I keep reading SQLFORM.grid. Any example out there with the different
> > > options?
>
> > > thanks
>
> > > Dan
>
> > > On Oct 20, 7:35 pm, Massimo Di Pierro 
> > > wrote:
>
> > > > Do not use crud.select. use SQLFORM.grid instead. So much better.
>
> > > > On Oct 20, 8:34 pm, Matthew  wrote:
>
> > > > > Is there any way to change the default behavior of the CRUD select
> > > > > view when using a plugin? Right now, I have to navigate to the select
> > > > > screen with ".../plugin_wmgraph/data...", but the generated links on
> > > > > the page point to ".../default/data...", so an error occurs when
> > > > > clicking them.
>
> > > > >http://img6.imagebanana.com/img/aw2vsbdl/pTZ6ZW0mVK.png
>
> > > > > Thanks,
> > > > > Matthew


[web2py] Re: SyntaxError: Set: no tables selected on select statement.

2011-11-07 Thread Matthew Young
I get the following error with those changes:
Traceback (most recent call last):
  File "/home/mattosaurus/web2py/gluon/restricted.py", line 204, in
restricted
exec ccode in environment
  File "/home/mattosaurus/web2py/applications/roomReserve/views/
default/check_room_availability.html", line 84, in 
  File "/home/mattosaurus/web2py/gluon/html.py", line 230, in URL
function = f.__name__
AttributeError: 'int' object has no attribute '__name__'

On Nov 7, 2:39 pm, Limedrop  wrote:
> A couple of obvious thing.  First, the query goes with the db() not
> the select().  Second, the reference to room is via room.id rather
> than room.name.  So you could try:
>
> reservations = db(db.reservation.room==room.id).select()
>
> On Nov 8, 8:49 am, Matthew Young  wrote:
>
>
>
>
>
>
>
> > Hello I am using the Version 1.99.3 (2011-11-07 17:41:19) dev version
> > of web2py.
>
> > I am having an issue with this view function:
> > def check_room_availability():
> >     room = db.room(request.args(0)) or redirect(URL('view_rooms'))
> >     reservations = db().select(db.reservation.room.name==room.name)
> >     return dict(room=room, reservations=reservations)
>
> > I get the following error when this page is viewed with a room number
> > passed as an argument:
> > Traceback (most recent call last):
> >   File "/home/mattosaurus/web2py/gluon/restricted.py", line 194, in
> > restricted
> >     in code it raises a RestrictedError containing the traceback.
> > layer is
> >   File "/home/mattosaurus/web2py/applications/roomReserve/controllers/
> > default.py", line 121, in 
> >   File "/home/mattosaurus/web2py/gluon/globals.py", line 149, in
> > 
> >     self.files = []            # used by web2py_ajax.html
> >   File "/home/mattosaurus/web2py/applications/roomReserve/controllers/
> > default.py", line 85, in check_room_availability
> >     reservations = db().select(db.reservation.room.name==room.name)
> >   File "/home/mattosaurus/web2py/gluon/dal.py", line 5697, in select
> >     db,
> >   File "/home/mattosaurus/web2py/gluon/dal.py", line 1225, in select
> >     sql_t += ' %s %s' % (icommand, str(t))
> >   File "/home/mattosaurus/web2py/gluon/dal.py", line 1128, in _select
> >     tablenames = self.tables(query)
> > SyntaxError: Set: no tables selected
>
> > My table definitions in db.py look like this:
> > db.define_table('room',
> >     Field('name'),
> >     Field('description','text'),
> >     Field('location','text'),
> >     format='%(name)s')
>
> > db.define_table('reservation',
> >     Field('room','references room'),
> >     Field('start_date','datetime'),
> >     Field('end_date','datetime'),
> >     Field('special_requirements','text'),
> >     Field('approved','boolean'),
> >     auth.signature)
>
> > db.reservation.room.requires = IS_IN_DB(db,db.room.id,'%(name)s')
> > db.room.name.requires = IS_NOT_EMPTY()
> > db.room.description.requires = IS_NOT_EMPTY()
> > db.room.location.requires = IS_NOT_EMPTY()
> > db.reservation.start_date.requires = IS_NOT_EMPTY()
> > db.reservation.end_date.requires = IS_NOT_EMPTY()
>
> > Has anyone seen this error before? Is my select incorrect? I am
> > finding the documentation a little confusing in this area.


[web2py] SyntaxError: Set: no tables selected on select statement.

2011-11-07 Thread Matthew Young
Hello I am using the Version 1.99.3 (2011-11-07 17:41:19) dev version
of web2py.

I am having an issue with this view function:
def check_room_availability():
room = db.room(request.args(0)) or redirect(URL('view_rooms'))
reservations = db().select(db.reservation.room.name==room.name)
return dict(room=room, reservations=reservations)

I get the following error when this page is viewed with a room number
passed as an argument:
Traceback (most recent call last):
  File "/home/mattosaurus/web2py/gluon/restricted.py", line 194, in
restricted
in code it raises a RestrictedError containing the traceback.
layer is
  File "/home/mattosaurus/web2py/applications/roomReserve/controllers/
default.py", line 121, in 
  File "/home/mattosaurus/web2py/gluon/globals.py", line 149, in

self.files = []# used by web2py_ajax.html
  File "/home/mattosaurus/web2py/applications/roomReserve/controllers/
default.py", line 85, in check_room_availability
reservations = db().select(db.reservation.room.name==room.name)
  File "/home/mattosaurus/web2py/gluon/dal.py", line 5697, in select
db,
  File "/home/mattosaurus/web2py/gluon/dal.py", line 1225, in select
sql_t += ' %s %s' % (icommand, str(t))
  File "/home/mattosaurus/web2py/gluon/dal.py", line 1128, in _select
tablenames = self.tables(query)
SyntaxError: Set: no tables selected

My table definitions in db.py look like this:
db.define_table('room',
Field('name'),
Field('description','text'),
Field('location','text'),
format='%(name)s')

db.define_table('reservation',
Field('room','references room'),
Field('start_date','datetime'),
Field('end_date','datetime'),
Field('special_requirements','text'),
Field('approved','boolean'),
auth.signature)

db.reservation.room.requires = IS_IN_DB(db,db.room.id,'%(name)s')
db.room.name.requires = IS_NOT_EMPTY()
db.room.description.requires = IS_NOT_EMPTY()
db.room.location.requires = IS_NOT_EMPTY()
db.reservation.start_date.requires = IS_NOT_EMPTY()
db.reservation.end_date.requires = IS_NOT_EMPTY()


Has anyone seen this error before? Is my select incorrect? I am
finding the documentation a little confusing in this area.


[web2py] Navigation links with Plugin & CRUD

2011-10-20 Thread Matthew
Is there any way to change the default behavior of the CRUD select
view when using a plugin? Right now, I have to navigate to the select
screen with ".../plugin_wmgraph/data...", but the generated links on
the page point to ".../default/data...", so an error occurs when
clicking them.

http://img6.imagebanana.com/img/aw2vsbdl/pTZ6ZW0mVK.png

Thanks,
Matthew


[web2py] Re: Plugin files disappearing during editing

2011-10-20 Thread Matthew
Thank you!

On Oct 20, 7:47 pm, Anthony  wrote:
> Plugin files are shown separately -- scroll to the bottom of the page, and
> you should see the plugins listed in the Plugins section. Click on one, and
> you'll get a separate page for the plugin files.


[web2py] Plugin files disappearing during editing

2011-10-20 Thread Matthew
I am trying to create a plugin. Is there any reason that files
prefixed with "plugin_" do not show up when you restart web2py to edit
them again?

http://img7.imagebanana.com/img/wcibbzg2/Selection_010.png

Thanks,
Matthew


[web2py] Re: Cannot see Plugins listed in Wizard

2011-10-20 Thread Matthew
Per Massimo's advice, I created an issue for this here:
http://code.google.com/p/web2py/issues/detail?id=478

Please star it if you are experiencing the same issue.

On Oct 19, 4:00 pm, Matthew  wrote:
> Here is a screenshot to illustrate,http://bit.ly/qL7VjAand a
> previous thread about testing the 
> wizard,http://groups.google.com/group/web2py/browse_thread/thread/6c368ee272...


[web2py] Question about crud forms and foreign keys

2011-10-19 Thread Matthew Young
Currently, I have a table that has a field that represents a different
table in my database (ex: Field('thing', db.thing)). If I make a crud
form of the table that has a field referring to a foreign table, I am
able to select items from the second table in a drop down menu. Is
there a way I can tell the crud form to let the user create an item
from the second table, instead of displaying a drop down?


[web2py] Re: Cannot see Plugins listed in Wizard

2011-10-19 Thread Matthew
Here is a screenshot to illustrate, http://bit.ly/qL7VjA and a
previous thread about testing the wizard,
http://groups.google.com/group/web2py/browse_thread/thread/6c368ee2723bb3b9/deb78bbc76b4d299?lnk=gst&q=plugins+wizard#deb78bbc76b4d299


[web2py] Cannot see Plugins listed in Wizard

2011-10-19 Thread Matthew
I am trying to use the plugins dropdown, but I can't see any choices
at all. I've tried this on both Chrome and Firefox, and am using
Ubuntu 10.04.

Thanks for your help,
Matthew


[web2py] Error when @auth.requires_login() decorator is used on a method in controllers/default.py

2011-10-18 Thread Matthew Young
Hi everyone I am using the following python/web2y versions:
web2py™ (1, 99, 3, datetime.datetime(2011, 10, 18, 17, 10, 12),
'dev')
Python  Python 2.7: /usr/bin/python

I am running web2py from source under linux.

I have the following method in my default controller file:
@auth.requires_login()
def add_recipe():
form = crud.create(db.recipe, next=URL('list_recipes'))
return dict(form=form)

When I have the decorator, I get the following stack trace when trying
to access that view:
Traceback (most recent call last):
  File "/home/mattosaurus/web2py/gluon/restricted.py", line 192, in
restricted
else:
  File "/home/mattosaurus/web2py/applications/recipeViewer/controllers/
default.py", line 105, in 
  File "/home/mattosaurus/web2py/gluon/globals.py", line 149, in

self._caller = lambda f: f()
  File "/home/mattosaurus/web2py/gluon/tools.py", line 2465, in f
"""
UnboundLocalError: local variable 'condition' referenced before
assignment

I'm not sure what this means, but I know that it goes away if I remove
the decorator. How can I get this working without removing my
decorator?

Thank you.


[web2py] Database drivers lost

2011-08-04 Thread Matthew
I ran a functioning application using App Engine once. When I tried to
run it again without GAE, I noticed that only the goolgle database
driver was available now:

Database drivers available: google

And when I try to run the app, I get this error:

Traceback (most recent call last):
  File "/home/matthew/dev/projects/poprop_cameron/project/src/gluon/
restricted.py", line 192, in restricted
exec ccode in environment
  File "/home/matthew/.local/share/Trash/files/src.3/applications/
welcome/models/db.py", line 17, in 
db = DAL('sqlite://storage.sqlite')   # if not, use SQLite or
other DB
  File "/home/matthew/dev/projects/poprop_cameron/project/src/gluon/
dal.py", line 3981, in __init__
raise RuntimeError, "Failure to connect, tried %d times:\n%s" %
(attempts, error)
RuntimeError: Failure to connect, tried 5 times:
'NoneType' object has no attribute 'Connection'

The sqlite file is still there, but it looks like I can't connect to
it now due to the lack of a driver. How did the sqlite driver get
removed and how do I restore it?

Thanks,
Matthew


[web2py] "No module named pickle" when started in App Engine

2011-08-02 Thread Matthew
I tried to start web2py 1.98.1 using dev_appserver.py, but it cannot
find the "pickle" module.

Traceback (most recent call last):
  File "/home/matthew/dev/sdks/google_appengine_1.5.2/google/appengine/
tools/dev_appserver.py", line 4144, in _HandleRequest
self._Dispatch(dispatcher, self.rfile, outfile, env_dict)
  File "/home/matthew/dev/sdks/google_appengine_1.5.2/google/appengine/
tools/dev_appserver.py", line 4049, in _Dispatch
base_env_dict=env_dict)
  File "/home/matthew/dev/sdks/google_appengine_1.5.2/google/appengine/
tools/dev_appserver.py", line 616, in Dispatch
base_env_dict=base_env_dict)
  File "/home/matthew/dev/sdks/google_appengine_1.5.2/google/appengine/
tools/dev_appserver.py", line 3120, in Dispatch
self._module_dict)
  File "/home/matthew/dev/sdks/google_appengine_1.5.2/google/appengine/
tools/dev_appserver.py", line 3024, in ExecuteCGI
reset_modules = exec_script(handler_path, cgi_path, hook)
  File "/home/matthew/dev/sdks/google_appengine_1.5.2/google/appengine/
tools/dev_appserver.py", line 2887, in ExecuteOrImportScript
exec module_code in script_module.__dict__
  File "/home/matthew/dev/projects/poprop_cameron/project/src/
gaehandler.py", line 33, in 
import pickle
ImportError: No module named pickle

When I import it using the interpretor, it imports without error. Is
there a path I have to include somewhere?

Thanks,
Matthew


[web2py] Re: Not getting proper Janrain choices

2011-08-02 Thread Matthew
I see it now, thank you. I didn't realize it was at the bottom of the
file.

Thanks!

On Aug 2, 2:20 pm, Anthony  wrote:
> On Tuesday, August 2, 2011 1:45:52 PM UTC-4, Matthew wrote:
>
> > 1. Yes, I completed those steps and the code was not inserted.
>
> Hmm, I just tried it (from 1.98.1 source version on Windows), and it works.
> Which distribution are you using -- Windows or Mac binary, or source? What
> else are you doing in the wizard? If you just specify the Janrain login but
> don't do anything else in the wizard, does it still fail to insert the code
> (note, it should be at the very bottom of your db.py model file, not at the
> place where the commented out Janrain code is).
>
> Anthony


[web2py] Re: Not getting proper Janrain choices

2011-08-02 Thread Matthew
1. Yes, I completed those steps and the code was not inserted.
2. Version 1.98.1
3. I will submit the recommended example/language to this group.


On Aug 2, 8:51 am, Anthony  wrote:
> On Tuesday, August 2, 2011 8:12:01 AM UTC-4, Matthew wrote:
>
> > Thank you! That bit of code was the key.
>
> > The wizard definitely does NOT work. I had to manually copy/paste this
> > code into db.py to get it working.
>
> Are you saying that in Step 1 of the wizard you selected Janrain as the
> login method and specified a login_config but did not get the following code
> inserted into your db.py file:
>
> from gluon.contrib.login_methods.rpx_account import RPXAccount
> auth.settings.actions_disabled=['register','change_password','request_reset 
> _password']
> auth.settings.login_form = RPXAccount(request,
>     api_key = settings.login_config.split(':')[-1],
>     domain = settings.login_config.split(':')[0],
>     url = "http://%s/%s/default/user/login"; %
> (request.env.http_host,request.application))
>
> This works when I try it. What version of web2py are you using? Or was there
> some other problem?
>
>
>
> > Can you point me in the right direction of the wizard's files so I can
> > take a look at fixing this bug?
>
> The wizard is part of the 'admin' application in
> /web2py/applications/admin 
> (http://code.google.com/p/web2py/source/browse/#hg%2Fapplications%2Fadmin).
> There is a wizard.py controller 
> (http://code.google.com/p/web2py/source/browse/applications/admin/cont...)
> and a couple views 
> (http://code.google.com/p/web2py/source/browse/applications/admin/#adm...
> ).
>
> > Also, what's the best way to
> > contribute to the documentation? I'd like to point out that "domain"
> > is not actually the full domain as defined by Janrain's documentation,
> > but your domain's application name.
>
> You can submit requests for documentation changes/corrections here.
>
> Anthony


[web2py] Re: Not getting proper Janrain choices

2011-08-02 Thread Matthew
Thank you! That bit of code was the key.

The wizard definitely does NOT work. I had to manually copy/paste this
code into db.py to get it working.

Can you point me in the right direction of the wizard's files so I can
take a look at fixing this bug? Also, what's the best way to
contribute to the documentation? I'd like to point out that "domain"
is not actually the full domain as defined by Janrain's documentation,
but your domain's application name.

Thanks again,
Matthew


On Jul 31, 10:57 pm, Anthony  wrote:
> On Sunday, July 31, 2011 7:20:27 PM UTC-4, Matthew wrote:
>
> > 0.py
>
> > settings.login_config = 'domain:api_key'
>
> I think the above is supposed to be your domain and Janrain API key, not the
> literal string 'domain:api_key' (you input this in the first step of the
> wizard). However, in this case I don't think it matters, because it appears
> your code does not actually use this setting (see below).
>
> > db.py (abridged)
>
> > ...
>
> > #
> > ## If you need to use OpenID, Facebook, MySpace, Twitter, Linkedin,
> > etc.
> > ## register with janrain.com, uncomment and customize following
> > from gluon.contrib.login_methods.rpx_account import RPXAccount
> > auth.settings.actions_disabled = \
> >    ['register','change_password','request_reset_password']
> > auth.settings.login_form = RPXAccount(request,
> > api_key='xx',domain='x',
> >    url = "http://localhost:/%s/default/user/login"; %
> > request.application)
>
> When using the wizard, you shouldn't need to manually uncomment and fill in
> the code above. Instead, the following code should be inserted in db.py for
> you by the wizard:
>
> from gluon.contrib.login_methods.rpx_account import RPXAccount
> auth.settings.actions_disabled=['register','change_password','request_reset_password']
> auth.settings.login_form = RPXAccount(request,
>     api_key = settings.login_config.split(':')[-1],
>     domain = settings.login_config.split(':')[0],
>     url = "http://%s/%s/default/user/login"; %
> (request.env.http_host,request.application))
>
> Notice this uses settings.login_config to obtain your domain and API key.
> Does your db.py include this code? If not, what version of web2py are you
> using?
>
> Anthony


[web2py] Re: Not getting proper Janrain choices

2011-07-31 Thread Matthew
They were both generated by the new application wizard, then I
modified them. I've copied the relevant portions below (substituting
for secret keys, etc.).

0.py

from gluon.storage import Storage
settings = Storage()

settings.migrate = True
settings.title = 'My New App'
settings.subtitle = 'powered by web2py'
settings.author = 'you'
settings.author_email = 'y...@example.com'
settings.keywords = ''
settings.description = ''
settings.layout_theme = 'Whitelight'
settings.database_uri = 'sqlite://storage.sqlite'
settings.security_key = '14f78e4e-5595-4d88-bcd8-49308acf11b4'
settings.email_server = 'localhost'
settings.email_sender = 'y...@example.com'
settings.email_login = ''
settings.login_method = 'janrain'
settings.login_config = 'domain:api_key'
settings.plugins = []

db.py (abridged)

...

#
## If you need to use OpenID, Facebook, MySpace, Twitter, Linkedin,
etc.
## register with janrain.com, uncomment and customize following
from gluon.contrib.login_methods.rpx_account import RPXAccount
auth.settings.actions_disabled = \
   ['register','change_password','request_reset_password']
auth.settings.login_form = RPXAccount(request,
api_key='xx',domain='x',
   url = "http://localhost:/%s/default/user/login"; %
request.application)

...

Thanks again for taking a look.

Matthew

On Jul 31, 4:06 pm, Anthony  wrote:
> Can you show more of your 0.py and db.py code related to auth settings? Did
> you copy those files from somewhere?
>
>
>
>
>
>
>
> On Sunday, July 31, 2011 3:59:14 PM UTC-4, Matthew wrote:
> > That method actually uses the values that are set in the RPXAccount
> > object, which is constructed in db.py.
>
> > On Jul 31, 3:21 pm, Anthony  wrote:
> > > Checkhttp://
> > code.google.com/p/web2py/source/browse/gluon/contrib/login_met
> > > You might need to override the login_form method.
>
> > > Anthony
>
> > > On Sunday, July 31, 2011 3:00:50 PM UTC-4, Matthew wrote:
> > > > I just tried to link a new web2py application with my Janrain account,
> > > > but I am still seeing the default Janrain options on the /default/user/
>
> > > > login. My models/db.py has my key, domain (not full domain, just
> > > > Janrain app name), and the url to /default/user/login. My 0.py file
> > > > has "settings.login_method = 'janrain'" and "settings.login_config =
> > > > 'domain:api_key'". Am I missing anything?
>
> > > > I am using the layout plugin and a layout - is there another spot to
> > > > alter in layouts?
>
> > > > Thanks,
> > > > Matthew


[web2py] Re: Not getting proper Janrain choices

2011-07-31 Thread Matthew
That method actually uses the values that are set in the RPXAccount
object, which is constructed in db.py.

On Jul 31, 3:21 pm, Anthony  wrote:
> Checkhttp://code.google.com/p/web2py/source/browse/gluon/contrib/login_met
> You might need to override the login_form method.
>
> Anthony
>
>
>
>
>
>
>
> On Sunday, July 31, 2011 3:00:50 PM UTC-4, Matthew wrote:
> > I just tried to link a new web2py application with my Janrain account,
> > but I am still seeing the default Janrain options on the /default/user/
> > login. My models/db.py has my key, domain (not full domain, just
> > Janrain app name), and the url to /default/user/login. My 0.py file
> > has "settings.login_method = 'janrain'" and "settings.login_config =
> > 'domain:api_key'". Am I missing anything?
>
> > I am using the layout plugin and a layout - is there another spot to
> > alter in layouts?
>
> > Thanks,
> > Matthew


[web2py] Not getting proper Janrain choices

2011-07-31 Thread Matthew
I just tried to link a new web2py application with my Janrain account,
but I am still seeing the default Janrain options on the /default/user/
login. My models/db.py has my key, domain (not full domain, just
Janrain app name), and the url to /default/user/login. My 0.py file
has "settings.login_method = 'janrain'" and "settings.login_config =
'domain:api_key'". Am I missing anything?

I am using the layout plugin and a layout - is there another spot to
alter in layouts?

Thanks,
Matthew


[web2py] Re: LIKE is slow on RDBS; true for GAE also?

2010-06-05 Thread Matthew
Right, which is why this syntax is used:

rows = db(buyer.id>0).select().find(lambda
row:row.name.startswith('C'))

I was just wondering how efficient this really is since it grabs the
whole table. I'm going to try it on GAE, I was just wondering if
anyone else had yet.

On Jun 4, 2:21 am, Álvaro Justen  wrote:
> On Fri, Jun 4, 2010 at 02:36, Vasile Ermicioi  wrote:
> > I think GAE doesn't support like
>
> Ouch, I forgot this. Excuse me for that.
>
> --
> Álvaro Justen - Turicas
>  http://blog.justen.eng.br/
>  21 9898-0141


[web2py] LIKE is slow on RDBS; true for GAE also?

2010-06-03 Thread Matthew
When implementing "LIKE", I noticed that the following line is
extremely slow (for large numbers of records) on RDBS:

rows = db(buyer.id>0).select().find(lambda
row:row.name.startswith('C'))

I haven't uploaded my data to GAE yet to test. Before I do, since the
upload is rather monotonous, does anyone know that the speed on GAE is
much faster with the syntax above?

Reference: http://www.web2pyslices.com/main/slices/take_slice/16

Thanks,
Matthew


[web2py] Re: Running a script with Google App Engine

2010-05-10 Thread Matthew
Does this apply to the dev environment as well? Just fire it up and
run it via localhost?

If that's the case, would you mind providing an example or the proper
documentation link to help me get started?

Also, since bulk inserts are now possible in GAE
http://groups.google.com/group/web2py/browse_thread/thread/93d3dad8474735e0/0e5bc2a69f0767d6?lnk=gst&q=bulk+insert#0e5bc2a69f0767d6,
does that mean they're only possible from within the application
itself (not via script)?

Thanks,
Matthew

On May 10, 7:04 pm, howesc  wrote:
> everything on GAE must be called via a URL (it must be a controller/
> function).  if you need to run it periodically look up how to do cron
> on GAE and create your cron.yaml.
>
> @auth.requires_membership() is your friend in this case to limit who
> can call your controller. :)
>
> i have several of these sorts of things running on GAE, and it seems
> to work quite well.
>
> On May 9, 7:14 pm, mdipierro  wrote:
>
> > no
>
> > On May 9, 8:33 pm, Matthew  wrote:
>
> > > You can run a script with Postgres or MySQL using this syntax:
>
> > >     python web2py.py -S myapp -M -R applications/myapp/modules/
> > > myscript.py
>
> > > Can a script be run in this way using App Engine as the datastore?


[web2py] Running a script with Google App Engine

2010-05-09 Thread Matthew
You can run a script with Postgres or MySQL using this syntax:

python web2py.py -S myapp -M -R applications/myapp/modules/
myscript.py

Can a script be run in this way using App Engine as the datastore?


[web2py] Re: Service returns invalid function message

2010-05-07 Thread Matthew
I did delete it accidentally. Thank you for the quick spot.

On May 7, 12:12 am, mdipierro  wrote:
> works for me with 1.77.3
>
> did you delete
>
> def call(): return service()
>
> On May 6, 11:08 pm, Matthew  wrote:
>
> > I have a simple service running in web2py 1.74.6 and 1.77.3. In the
> > older version, the service works great. In the newer version, the
> > "invalid function" message is returned. Here is my code:
>
> >     from gluon.tools import Service
> >     service = Service(globals())
>
> >     @service.json
> >     def hello():
> >         return 'Hello!'
>
> > And here is how I call refer to it from the HTML page:
>
> >     {{=URL(r=request, f='call/json/hello')}}
>
> > Is there a change between how services are called? The 
> > documentationhttp://web2py.com/book/default/section/9/2?search=serviceslooksthe
> > same.
>
> > Thanks,
> > Matthew


[web2py] Service returns invalid function message

2010-05-06 Thread Matthew
I have a simple service running in web2py 1.74.6 and 1.77.3. In the
older version, the service works great. In the newer version, the
"invalid function" message is returned. Here is my code:

from gluon.tools import Service
service = Service(globals())

@service.json
def hello():
return 'Hello!'

And here is how I call refer to it from the HTML page:

{{=URL(r=request, f='call/json/hello')}}

Is there a change between how services are called? The documentation
http://web2py.com/book/default/section/9/2?search=services looks the
same.

Thanks,
Matthew


[web2py] Re: Different results in console vs. script

2010-05-05 Thread Matthew
I figured it out (stupid mistake on my part). Part of the instructions
at http://web2py.com/AlterEgo/default/show/260 include creating a test
database. I dutifully followed those instructions, but neglected to
change my DAL connection string to my actual database :P

A great thanks to the community and to you, Massimo, for taking so
much time and effort to answer these questions. It's very helpful.

And I also found out about web2py_utils!

On May 5, 6:24 pm, Thadeus Burgess  wrote:
> OK. Thank you for the idea. You will be happy :)
>
> --
> Thadeus
>
> On Wed, May 5, 2010 at 2:00 PM, Jonathan Lundell  wrote:
> > On May 5, 2010, at 9:13 AM, Thadeus Burgess wrote:
>
> >> It supports nosetests which includes a coverage plugin. I will look
> >> into adding the option stand-alone so you do not need nosetests.
>
> > Nosetests works for me just fine; in fact it's preferable.
>
> >> The problem is that there is no way to determine how much "coverage"
> >> you have in a web2py app. It will include the coverage of "gluon + all
> >> apps", which is not what you want I don't think. I have attempted and
> >> do not see any way around this, it is a limitation in web2py that will
> >> now allow for proper coverage testing.
>
> > In my current unit test, which calls coverage directly, I generate the 
> > report like this:
>
> > cov.report(file=open('coverage.report','w'), 
> > omit_prefixes=list(('gluon','/path/to/tests')))
>
> > That is, I exclude gluon and the unit test directory from the report, which 
> > seems to do the trick just fine. I'm pretty sure you can do the same thing 
> > via the nose plugin, but I haven't tried.
>
> >> The requirements for the script are:
>
> >> A) Source installation of web2py, given how it must execute and locate
> >> test files
> >> B) A runner script to actually start the tests. Since it relies on the
> >> path to [A]


[web2py] Re: Web2py Utilities

2010-05-05 Thread Matthew
This is excellent! I know that the documentation is in its early
stages, but are there any examples you can point to where this has
been used?

On Apr 29, 10:15 pm, muybay  wrote:
> Fantastic contribution Thadeus, I hope to contribute back a fraction
> of what you have already done, many thanks!
>
> On Apr 29, 10:50 am, Thadeus Burgess  wrote:
>
> > Leandro:
>
> > The only dummy questions are the ones never asked!
>
> > You can checkout a copy and stick it in the modules folder of your
> > application, and instead of
>
> > ``importweb2py_utils``
>
> > you can do
>
> > web2py_utils= local_import('web2py_utils')
>
> > Mind you, I designed this so that only the code in __init__.py gets
> > imported, so if you wanted pagination you will need to do.
>
> > pagination = local_import('web2py_utils.paginate')
>
> > set = pagination.Pagination()
>
> > Most of the code should work on GAE, I have not tested so if you run
> > into any problems I don't mind fixing them!
>
> > Patrick:
>
> > Its almost there! I want to get the layout manager working better so
> > that you can hot-swap layouts like in wordpress.
>
> > --
> > Thadeus
>
> > On Thu, Apr 29, 2010 at 9:09 AM, DenesL  wrote:
> > > Thanks for sharing.
>
> > > On Apr 28, 9:02 pm, Thadeus Burgess  wrote:
> > >> I have decided to share some of the libraries that I have found useful
> > >> when creating web2py apps.
>
> > >> This contains lots of goodies, and some nice shortcuts.
>
> > >>     * Common shortcuts
> > >>     * Widgets
> > >>     * py2jquery module
> > >>     * Heirarchical category module.
> > >>     * Database store configuration settings
> > >>     * Class based menu builder
> > >>     * syntax highlighting
> > >>     * Output compression
> > >>     * Pagination
> > >>     * Stop words lists
> > >>     * Levenstien algorithm
> > >>     * NGram algorithm
> > >>     * New SQLHTML widgets (able to pass class attributes to them)
> > >>     * Convert wordpress xml export into a python dict!
> > >>     * Comments, tagging, and pingback/trackback plugins!
>
> > >> And more!
>
> > >> The whole library is designed to be installed like any other python
> > >> package using setuptools. For basic usage you can just import the
> > >> package normally.
>
> > >> However, the plugins are there for convenience, and so that I can keep
> > >> them all in the same place, but you will need to copy them to your app
> > >> to actually use them.
>
> > >> Read the documentation here
>
> > >>http://static.thadeusb.com/web2py_utils/index.html
>
> > >> And the source code is located here
>
> > >>http://hg.thadeusb.com/Web/web2py_utils/summary
>
> > >> I am open to ideas/suggestions, and if you want to contribute let me 
> > >> know!
>
> > >> p.s. blogitizor gets some loving tonight, and is being migrated to use
> > >> this library.
>
> > >> --
> > >> Thadeus


[web2py] Re: Different results in console vs. script

2010-05-05 Thread Matthew
Note that I've renamed my root web2py folder to 'app' as you'll see
below.

>From console:

>>> os.getcwd()
'/home/matthew/dev/projects/mywebapp/src/app'
>>> request.env.web2py_path
>>>

Print statements from search_test.py:

/home/matthew/dev/projects/mywebapp/src/app
None

On May 5, 12:01 am, mdipierro  wrote:
> can you also print
>
> os.getcwd() and request.env.web2py_path
>
> On May 4, 10:26 pm, Matthew  wrote:
>
> > From console:
>
> > >>> db._folder
>
> > 'applications/myapp/databases'>>> request.folder
>
> > 'applications/myapp'
>
> > Print statements from search_test.py, the unit test:
>
> > applications/myapp/databases
> > applications/myapp
>
> > On May 4, 10:27 pm, mdipierro  wrote:
>
> > > and what is in db._folder?
>
> > > On May 4, 9:27 pm, mdipierro  wrote:
>
> > > > Perhpas something is causing the test script to pick up the wrong
> > > > database. What is in request.folder from console?
>
> > > > On May 4, 8:44 pm, Matthew  wrote:
>
> > > > > Thanks for the quick reply!
>
> > > > > They are in the db. That's why running the code from the console works
> > > > > and why it's puzzling that the script doesn't since the same
> > > > > environment is set up.
>
> > > > > On May 4, 9:28 pm, mdipierro  wrote:
>
> > > > > > I do not think that line is the problem. Are the records in the db
> > > > > > already or are they stored by the unit_test?
>
> > > > > > On May 4, 8:12 pm, Matthew  wrote:
>
> > > > > > > I'm attempting to unit test a method by 
> > > > > > > followinghttp://web2py.com/AlterEgo/default/show/260. If I run 
> > > > > > > the query inside
> > > > > > > the console, it works fine. If I run it in my unit tests, it 
> > > > > > > returns
> > > > > > > no results (NOTE that there are no errors in the unit test).
>
> > > > > > > Here is the query:
>
> > > > > > >     rows = db(db.flavor.id>0).select().\
> > > > > > >         find(lambda row:row.name.startswith(term))
>
> > > > > > > WORKS (17 results): python web2py.py -S myapp -M
> > > > > > > DOES NOT WORK (0 results): python web2py.py -S myapp -M -R
> > > > > > > applications/myapp/tests/test_search.py
>
> > > > > > > Thanks,
> > > > > > > Matthew


[web2py] Re: Different results in console vs. script

2010-05-04 Thread Matthew
>From console:

>>> db._folder
'applications/myapp/databases'
>>> request.folder
'applications/myapp'

Print statements from search_test.py, the unit test:

applications/myapp/databases
applications/myapp


On May 4, 10:27 pm, mdipierro  wrote:
> and what is in db._folder?
>
> On May 4, 9:27 pm, mdipierro  wrote:
>
>
>
> > Perhpas something is causing the test script to pick up the wrong
> > database. What is in request.folder from console?
>
> > On May 4, 8:44 pm, Matthew  wrote:
>
> > > Thanks for the quick reply!
>
> > > They are in the db. That's why running the code from the console works
> > > and why it's puzzling that the script doesn't since the same
> > > environment is set up.
>
> > > On May 4, 9:28 pm, mdipierro  wrote:
>
> > > > I do not think that line is the problem. Are the records in the db
> > > > already or are they stored by the unit_test?
>
> > > > On May 4, 8:12 pm, Matthew  wrote:
>
> > > > > I'm attempting to unit test a method by 
> > > > > followinghttp://web2py.com/AlterEgo/default/show/260. If I run the 
> > > > > query inside
> > > > > the console, it works fine. If I run it in my unit tests, it returns
> > > > > no results (NOTE that there are no errors in the unit test).
>
> > > > > Here is the query:
>
> > > > >     rows = db(db.flavor.id>0).select().\
> > > > >         find(lambda row:row.name.startswith(term))
>
> > > > > WORKS (17 results): python web2py.py -S myapp -M
> > > > > DOES NOT WORK (0 results): python web2py.py -S myapp -M -R
> > > > > applications/myapp/tests/test_search.py
>
> > > > > Thanks,
> > > > > Matthew


[web2py] Re: Different results in console vs. script

2010-05-04 Thread Matthew
Thanks for the quick reply!

They are in the db. That's why running the code from the console works
and why it's puzzling that the script doesn't since the same
environment is set up.


On May 4, 9:28 pm, mdipierro  wrote:
> I do not think that line is the problem. Are the records in the db
> already or are they stored by the unit_test?
>
> On May 4, 8:12 pm, Matthew  wrote:
>
>
>
> > I'm attempting to unit test a method by 
> > followinghttp://web2py.com/AlterEgo/default/show/260. If I run the query 
> > inside
> > the console, it works fine. If I run it in my unit tests, it returns
> > no results (NOTE that there are no errors in the unit test).
>
> > Here is the query:
>
> >     rows = db(db.flavor.id>0).select().\
> >         find(lambda row:row.name.startswith(term))
>
> > WORKS (17 results): python web2py.py -S myapp -M
> > DOES NOT WORK (0 results): python web2py.py -S myapp -M -R
> > applications/myapp/tests/test_search.py
>
> > Thanks,
> > Matthew


[web2py] Different results in console vs. script

2010-05-04 Thread Matthew
I'm attempting to unit test a method by following
http://web2py.com/AlterEgo/default/show/260. If I run the query inside
the console, it works fine. If I run it in my unit tests, it returns
no results (NOTE that there are no errors in the unit test).

Here is the query:

rows = db(db.flavor.id>0).select().\
find(lambda row:row.name.startswith(term))

WORKS (17 results): python web2py.py -S myapp -M
DOES NOT WORK (0 results): python web2py.py -S myapp -M -R
applications/myapp/tests/test_search.py

Thanks,
Matthew


[web2py] Unit Testing - exec not adding controller to globals

2010-05-02 Thread Matthew
I'm following the instructions from this post 
http://web2py.com/AlterEgo/default/show/260
but cannot get my methods recognized globally.

ERROR MESSAGE:

ERROR: test_suggest_performer (__builtin__.TestSearch)
--
Traceback (most recent call last):
  File "applications/myapp/tests/test_search.py", line 24, in
test_suggest_performer
suggs = suggest_flavors("straw")
NameError: global name 'suggest_flavors' is not defined

TEST FILE:

import unittest

from gluon.globals import Request
db = test_db

execfile("applications/myapp/controllers/search.py", globals())

class TestSearch(unittest.TestCase):
def setUp(self):
request = Request()

def test_suggest_flavors(self):
suggs = suggest_flavors("straw")
self.assertEqual(len(suggs), 1)
self.assertEqual(suggs[0][1], 'Strawberry')

CONTROLLER:

def suggest_flavors(term):
return []


[web2py] Re: Database migration does not work

2010-04-24 Thread Matthew
Perfect! Thank you so much for your help.

I had been including fake_migrate in the definition of the tables as
well, which is what caused the second error.

Thanks again!

On Apr 24, 11:10 am, mdipierro  wrote:
> Try follow my instructions above and fake_migrate goes here:
>
> db.define_table('performer', __performer, __audit,fake_migrate=True or
> False)
> db.define_table('performer_audit_trail', __performer,
> __audit_trail,fake_migrate=True or False)
>
> On Apr 24, 10:07 am, Matthew  wrote:
>
> > Here are the relevant parts of the model. I didn't copy the
> > boilerplate code like connection string, etc at the start of the db.py
> > file:
>
> > # Common fields.
> > ###
>
> > # Web data.
> > __web_resource = db.Table(db,
> >                           '__web_resource',
> >                           Field('wikipedia_id'),
> >                           Field('myspace_id'),
> >                           Field('facebook_id'))
>
> > # All tables will inherit this simple audit.
> > current_user_id = (auth.user and auth.user.id) or 1
>
> > __audit = db.Table(db,
> >                    '__audit',
> >                    Field('created_on', 'datetime',
> > default=request.now),
> >                    Field('created_by', db.auth_user,
> > default=current_user_id),
> >                    Field('modified_on', 'datetime',
> > default=request.now),
> >                    Field('modified_by', db.auth_user,
> > default=current_user_id))
>
> > # Each table's corresponding *audit table will inherit this audit.
> > __audit_trail = db.Table(db,
> >                          '__audit_trail',
> >                          Field('modified_on', 'datetime',
> > default=request.now),
> >                          Field('modified_by', db.auth_user,
> >                                default=current_user_id))
>
> > # Tables.
> > ##
>
> > # Performer
> > __performer = db.Table(db,
> >                        '__performer',
> >                        Field('name'),
> >                        Field('slug'),
> >                        Field('twitter_id'),
> >                        Field('musicbrainz_guid'), # the offending new
> > field
> >                        __web_resource)
>
> > db.define_table('performer', __performer, __audit)
> > db.define_table('performer_audit_trail', __performer, __audit_trail)
>
> > On Apr 24, 10:46 am, mdipierro  wrote:
>
> > > hmmm. I guess I need to the model then. fake_migrate was supported in
> > > 1.76.5
>
> > > Massimo
>
> > > On Apr 24, 9:37 am, Matthew  wrote:
>
> > > > 1.76.5
>
> > > > On Apr 24, 10:35 am, mdipierro  wrote:
>
> > > > > you must have a very old web2py version.
>
> > > > > On Apr 24, 9:25 am, Matthew  wrote:
>
> > > > > > I'm including previously-defined tables in other tables to reduce
> > > > > > maintenance. For example, I have "__web_resource" table that has
> > > > > > Wikipedia IDs, etc that I'm using in other tables.
>
> > > > > > When I tried your suggestion, I got the following error:
>
> > > > > > File "/home/matthew/dev/projects/webapp/src/app/applications/myapp/
> > > > > > models/db.py", line 114, in 
> > > > > >     __web_resource, fake_migrate=True)
> > > > > > TypeError: __init__() got an unexpected keyword argument
> > > > > > 'fake_migrate'
>
> > > > > > Is this due to the inclusion of other tables?
>
> > > > > > On Apr 23, 10:13 am, mdipierro  wrote:
>
> > > > > > > Something went wrong with migration. Do this:
>
> > > > > > > 1) comment the field that gives you problem and set migrate to 
> > > > > > > fake:
>
> > > > > > > db.define_table('performer',
> > > > > > >      ...
> > > > > > > #     Field('musicbrainz_guid'),
> > > > > > >      ...,
> > > > > > >      fake_migrate=True) # <<<
>
> > > > &

[web2py] Re: Database migration does not work

2010-04-24 Thread Matthew
Here are the relevant parts of the model. I didn't copy the
boilerplate code like connection string, etc at the start of the db.py
file:

# Common fields.
###

# Web data.
__web_resource = db.Table(db,
  '__web_resource',
  Field('wikipedia_id'),
  Field('myspace_id'),
  Field('facebook_id'))

# All tables will inherit this simple audit.
current_user_id = (auth.user and auth.user.id) or 1

__audit = db.Table(db,
   '__audit',
   Field('created_on', 'datetime',
default=request.now),
   Field('created_by', db.auth_user,
default=current_user_id),
   Field('modified_on', 'datetime',
default=request.now),
   Field('modified_by', db.auth_user,
default=current_user_id))

# Each table's corresponding *audit table will inherit this audit.
__audit_trail = db.Table(db,
 '__audit_trail',
 Field('modified_on', 'datetime',
default=request.now),
 Field('modified_by', db.auth_user,
   default=current_user_id))

# Tables.
##

# Performer
__performer = db.Table(db,
   '__performer',
   Field('name'),
   Field('slug'),
   Field('twitter_id'),
   Field('musicbrainz_guid'), # the offending new
field
   __web_resource)

db.define_table('performer', __performer, __audit)
db.define_table('performer_audit_trail', __performer, __audit_trail)

On Apr 24, 10:46 am, mdipierro  wrote:
> hmmm. I guess I need to the model then. fake_migrate was supported in
> 1.76.5
>
> Massimo
>
> On Apr 24, 9:37 am, Matthew  wrote:
>
> > 1.76.5
>
> > On Apr 24, 10:35 am, mdipierro  wrote:
>
> > > you must have a very old web2py version.
>
> > > On Apr 24, 9:25 am, Matthew  wrote:
>
> > > > I'm including previously-defined tables in other tables to reduce
> > > > maintenance. For example, I have "__web_resource" table that has
> > > > Wikipedia IDs, etc that I'm using in other tables.
>
> > > > When I tried your suggestion, I got the following error:
>
> > > > File "/home/matthew/dev/projects/webapp/src/app/applications/myapp/
> > > > models/db.py", line 114, in 
> > > >     __web_resource, fake_migrate=True)
> > > > TypeError: __init__() got an unexpected keyword argument
> > > > 'fake_migrate'
>
> > > > Is this due to the inclusion of other tables?
>
> > > > On Apr 23, 10:13 am, mdipierro  wrote:
>
> > > > > Something went wrong with migration. Do this:
>
> > > > > 1) comment the field that gives you problem and set migrate to fake:
>
> > > > > db.define_table('performer',
> > > > >      ...
> > > > > #     Field('musicbrainz_guid'),
> > > > >      ...,
> > > > >      fake_migrate=True) # <<<
>
> > > > > 2) run appadmin once (it should work)
>
> > > > > 3) uncomment field and remove fake migrate
>
> > > > > db.define_table('performer',
> > > > >      ...
> > > > >      Field('musicbrainz_guid'),
> > > > >      ...)
>
> > > > > 4) run appadmin again. If you get an error something is wrong in your
> > > > > model.
>
> > > > > On Apr 23, 6:19 am, Matthew  wrote:
>
> > > > > > >>> perf = db(db.performer.id > 0).first()
>
> > > > > > Traceback (most recent call last):
> > > > > >   File "", line 1, in 
> > > > > > AttributeError: 'Set' object has no attribute 'first'>>> perf = 
> > > > > > db(db.performer.id > 0).select().first()
>
> > > > > > Traceback (most recent call last):
> > > > > >   File "", line 1, in 
> > > > > >   File "/home/matthew/dev/projects/webapp/src/app/gluon/sql.py", 
> > > > > > line
> > > > > > 3056, in select
> > > > > >     rows = response(query)
> > > > > >   File "/home/matthew/dev/projects/webapp/src/app/gluon/sql.py", 
> > > > > > line
> > > > > > 3051, in response
> > > > > >     db._execute(query)
> > > > > >   File "/home/matthew/dev/projects/webapp/src/app/gluon/sql.py", 
> > > > > > line
> > > > > > 958, in 
> > > > > >     self._execute = lambda *a, **b: self._cursor.execute(*a, **b)
> > > > > > ProgrammingError: column performer.musicbrainz_guid does not exist
> > > > > > LINE 1: ..._id, performer.facebook_id, performer.twitter_id,
> > > > > > performer
>
> > > > > > On Apr 22, 8:48 am, Kuba Kucharski  wrote:
>
> > > > > > > Can you show us the line with a query code?
>
> > > > > > > --
> > > > > > > Kuba
>
> > > > > > > --
> > > > > > > Subscription 
> > > > > > > settings:http://groups.google.com/group/web2py/subscribe?hl=en


[web2py] Re: Database migration does not work

2010-04-24 Thread Matthew
Here are the relevant parts of the model. I didn't copy the
boilerplate code like connection string, etc at the start of the db.py
file:

# Common fields.
###

# Web data.
__web_resource = db.Table(db,
  '__web_resource',
  Field('wikipedia_id'),
  Field('myspace_id'),
  Field('facebook_id'))

# All tables will inherit this simple audit.
current_user_id = (auth.user and auth.user.id) or 1

__audit = db.Table(db,
   '__audit',
   Field('created_on', 'datetime',
default=request.now),
   Field('created_by', db.auth_user,
default=current_user_id),
   Field('modified_on', 'datetime',
default=request.now),
   Field('modified_by', db.auth_user,
default=current_user_id))

# Each table's corresponding *audit table will inherit this audit.
__audit_trail = db.Table(db,
 '__audit_trail',
 Field('modified_on', 'datetime',
default=request.now),
 Field('modified_by', db.auth_user,
   default=current_user_id))

# Tables.
##

# Performer
__performer = db.Table(db,
   '__performer',
   Field('name'),
   Field('slug'),
   Field('twitter_id'),
   Field('musicbrainz_guid'), # the offending new
field
   __performance_resource,
   __web_resource)

db.define_table('performer', __performer, __audit)
db.define_table('performer_audit_trail', __performer, __audit_trail)

On Apr 24, 10:46 am, mdipierro  wrote:
> hmmm. I guess I need to the model then. fake_migrate was supported in
> 1.76.5
>
> Massimo
>
> On Apr 24, 9:37 am, Matthew  wrote:
>
> > 1.76.5
>
> > On Apr 24, 10:35 am, mdipierro  wrote:
>
> > > you must have a very old web2py version.
>
> > > On Apr 24, 9:25 am, Matthew  wrote:
>
> > > > I'm including previously-defined tables in other tables to reduce
> > > > maintenance. For example, I have "__web_resource" table that has
> > > > Wikipedia IDs, etc that I'm using in other tables.
>
> > > > When I tried your suggestion, I got the following error:
>
> > > > File "/home/matthew/dev/projects/webapp/src/app/applications/myapp/
> > > > models/db.py", line 114, in 
> > > >     __web_resource, fake_migrate=True)
> > > > TypeError: __init__() got an unexpected keyword argument
> > > > 'fake_migrate'
>
> > > > Is this due to the inclusion of other tables?
>
> > > > On Apr 23, 10:13 am, mdipierro  wrote:
>
> > > > > Something went wrong with migration. Do this:
>
> > > > > 1) comment the field that gives you problem and set migrate to fake:
>
> > > > > db.define_table('performer',
> > > > >      ...
> > > > > #     Field('musicbrainz_guid'),
> > > > >      ...,
> > > > >      fake_migrate=True) # <<<
>
> > > > > 2) run appadmin once (it should work)
>
> > > > > 3) uncomment field and remove fake migrate
>
> > > > > db.define_table('performer',
> > > > >      ...
> > > > >      Field('musicbrainz_guid'),
> > > > >      ...)
>
> > > > > 4) run appadmin again. If you get an error something is wrong in your
> > > > > model.
>
> > > > > On Apr 23, 6:19 am, Matthew  wrote:
>
> > > > > > >>> perf = db(db.performer.id > 0).first()
>
> > > > > > Traceback (most recent call last):
> > > > > >   File "", line 1, in 
> > > > > > AttributeError: 'Set' object has no attribute 'first'>>> perf = 
> > > > > > db(db.performer.id > 0).select().first()
>
> > > > > > Traceback (most recent call last):
> > > > > >   File "", line 1, in 
> > > > > >   File "/home/matthew/dev/projects/webapp/src/app/gluon/sql.py", 
> > > > > > line
> > > > > > 3056, in select
> > > > > >     rows = response(query)
> > > > > >   File "/home/matthew/dev/projects/webapp/src/app/gluon/sql.py", 
> > > > > > line
> > > > > > 3051, in response
> > > > > >     db._execute(query)
> > > > > >   File "/home/matthew/dev/projects/webapp/src/app/gluon/sql.py", 
> > > > > > line
> > > > > > 958, in 
> > > > > >     self._execute = lambda *a, **b: self._cursor.execute(*a, **b)
> > > > > > ProgrammingError: column performer.musicbrainz_guid does not exist
> > > > > > LINE 1: ..._id, performer.facebook_id, performer.twitter_id,
> > > > > > performer
>
> > > > > > On Apr 22, 8:48 am, Kuba Kucharski  wrote:
>
> > > > > > > Can you show us the line with a query code?
>
> > > > > > > --
> > > > > > > Kuba
>
> > > > > > > --
> > > > > > > Subscription 
> > > > > > > settings:http://groups.google.com/group/web2py/subscribe?hl=en


[web2py] Re: Database migration does not work

2010-04-24 Thread Matthew
1.76.5


On Apr 24, 10:35 am, mdipierro  wrote:
> you must have a very old web2py version.
>
> On Apr 24, 9:25 am, Matthew  wrote:
>
> > I'm including previously-defined tables in other tables to reduce
> > maintenance. For example, I have "__web_resource" table that has
> > Wikipedia IDs, etc that I'm using in other tables.
>
> > When I tried your suggestion, I got the following error:
>
> > File "/home/matthew/dev/projects/webapp/src/app/applications/myapp/
> > models/db.py", line 114, in 
> >     __web_resource, fake_migrate=True)
> > TypeError: __init__() got an unexpected keyword argument
> > 'fake_migrate'
>
> > Is this due to the inclusion of other tables?
>
> > On Apr 23, 10:13 am, mdipierro  wrote:
>
> > > Something went wrong with migration. Do this:
>
> > > 1) comment the field that gives you problem and set migrate to fake:
>
> > > db.define_table('performer',
> > >      ...
> > > #     Field('musicbrainz_guid'),
> > >      ...,
> > >      fake_migrate=True) # <<<
>
> > > 2) run appadmin once (it should work)
>
> > > 3) uncomment field and remove fake migrate
>
> > > db.define_table('performer',
> > >      ...
> > >      Field('musicbrainz_guid'),
> > >      ...)
>
> > > 4) run appadmin again. If you get an error something is wrong in your
> > > model.
>
> > > On Apr 23, 6:19 am, Matthew  wrote:
>
> > > > >>> perf = db(db.performer.id > 0).first()
>
> > > > Traceback (most recent call last):
> > > >   File "", line 1, in 
> > > > AttributeError: 'Set' object has no attribute 'first'>>> perf = 
> > > > db(db.performer.id > 0).select().first()
>
> > > > Traceback (most recent call last):
> > > >   File "", line 1, in 
> > > >   File "/home/matthew/dev/projects/webapp/src/app/gluon/sql.py", line
> > > > 3056, in select
> > > >     rows = response(query)
> > > >   File "/home/matthew/dev/projects/webapp/src/app/gluon/sql.py", line
> > > > 3051, in response
> > > >     db._execute(query)
> > > >   File "/home/matthew/dev/projects/webapp/src/app/gluon/sql.py", line
> > > > 958, in 
> > > >     self._execute = lambda *a, **b: self._cursor.execute(*a, **b)
> > > > ProgrammingError: column performer.musicbrainz_guid does not exist
> > > > LINE 1: ..._id, performer.facebook_id, performer.twitter_id,
> > > > performer
>
> > > > On Apr 22, 8:48 am, Kuba Kucharski  wrote:
>
> > > > > Can you show us the line with a query code?
>
> > > > > --
> > > > > Kuba
>
> > > > > --
> > > > > Subscription 
> > > > > settings:http://groups.google.com/group/web2py/subscribe?hl=en


[web2py] Re: Database migration does not work

2010-04-24 Thread Matthew
I'm including previously-defined tables in other tables to reduce
maintenance. For example, I have "__web_resource" table that has
Wikipedia IDs, etc that I'm using in other tables.

When I tried your suggestion, I got the following error:

File "/home/matthew/dev/projects/webapp/src/app/applications/myapp/
models/db.py", line 114, in 
__web_resource, fake_migrate=True)
TypeError: __init__() got an unexpected keyword argument
'fake_migrate'

Is this due to the inclusion of other tables?


On Apr 23, 10:13 am, mdipierro  wrote:
> Something went wrong with migration. Do this:
>
> 1) comment the field that gives you problem and set migrate to fake:
>
> db.define_table('performer',
>      ...
> #     Field('musicbrainz_guid'),
>      ...,
>      fake_migrate=True) # <<<
>
> 2) run appadmin once (it should work)
>
> 3) uncomment field and remove fake migrate
>
> db.define_table('performer',
>      ...
>      Field('musicbrainz_guid'),
>      ...)
>
> 4) run appadmin again. If you get an error something is wrong in your
> model.
>
> On Apr 23, 6:19 am, Matthew  wrote:
>
> > >>> perf = db(db.performer.id > 0).first()
>
> > Traceback (most recent call last):
> >   File "", line 1, in 
> > AttributeError: 'Set' object has no attribute 'first'>>> perf = 
> > db(db.performer.id > 0).select().first()
>
> > Traceback (most recent call last):
> >   File "", line 1, in 
> >   File "/home/matthew/dev/projects/webapp/src/app/gluon/sql.py", line
> > 3056, in select
> >     rows = response(query)
> >   File "/home/matthew/dev/projects/webapp/src/app/gluon/sql.py", line
> > 3051, in response
> >     db._execute(query)
> >   File "/home/matthew/dev/projects/webapp/src/app/gluon/sql.py", line
> > 958, in 
> >     self._execute = lambda *a, **b: self._cursor.execute(*a, **b)
> > ProgrammingError: column performer.musicbrainz_guid does not exist
> > LINE 1: ..._id, performer.facebook_id, performer.twitter_id,
> > performer
>
> > On Apr 22, 8:48 am, Kuba Kucharski  wrote:
>
> > > Can you show us the line with a query code?
>
> > > --
> > > Kuba
>
> > > --
> > > Subscription 
> > > settings:http://groups.google.com/group/web2py/subscribe?hl=en


[web2py] Re: Database migration does not work

2010-04-23 Thread Matthew
>>> perf = db(db.performer.id > 0).first()
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'Set' object has no attribute 'first'
>>> perf = db(db.performer.id > 0).select().first()
Traceback (most recent call last):
  File "", line 1, in 
  File "/home/matthew/dev/projects/webapp/src/app/gluon/sql.py", line
3056, in select
rows = response(query)
  File "/home/matthew/dev/projects/webapp/src/app/gluon/sql.py", line
3051, in response
db._execute(query)
  File "/home/matthew/dev/projects/webapp/src/app/gluon/sql.py", line
958, in 
self._execute = lambda *a, **b: self._cursor.execute(*a, **b)
ProgrammingError: column performer.musicbrainz_guid does not exist
LINE 1: ..._id, performer.facebook_id, performer.twitter_id,
performer


On Apr 22, 8:48 am, Kuba Kucharski  wrote:
> Can you show us the line with a query code?
>
> --
> Kuba
>
> --
> Subscription settings:http://groups.google.com/group/web2py/subscribe?hl=en


[web2py] Database migration does not work

2010-04-22 Thread Matthew
Database: PostgreSQL
web2py: 1.76.5

Database migration doesn't seem to be working. I've added a new field
to my database, and sql.log says the table has been successfully
altered.

ALTER TABLE performer ADD musicbrainz_guid VARCHAR(512);
timestamp: 2010-04-19T20:55:38.147015

However, when I try to query my data in the admin console, I see this
message:

Invalid Query: column performer.musicbrainz_guid does not exist

I found this post,
http://groups.google.com/group/web2py/browse_thread/thread/23353f4a0265d009/de6dadfeee3580f0?lnk=gst&q=database+migration#de6dadfeee3580f0,
but I don't think it's related to my issue.

Thanks,
Matthew


[web2py] Re: Can't use db in InteractiveConsole

2010-03-28 Thread Matthew
Thanks! I've added this to my notes.

On Mar 28, 11:23 am, mdipierro  wrote:
> python web2py.py -S myapp  -M
>
> On Mar 28, 10:05 am, Matthew  wrote:
>
>
>
> > I'm trying to use web2py in the interactive console, but I'm getting
> > NameErrors when accessing 'db'. The strange thing is, just a few days
> > ago I was able to do this. Here is what I'm running:
>
> > python web2py.py -S myapp>>> from gluon.sql import *
> > >>> rows = db(db.mytable.id > 0)
>
> > Traceback (most recent call last):
> >   File "", line 1, in 
> > NameError: name 'db' is not defined
>
> > Any reason the console would not be able to find 'db' now? I did not
> > change anything on my system.

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Can't use db in InteractiveConsole

2010-03-28 Thread Matthew
I'm trying to use web2py in the interactive console, but I'm getting
NameErrors when accessing 'db'. The strange thing is, just a few days
ago I was able to do this. Here is what I'm running:

python web2py.py -S myapp
>>> from gluon.sql import *
>>> rows = db(db.mytable.id > 0)
Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'db' is not defined

Any reason the console would not be able to find 'db' now? I did not
change anything on my system.

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



  1   2   >