[web2py] Re: uploadfolder=request.folder not working as it expected

2020-10-08 Thread mostwanted
This worked, thanks Villas

On Tuesday, October 6, 2020 at 1:43:37 PM UTC+2 villas wrote:

> Maybe you are not using a separator (eg '/').  Try something like this:
>
> uploadfolder = os.path.join(request.folder, 'static/docs') 
>
> On Monday, 5 October 2020 at 17:21:43 UTC+1 mostwanted wrote:
>
>> *uploadfolder=request.folder+'static/docs'  *suddenly aint working as it 
>> should, initially is worked. What should happen is that when i save a PDF 
>> file it should be save in a static folder called *docs  *& in a database 
>> table but the *docs *folder in static doesnt get created now I am 
>> getting the *404 NOT FOUND *when i try to view or open the PDF. I dont 
>> know why this is suddenly happening when it used to work, do i need import 
>> some python library or change my code somwhere?
>>
>> *CODE:*
>> *model:*
>>
>>
>>
>>
>> *db.define_table('pdfs',Field('Form_Name', 
>> label=SPAN('Document Title', _style="font-weight: bold;"), widget=lambda 
>> field, value:SQLFORM.widgets.string.widget(field, value, 
>> _placeholder="Invoice/PO/Quotation Name")),Field('status', 
>> 'boolean', label=SPAN('Status (For Invoices Only)', _style="font-weight: 
>> bold;")),Field('status_condition', 
>> requires=IS_IN_SET(['Quotation', 'Paid', 'Unpaid', 'Cancelled', 'Paid With 
>> Balance'], zero=None), label=SPAN('Status Condition', _style="font-weight: 
>> bold;")),
>> Field('fileS','upload',uploadfolder=request.folder+'static/docs', 
>> label=SPAN('Upload Files', _style="font-weight: bold;")))*
>>
>> *CONTROLLER:*
>>
>>
>>
>>
>> *def saveDocument():form=SQLFORM(db.pdfs)if 
>> form.process().accepted:response.flash=T('Form Saved')return 
>> locals()*
>>
>>
>>
>> *def viewer():row = db(db.pdfs.id 
>> ==request.args(0)).select(db.pdfs.fileS).first()
>> redirect(URL('static','docs',args=row.fileS))*
>>
>>
>> *VIEW FOR SAVED DOCUMENT VIEWING*
>>
>> *{{extend 'layout.html'}}*
>>
>>
>>
>> *{{for details in details2: }}{{=A(details.Form_Name, 
>> _target="_blank", _href=URL('viewer', args=details.id 
>> ))}} {{pass}}*
>>
>> Regards;
>>
>> Mostwanted
>>
>

-- 
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/30edba5a-f0de-49ae-a295-5c80319d5081n%40googlegroups.com.


[web2py] ckEditor v4.5.7 function download

2020-10-08 Thread lcham...@gmail.com

Hello,

i don't know why , i can upload a pic from a form using ckeditor
/app/download/plugin_ckeditor_upload.upload.a7dc4103618b052d.57494e5f32303230313030315f31365f35325f31305f50726f2e6a7067.jpg

i submit the record is registered, , i visualise the view , the code source 
is correct



and the pic is not displayed . If i use an existing  pic in the directory 
uploads  from a table with an another name  like 
mytable.myfield.b77ad521b8552f22.43656c6c42696f6c6f67792e6a7067.jpg
it works

why ? thank you

Note : if i browse the pics with ckeditor, i see the names but they are not 
displayed

-- 
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/989a9714-8eba-46ba-a0be-be122d8bcecbn%40googlegroups.com.


[web2py] Re: SQLFLORMGRID

2020-10-08 Thread lcham...@gmail.com
good idea it works , thank you

i have to practise more


Le jeudi 8 octobre 2020 à 16:05:39 UTC+2, Alex Beskopilny a écrit :

> maybe you could do this
>
> def art_manage():
>
> if  len(request.args) >= 2 and ('new' == request.args[0]):
># some code
>return ' create '
>
>
> records= SQLFORM.grid(query=db.t_art,maxtextlength = 
> 40,deletable=False,create=True, fields=[db.t_art.f_name, db.t_art.f_team, 
> db.t_art.f_tit])
> return dict(records=records)
>

-- 
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/012f237e-ed1e-44b0-8c5e-cc1917112990n%40googlegroups.com.


Re: [web2py] Re: Db fields in the "links" of the grid

2020-10-08 Thread Jim S
I looked back through my code and didn't find an instance where I had 
custom links on a grid with a left join.  And, I've been coding in web2py 
since 2011.

-Jim

On Thursday, October 8, 2020 at 10:38:12 AM UTC-5, Vlad wrote:
>
> Jim,
>
> Thank you very much for your help,
>
> This is a perfect solution for me. It just took me time to figure out what 
> was going on. 
>
> I don't think that this can be classified as a bug in web2py. It's just 
> very confusing for anybody who encounters this situation. However, if I am 
> the only one who has encountered it for the past 10 years, we can live with 
> it :) 
>
> Thank you! 
>
>
> On Thu, Oct 8, 2020, 10:58 AM Jim S > 
> wrote:
>
>> Vlad
>>
>> The behavior is exactly as you said it is.
>>
>> I don't know if I'd go as far as saying this is a problem with web2py.  I 
>> got around it by using this instead of the try/except in GetCartsGridLink
>>
>> id = row.cart.id if 'cart' in row else row.id
>>
>> I know it isn't ideal and isn't what you were looking for, but as you 
>> found, it isn't that hard to get around.  I'm just surprised that I haven't 
>> run into this over the years I've been working with web2py because I do 
>> similar linking in my apps all the time.
>>
>> Sorry I couldn't be of more help.  
>>
>> Anyone else have any thoughts on this?
>>
>> -Jim
>>
>>
>> On Thursday, October 8, 2020 at 8:45:41 AM UTC-5, Vlad wrote:
>>>
>>> Just realized that there is another field, virtual one, referenced in 
>>> the code. In case the problem doesn't reproduce without it, here is the 
>>> definition (but I don't think that this would be necessary): 
>>>
>>> db.cart.count = Field.Virtual(lambda row: db(db.cart_content.cart==
>>> row.cart.id
>>> ).select(db.cart_content.quantity.count()).first()[db.cart_content.quantity.count()])
>>>
>>> And here is the model (and data attached):
>>>
>>> db.define_table('cart_content',
>>>Field('cart','reference cart'),
>>>Field('product','reference product'),
>>>Field('formula','reference formula'),
>>>Field('description','string',default=None),
>>>Field('flavor','reference flavor'),
>>>Field('quantity','integer',requires=[IS_NOT_EMPTY()],default=1),
>>>Field('price','integer',represent=lambda x, row: '$' + str(x/100)),
>>>Field('imported','boolean'),
>>>auth.signature)
>>>
>>>
>>>
>>> On Thursday, October 8, 2020 at 9:37:34 AM UTC-4 Vlad wrote:
>>>
 Sure, the sample data attached (are these 2 tables enough?), and the 
 models are as follows: 

 db.define_table('cart',
Field('description','string',default='My Cart (%s)' % 
 str((datetime.now().strftime("%m/%d/%Y %I:%M%p",
auth.signature)

 db.define_table('cart_ownership',
 Field('description', 'string'),
 Field('boss','reference auth_user'),
 Field('cart', 'reference cart'),
 Field('status', 'string', requires=IS_IN_SET(['current','onhold'])),
 auth.signature)


 On Thursday, October 8, 2020 at 9:18:53 AM UTC-4 Jim S wrote:

> any chance you have a model and a small sample-set of data you could 
> share that cause the inconsistencies to be shown?  Just 3 records or so 
> in 
> each table that can show the inconsistency?
>
>
> On Thursday, October 8, 2020 at 7:38:48 AM UTC-5, Vlad wrote:
>
>> Yes, there is always a corresponding record in the second table 
>> (doesn't have to be, but I do clean up ownerless carts, so when I am 
>> testing things, the corresponding record is always there). 
>>
>> Here is the complete creation of the grid (where GetCartsGridLink is 
>> the function that now has try/except clause to flip between row.id 
>> and row.cart.id):
>>
>> def show_carts():
>>> query = db.cart
>>> headers = {'cart.id':'ID', 'cart.description':'Name', 
>>> 'cart_ownership.boss':'Owner', 'cart_ownership.status':'Status', 
>>> 'cart.count':'Items'}
>>> fields = [db.cart.id, db.cart.description, 
>>> db.cart_ownership.boss, db.cart_ownership.status, db.cart.count]
>>> links = [dict(header='View', body=GetCartsGridLink)]
>>>
>>> grid = SQLFORM.grid(query,
>>> editable=True,
>>> details=True,
>>> create=True,
>>> links=links,
>>> fields=fields,
>>> headers=headers,
>>> orderby=[~db.cart.created_on],
>>> left = [db.cart_ownership.on(db.cart.id
>>> ==db.cart_ownership.cart)],
>>> formname='carts_grid',
>>> field_id=db.cart.id,
>>> )
>>>
>>> return grid
>>
>>  
>>
>>
>>
>> On Wed, Oct 7, 2020 at 11:12 PM Jim Steil  wrote:
>>
> I will take a look tomorrow to see 

Re: [web2py] Re: Db fields in the "links" of the grid

2020-10-08 Thread Eliezer (Vlad) Tseytkin
Jim,

Thank you very much for your help,

This is a perfect solution for me. It just took me time to figure out what
was going on.

I don't think that this can be classified as a bug in web2py. It's just
very confusing for anybody who encounters this situation. However, if I am
the only one who has encountered it for the past 10 years, we can live with
it :)

Thank you!


On Thu, Oct 8, 2020, 10:58 AM Jim S  wrote:

> Vlad
>
> The behavior is exactly as you said it is.
>
> I don't know if I'd go as far as saying this is a problem with web2py.  I
> got around it by using this instead of the try/except in GetCartsGridLink
>
> id = row.cart.id if 'cart' in row else row.id
>
> I know it isn't ideal and isn't what you were looking for, but as you
> found, it isn't that hard to get around.  I'm just surprised that I haven't
> run into this over the years I've been working with web2py because I do
> similar linking in my apps all the time.
>
> Sorry I couldn't be of more help.
>
> Anyone else have any thoughts on this?
>
> -Jim
>
>
> On Thursday, October 8, 2020 at 8:45:41 AM UTC-5, Vlad wrote:
>>
>> Just realized that there is another field, virtual one, referenced in the
>> code. In case the problem doesn't reproduce without it, here is the
>> definition (but I don't think that this would be necessary):
>>
>> db.cart.count = Field.Virtual(lambda row: db(db.cart_content.cart==
>> row.cart.id
>> ).select(db.cart_content.quantity.count()).first()[db.cart_content.quantity.count()])
>>
>> And here is the model (and data attached):
>>
>> db.define_table('cart_content',
>>Field('cart','reference cart'),
>>Field('product','reference product'),
>>Field('formula','reference formula'),
>>Field('description','string',default=None),
>>Field('flavor','reference flavor'),
>>Field('quantity','integer',requires=[IS_NOT_EMPTY()],default=1),
>>Field('price','integer',represent=lambda x, row: '$' + str(x/100)),
>>Field('imported','boolean'),
>>auth.signature)
>>
>>
>>
>> On Thursday, October 8, 2020 at 9:37:34 AM UTC-4 Vlad wrote:
>>
>>> Sure, the sample data attached (are these 2 tables enough?), and the
>>> models are as follows:
>>>
>>> db.define_table('cart',
>>>Field('description','string',default='My Cart (%s)' %
>>> str((datetime.now().strftime("%m/%d/%Y %I:%M%p",
>>>auth.signature)
>>>
>>> db.define_table('cart_ownership',
>>> Field('description', 'string'),
>>> Field('boss','reference auth_user'),
>>> Field('cart', 'reference cart'),
>>> Field('status', 'string', requires=IS_IN_SET(['current','onhold'])),
>>> auth.signature)
>>>
>>>
>>> On Thursday, October 8, 2020 at 9:18:53 AM UTC-4 Jim S wrote:
>>>
 any chance you have a model and a small sample-set of data you could
 share that cause the inconsistencies to be shown?  Just 3 records or so in
 each table that can show the inconsistency?


 On Thursday, October 8, 2020 at 7:38:48 AM UTC-5, Vlad wrote:

> Yes, there is always a corresponding record in the second table
> (doesn't have to be, but I do clean up ownerless carts, so when I am
> testing things, the corresponding record is always there).
>
> Here is the complete creation of the grid (where GetCartsGridLink is
> the function that now has try/except clause to flip between row.id
> and row.cart.id):
>
> def show_carts():
>> query = db.cart
>> headers = {'cart.id':'ID', 'cart.description':'Name',
>> 'cart_ownership.boss':'Owner', 'cart_ownership.status':'Status',
>> 'cart.count':'Items'}
>> fields = [db.cart.id, db.cart.description,
>> db.cart_ownership.boss, db.cart_ownership.status, db.cart.count]
>> links = [dict(header='View', body=GetCartsGridLink)]
>>
>> grid = SQLFORM.grid(query,
>> editable=True,
>> details=True,
>> create=True,
>> links=links,
>> fields=fields,
>> headers=headers,
>> orderby=[~db.cart.created_on],
>> left = [db.cart_ownership.on(db.cart.id
>> ==db.cart_ownership.cart)],
>> formname='carts_grid',
>> field_id=db.cart.id,
>> )
>>
>> return grid
>
>
>
>
>
> On Wed, Oct 7, 2020 at 11:12 PM Jim Steil  wrote:
>
 I will take a look tomorrow to see if I can code something up to
>> reproduce the error.
>>
>> Which tackle are you setting as the 'primary' table, by that I mean
>> what field are you specifying in the field_id parameter?  And, is there
>> ALWAYS a matching record in the secondary table?
>>
>> Oh, just thought of another thing. How about specifying db.cart.id
>> in fields=[], and the also specifying it in hidden_fields=[]?

Re: [web2py] Re: Db fields in the "links" of the grid

2020-10-08 Thread Jim S
Vlad

The behavior is exactly as you said it is.

I don't know if I'd go as far as saying this is a problem with web2py.  I 
got around it by using this instead of the try/except in GetCartsGridLink

id = row.cart.id if 'cart' in row else row.id

I know it isn't ideal and isn't what you were looking for, but as you 
found, it isn't that hard to get around.  I'm just surprised that I haven't 
run into this over the years I've been working with web2py because I do 
similar linking in my apps all the time.

Sorry I couldn't be of more help.  

Anyone else have any thoughts on this?

-Jim


On Thursday, October 8, 2020 at 8:45:41 AM UTC-5, Vlad wrote:
>
> Just realized that there is another field, virtual one, referenced in the 
> code. In case the problem doesn't reproduce without it, here is the 
> definition (but I don't think that this would be necessary): 
>
> db.cart.count = Field.Virtual(lambda row: db(db.cart_content.cart==
> row.cart.id
> ).select(db.cart_content.quantity.count()).first()[db.cart_content.quantity.count()])
>
> And here is the model (and data attached):
>
> db.define_table('cart_content',
>Field('cart','reference cart'),
>Field('product','reference product'),
>Field('formula','reference formula'),
>Field('description','string',default=None),
>Field('flavor','reference flavor'),
>Field('quantity','integer',requires=[IS_NOT_EMPTY()],default=1),
>Field('price','integer',represent=lambda x, row: '$' + str(x/100)),
>Field('imported','boolean'),
>auth.signature)
>
>
>
> On Thursday, October 8, 2020 at 9:37:34 AM UTC-4 Vlad wrote:
>
>> Sure, the sample data attached (are these 2 tables enough?), and the 
>> models are as follows: 
>>
>> db.define_table('cart',
>>Field('description','string',default='My Cart (%s)' % 
>> str((datetime.now().strftime("%m/%d/%Y %I:%M%p",
>>auth.signature)
>>
>> db.define_table('cart_ownership',
>> Field('description', 'string'),
>> Field('boss','reference auth_user'),
>> Field('cart', 'reference cart'),
>> Field('status', 'string', requires=IS_IN_SET(['current','onhold'])),
>> auth.signature)
>>
>>
>> On Thursday, October 8, 2020 at 9:18:53 AM UTC-4 Jim S wrote:
>>
>>> any chance you have a model and a small sample-set of data you could 
>>> share that cause the inconsistencies to be shown?  Just 3 records or so in 
>>> each table that can show the inconsistency?
>>>
>>>
>>> On Thursday, October 8, 2020 at 7:38:48 AM UTC-5, Vlad wrote:
>>>
 Yes, there is always a corresponding record in the second table 
 (doesn't have to be, but I do clean up ownerless carts, so when I am 
 testing things, the corresponding record is always there). 

 Here is the complete creation of the grid (where GetCartsGridLink is 
 the function that now has try/except clause to flip between row.id and 
 row.cart.id):

 def show_carts():
> query = db.cart
> headers = {'cart.id':'ID', 'cart.description':'Name', 
> 'cart_ownership.boss':'Owner', 'cart_ownership.status':'Status', 
> 'cart.count':'Items'}
> fields = [db.cart.id, db.cart.description, 
> db.cart_ownership.boss, db.cart_ownership.status, db.cart.count]
> links = [dict(header='View', body=GetCartsGridLink)]
>
> grid = SQLFORM.grid(query,
> editable=True,
> details=True,
> create=True,
> links=links,
> fields=fields,
> headers=headers,
> orderby=[~db.cart.created_on],
> left = [db.cart_ownership.on(db.cart.id
> ==db.cart_ownership.cart)],
> formname='carts_grid',
> field_id=db.cart.id,
> )
>
> return grid

  



 On Wed, Oct 7, 2020 at 11:12 PM Jim Steil  wrote:

>>> I will take a look tomorrow to see if I can code something up to 
> reproduce the error.
>
> Which tackle are you setting as the 'primary' table, by that I mean 
> what field are you specifying in the field_id parameter?  And, is there 
> ALWAYS a matching record in the secondary table? 
>
> Oh, just thought of another thing. How about specifying db.cart.id in 
> fields=[], and the also specifying it in hidden_fields=[]?
>
> Jim
>
>
>
> On Wed, Oct 7, 2020, 9:50 PM Eliezer (Vlad) Tseytkin <
> westga...@gmail.com> wrote:
>
 Jom, you said " I'm having trouble understanding why you need the 
>> try/except" - this is exactly the trouble I'm having too :) 
>>
>> I do use the left join. So I should simply specify the table name - 
>> correct?
>>
>> Well, if I do - then the grid itself works fine, but once I click 
>> "view" or "edit"  - it crashes. To fix that crash, 

[web2py] Re: SQLFLORMGRID

2020-10-08 Thread Alex Beskopilny
maybe you could do this

def art_manage():

if  len(request.args) >= 2 and ('new' == request.args[0]):
   # some code
   return ' create '


records= SQLFORM.grid(query=db.t_art,maxtextlength = 
40,deletable=False,create=True, fields=[db.t_art.f_name, db.t_art.f_team, 
db.t_art.f_tit])
return dict(records=records)

-- 
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/0f266063-c05b-4edd-9a2e-b76a8144bc89o%40googlegroups.com.


Re: [web2py] Re: Db fields in the "links" of the grid

2020-10-08 Thread Vlad
Just realized that there is another field, virtual one, referenced in the 
code. In case the problem doesn't reproduce without it, here is the 
definition (but I don't think that this would be necessary): 

db.cart.count = Field.Virtual(lambda row: 
db(db.cart_content.cart==row.cart.id).select(db.cart_content.quantity.count()).first()[db.cart_content.quantity.count()])

And here is the model (and data attached):

db.define_table('cart_content',
   Field('cart','reference cart'),
   Field('product','reference product'),
   Field('formula','reference formula'),
   Field('description','string',default=None),
   Field('flavor','reference flavor'),
   Field('quantity','integer',requires=[IS_NOT_EMPTY()],default=1),
   Field('price','integer',represent=lambda x, row: '$' + str(x/100)),
   Field('imported','boolean'),
   auth.signature)



On Thursday, October 8, 2020 at 9:37:34 AM UTC-4 Vlad wrote:

> Sure, the sample data attached (are these 2 tables enough?), and the 
> models are as follows: 
>
> db.define_table('cart',
>Field('description','string',default='My Cart (%s)' % 
> str((datetime.now().strftime("%m/%d/%Y %I:%M%p",
>auth.signature)
>
> db.define_table('cart_ownership',
> Field('description', 'string'),
> Field('boss','reference auth_user'),
> Field('cart', 'reference cart'),
> Field('status', 'string', requires=IS_IN_SET(['current','onhold'])),
> auth.signature)
>
>
> On Thursday, October 8, 2020 at 9:18:53 AM UTC-4 Jim S wrote:
>
>> any chance you have a model and a small sample-set of data you could 
>> share that cause the inconsistencies to be shown?  Just 3 records or so in 
>> each table that can show the inconsistency?
>>
>>
>> On Thursday, October 8, 2020 at 7:38:48 AM UTC-5, Vlad wrote:
>>
>>> Yes, there is always a corresponding record in the second table (doesn't 
>>> have to be, but I do clean up ownerless carts, so when I am testing things, 
>>> the corresponding record is always there). 
>>>
>>> Here is the complete creation of the grid (where GetCartsGridLink is the 
>>> function that now has try/except clause to flip between row.id and 
>>> row.cart.id):
>>>
>>> def show_carts():
 query = db.cart
 headers = {'cart.id':'ID', 'cart.description':'Name', 
 'cart_ownership.boss':'Owner', 'cart_ownership.status':'Status', 
 'cart.count':'Items'}
 fields = [db.cart.id, db.cart.description, db.cart_ownership.boss, 
 db.cart_ownership.status, db.cart.count]
 links = [dict(header='View', body=GetCartsGridLink)]

 grid = SQLFORM.grid(query,
 editable=True,
 details=True,
 create=True,
 links=links,
 fields=fields,
 headers=headers,
 orderby=[~db.cart.created_on],
 left = [db.cart_ownership.on(db.cart.id
 ==db.cart_ownership.cart)],
 formname='carts_grid',
 field_id=db.cart.id,
 )

 return grid
>>>
>>>  
>>>
>>>
>>>
>>> On Wed, Oct 7, 2020 at 11:12 PM Jim Steil  wrote:
>>>
>> I will take a look tomorrow to see if I can code something up to 
 reproduce the error.

 Which tackle are you setting as the 'primary' table, by that I mean 
 what field are you specifying in the field_id parameter?  And, is there 
 ALWAYS a matching record in the secondary table? 

 Oh, just thought of another thing. How about specifying db.cart.id in 
 fields=[], and the also specifying it in hidden_fields=[]?

 Jim



 On Wed, Oct 7, 2020, 9:50 PM Eliezer (Vlad) Tseytkin <
 westga...@gmail.com> wrote:

>>> Jom, you said " I'm having trouble understanding why you need the 
> try/except" - this is exactly the trouble I'm having too :) 
>
> I do use the left join. So I should simply specify the table name - 
> correct?
>
> Well, if I do - then the grid itself works fine, but once I click 
> "view" or "edit"  - it crashes. To fix that crash, I must specify 
> try/except clause in the function used by the "links". WIthout that 
> try/except the actions of view and edit don' work! 
>
> That's exactly what I am saying - with the left join, the grid expects 
> the table name, but the view/edit actions of this grid expect no table 
> name 
> and in fact crash when the table name is there.  
>
> On Wed, Oct 7, 2020 at 10:38 PM Jim S  wrote:
>
 I'm having trouble understanding why you need the try/except.  To me it 
>> seems like "if you specify a left" -> you need to use the table name.  
>> "if 
>> you don't specify a left" -> omit the table name
>>
>> Do you have an occasion where sometimes different rows in the same 
>> grid require you to specify the 

Re: [web2py] Re: Db fields in the "links" of the grid

2020-10-08 Thread Vlad
Sure, the sample data attached (are these 2 tables enough?), and the models 
are as follows: 

db.define_table('cart',
   Field('description','string',default='My Cart (%s)' % 
str((datetime.now().strftime("%m/%d/%Y %I:%M%p",
   auth.signature)

db.define_table('cart_ownership',
Field('description', 'string'),
Field('boss','reference auth_user'),
Field('cart', 'reference cart'),
Field('status', 'string', requires=IS_IN_SET(['current','onhold'])),
auth.signature)


On Thursday, October 8, 2020 at 9:18:53 AM UTC-4 Jim S wrote:

> any chance you have a model and a small sample-set of data you could share 
> that cause the inconsistencies to be shown?  Just 3 records or so in each 
> table that can show the inconsistency?
>
>
> On Thursday, October 8, 2020 at 7:38:48 AM UTC-5, Vlad wrote:
>
>> Yes, there is always a corresponding record in the second table (doesn't 
>> have to be, but I do clean up ownerless carts, so when I am testing things, 
>> the corresponding record is always there). 
>>
>> Here is the complete creation of the grid (where GetCartsGridLink is the 
>> function that now has try/except clause to flip between row.id and 
>> row.cart.id):
>>
>> def show_carts():
>>> query = db.cart
>>> headers = {'cart.id':'ID', 'cart.description':'Name', 
>>> 'cart_ownership.boss':'Owner', 'cart_ownership.status':'Status', 
>>> 'cart.count':'Items'}
>>> fields = [db.cart.id, db.cart.description, db.cart_ownership.boss, 
>>> db.cart_ownership.status, db.cart.count]
>>> links = [dict(header='View', body=GetCartsGridLink)]
>>>
>>> grid = SQLFORM.grid(query,
>>> editable=True,
>>> details=True,
>>> create=True,
>>> links=links,
>>> fields=fields,
>>> headers=headers,
>>> orderby=[~db.cart.created_on],
>>> left = [db.cart_ownership.on(db.cart.id
>>> ==db.cart_ownership.cart)],
>>> formname='carts_grid',
>>> field_id=db.cart.id,
>>> )
>>>
>>> return grid
>>
>>  
>>
>>
>>
>> On Wed, Oct 7, 2020 at 11:12 PM Jim Steil  wrote:
>>
> I will take a look tomorrow to see if I can code something up to reproduce 
>>> the error.
>>>
>>> Which tackle are you setting as the 'primary' table, by that I mean what 
>>> field are you specifying in the field_id parameter?  And, is there ALWAYS a 
>>> matching record in the secondary table? 
>>>
>>> Oh, just thought of another thing. How about specifying db.cart.id in 
>>> fields=[], and the also specifying it in hidden_fields=[]?
>>>
>>> Jim
>>>
>>>
>>>
>>> On Wed, Oct 7, 2020, 9:50 PM Eliezer (Vlad) Tseytkin <
>>> westga...@gmail.com> wrote:
>>>
>> Jom, you said " I'm having trouble understanding why you need the 
 try/except" - this is exactly the trouble I'm having too :) 

 I do use the left join. So I should simply specify the table name - 
 correct?

 Well, if I do - then the grid itself works fine, but once I click 
 "view" or "edit"  - it crashes. To fix that crash, I must specify 
 try/except clause in the function used by the "links". WIthout that 
 try/except the actions of view and edit don' work! 

 That's exactly what I am saying - with the left join, the grid expects 
 the table name, but the view/edit actions of this grid expect no table 
 name 
 and in fact crash when the table name is there.  

 On Wed, Oct 7, 2020 at 10:38 PM Jim S  wrote:

>>> I'm having trouble understanding why you need the try/except.  To me it 
> seems like "if you specify a left" -> you need to use the table name.  
> "if 
> you don't specify a left" -> omit the table name
>
> Do you have an occasion where sometimes different rows in the same 
> grid require you to specify the field differently?
>
> -Jim
>
> On Wednesday, October 7, 2020 at 9:30:28 PM UTC-5, Vlad wrote:
>>
>> But shouldn't it be the same for the grid and for the record of the 
>> grid? The difference confuses me - having to specify the table should be 
>> consistent when I use the grid for all the transactions of the 
>> grid, including view/edit etc.. 
>>
>> In other words, having to specify the table is perfectly fine - but 
>> it should be consistent and I should as well specify the table for the 
>> view/edit action of the grid record. Different structures for the gird 
>> and 
>> fo the record of the grid seems inconsistent to me.It took me time to 
>> figure this out - now that I know how this works, I simply have the 
>> try/except to solve it - this makes practical sense, as it solves the 
>> problem, but it makes no logical sense. Do you know what I mean? Anybody 
>> who encounters such a situation will presumably be messed up and 

Re: [web2py] Re: Db fields in the "links" of the grid

2020-10-08 Thread Jim S
any chance you have a model and a small sample-set of data you could share 
that cause the inconsistencies to be shown?  Just 3 records or so in each 
table that can show the inconsistency?

On Thursday, October 8, 2020 at 7:38:48 AM UTC-5, Vlad wrote:
>
> Yes, there is always a corresponding record in the second table (doesn't 
> have to be, but I do clean up ownerless carts, so when I am testing things, 
> the corresponding record is always there). 
>
> Here is the complete creation of the grid (where GetCartsGridLink is the 
> function that now has try/except clause to flip between row.id and 
> row.cart.id):
>
> def show_carts():
>> query = db.cart
>> headers = {'cart.id':'ID', 'cart.description':'Name', 
>> 'cart_ownership.boss':'Owner', 'cart_ownership.status':'Status', 
>> 'cart.count':'Items'}
>> fields = [db.cart.id, db.cart.description, db.cart_ownership.boss, 
>> db.cart_ownership.status, db.cart.count]
>> links = [dict(header='View', body=GetCartsGridLink)]
>>
>> grid = SQLFORM.grid(query,
>> editable=True,
>> details=True,
>> create=True,
>> links=links,
>> fields=fields,
>> headers=headers,
>> orderby=[~db.cart.created_on],
>> left = [db.cart_ownership.on(db.cart.id
>> ==db.cart_ownership.cart)],
>> formname='carts_grid',
>> field_id=db.cart.id,
>> )
>>
>> return grid
>
>  
>
>
>
> On Wed, Oct 7, 2020 at 11:12 PM Jim Steil > 
> wrote:
>
>> I will take a look tomorrow to see if I can code something up to 
>> reproduce the error.
>>
>> Which tackle are you setting as the 'primary' table, by that I mean what 
>> field are you specifying in the field_id parameter?  And, is there ALWAYS a 
>> matching record in the secondary table? 
>>
>> Oh, just thought of another thing. How about specifying db.cart.id in 
>> fields=[], and the also specifying it in hidden_fields=[]?
>>
>> Jim
>>
>>
>>
>> On Wed, Oct 7, 2020, 9:50 PM Eliezer (Vlad) Tseytkin > > wrote:
>>
>>> Jom, you said " I'm having trouble understanding why you need the 
>>> try/except" - this is exactly the trouble I'm having too :) 
>>>
>>> I do use the left join. So I should simply specify the table name - 
>>> correct?
>>>
>>> Well, if I do - then the grid itself works fine, but once I click "view" 
>>> or "edit"  - it crashes. To fix that crash, I must specify try/except 
>>> clause in the function used by the "links". WIthout that try/except the 
>>> actions of view and edit don' work! 
>>>
>>> That's exactly what I am saying - with the left join, the grid expects 
>>> the table name, but the view/edit actions of this grid expect no table name 
>>> and in fact crash when the table name is there.  
>>>
>>> On Wed, Oct 7, 2020 at 10:38 PM Jim S > 
>>> wrote:
>>>
 I'm having trouble understanding why you need the try/except.  To me it 
 seems like "if you specify a left" -> you need to use the table name.  "if 
 you don't specify a left" -> omit the table name

 Do you have an occasion where sometimes different rows in the same grid 
 require you to specify the field differently?

 -Jim

 On Wednesday, October 7, 2020 at 9:30:28 PM UTC-5, Vlad wrote:
>
> But shouldn't it be the same for the grid and for the record of the 
> grid? The difference confuses me - having to specify the table should be 
> consistent when I use the grid for all the transactions of the 
> grid, including view/edit etc.. 
>
> In other words, having to specify the table is perfectly fine - but it 
> should be consistent and I should as well specify the table for the 
> view/edit action of the grid record. Different structures for the gird 
> and 
> fo the record of the grid seems inconsistent to me.It took me time to 
> figure this out - now that I know how this works, I simply have the 
> try/except to solve it - this makes practical sense, as it solves the 
> problem, but it makes no logical sense. Do you know what I mean? Anybody 
> who encounters such a situation will presumably be messed up and have to 
> spend time figuring out what's going on. 
>
> On Wed, Oct 7, 2020 at 10:22 PM Jim Steil  wrote:
>
>> I think that is a result of having a left join specified.  With the 
>> left join you now have to specify which table the field is in as well.
>>
>> Or, am I missing something?
>>
>> -Jim
>>
>> On Wed, Oct 7, 2020 at 9:13 PM Eliezer (Vlad) Tseytkin <
>> westga...@gmail.com> wrote:
>>
>>> Jim, 
>>>
>>> Thank you for the suggestions. 
>>>
>>> I do specify field_id (it wasn't there in the simplified code, but 
>>> the complete code does have it). 
>>>
>>> When I use a function, instead 

Re: [web2py] Re: Db fields in the "links" of the grid

2020-10-08 Thread Eliezer (Vlad) Tseytkin
Yes, there is always a corresponding record in the second table (doesn't
have to be, but I do clean up ownerless carts, so when I am testing things,
the corresponding record is always there).

Here is the complete creation of the grid (where GetCartsGridLink is the
function that now has try/except clause to flip between row.id and
row.cart.id):

def show_carts():
> query = db.cart
> headers = {'cart.id':'ID', 'cart.description':'Name',
> 'cart_ownership.boss':'Owner', 'cart_ownership.status':'Status',
> 'cart.count':'Items'}
> fields = [db.cart.id, db.cart.description, db.cart_ownership.boss,
> db.cart_ownership.status, db.cart.count]
> links = [dict(header='View', body=GetCartsGridLink)]
>
> grid = SQLFORM.grid(query,
> editable=True,
> details=True,
> create=True,
> links=links,
> fields=fields,
> headers=headers,
> orderby=[~db.cart.created_on],
> left = [db.cart_ownership.on(db.cart.id
> ==db.cart_ownership.cart)],
> formname='carts_grid',
> field_id=db.cart.id,
> )
>
> return grid





On Wed, Oct 7, 2020 at 11:12 PM Jim Steil  wrote:

> I will take a look tomorrow to see if I can code something up to reproduce
> the error.
>
> Which tackle are you setting as the 'primary' table, by that I mean what
> field are you specifying in the field_id parameter?  And, is there ALWAYS a
> matching record in the secondary table?
>
> Oh, just thought of another thing. How about specifying db.cart.id in
> fields=[], and the also specifying it in hidden_fields=[]?
>
> Jim
>
>
>
> On Wed, Oct 7, 2020, 9:50 PM Eliezer (Vlad) Tseytkin <
> westgate6...@gmail.com> wrote:
>
>> Jom, you said " I'm having trouble understanding why you need the
>> try/except" - this is exactly the trouble I'm having too :)
>>
>> I do use the left join. So I should simply specify the table name -
>> correct?
>>
>> Well, if I do - then the grid itself works fine, but once I click "view"
>> or "edit"  - it crashes. To fix that crash, I must specify try/except
>> clause in the function used by the "links". WIthout that try/except the
>> actions of view and edit don' work!
>>
>> That's exactly what I am saying - with the left join, the grid expects
>> the table name, but the view/edit actions of this grid expect no table name
>> and in fact crash when the table name is there.
>>
>> On Wed, Oct 7, 2020 at 10:38 PM Jim S  wrote:
>>
>>> I'm having trouble understanding why you need the try/except.  To me it
>>> seems like "if you specify a left" -> you need to use the table name.  "if
>>> you don't specify a left" -> omit the table name
>>>
>>> Do you have an occasion where sometimes different rows in the same grid
>>> require you to specify the field differently?
>>>
>>> -Jim
>>>
>>> On Wednesday, October 7, 2020 at 9:30:28 PM UTC-5, Vlad wrote:

 But shouldn't it be the same for the grid and for the record of the
 grid? The difference confuses me - having to specify the table should be
 consistent when I use the grid for all the transactions of the
 grid, including view/edit etc..

 In other words, having to specify the table is perfectly fine - but it
 should be consistent and I should as well specify the table for the
 view/edit action of the grid record. Different structures for the gird and
 fo the record of the grid seems inconsistent to me.It took me time to
 figure this out - now that I know how this works, I simply have the
 try/except to solve it - this makes practical sense, as it solves the
 problem, but it makes no logical sense. Do you know what I mean? Anybody
 who encounters such a situation will presumably be messed up and have to
 spend time figuring out what's going on.

 On Wed, Oct 7, 2020 at 10:22 PM Jim Steil  wrote:

> I think that is a result of having a left join specified.  With the
> left join you now have to specify which table the field is in as well.
>
> Or, am I missing something?
>
> -Jim
>
> On Wed, Oct 7, 2020 at 9:13 PM Eliezer (Vlad) Tseytkin <
> westga...@gmail.com> wrote:
>
>> Jim,
>>
>> Thank you for the suggestions.
>>
>> I do specify field_id (it wasn't there in the simplified code, but
>> the complete code does have it).
>>
>> When I use a function, instead of the lambda, I indeed can have a
>> solution, but at the same time it emphasizes that something is wrong:
>>
>> The links are now presented as such:
>>
>> links = [dict(header='View', body=GetCartsGridLink)]
>>
>>
>> And the GetCarrsGridLink function as follows:
>>
>> def GetCartsGridLink(row):
>>>
>>> id = None
>>>
>>> try:
>>>   id = row.cart.id # 

Re: [web2py] SQLFLORMGRID

2020-10-08 Thread lcham...@gmail.com
i do not want to make change on databe , just launch a function like 
sending an email . Is it possible to to do:
in the function or in the model .. ? let me now better choice ?
db.mytable._before_insert.my_function_send_email() 




Le lundi 5 octobre 2020 à 03:43:05 UTC+2, roge...@gmail.com a écrit :

> Hi
>
> I have used the DAL to execute code before or after I make database 
> changes. Maybe that might work in your situation:
>
> http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#callbacks-on-record-insert-delete-and-update
>  
>
> Cheers
> Andrew
>
> ___
> *www.TenOutOfTen.org* 
> roge...@gmail.com
> (+95) 09 250018669 <+95%209%20250%20018%20669> (Myanmar)
>
>
>
> On Fri, 2 Oct 2020 at 00:07, lcham...@gmail.com  
> wrote:
>
>>
>> Hello,
>> i use sqlformgrid and like this :
>> controller:
>> def art_manage():
>> records= SQLFORM.grid(query=db.t_art,maxtextlength = 
>> 40,deletable=False,create=True, fields=[db.t_art.f_name, db.t_art.f_team, 
>> db.t_art.f_tit])
>> return dict(records=records)
>>
>> view:
>> {{=records}}
>>
>>
>> the records displayed are good and i let the possibility to add records 
>> (create=True). 
>> My question is : when i add a record and i submit i would to exectue a 
>> function , how can i do ?
>> Thank you
>>
>> (i know how to do with form .. if form.process (onvalidation .. and so on)
>>
>> -- 
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to web2py+un...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/web2py/399f0935-40d6-4277-829e-2fe5f7f0784bn%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/a103801c-1586-415d-bc44-f7069f2690a9n%40googlegroups.com.