It would work, but if I delete a record and then add a new one it would get
the wrong id :-/


On Wed, Mar 27, 2013 at 6:40 PM, Niphlod <[email protected]> wrote:

> when dealing with first() or last(), remember that those come AFTER the
> select() ... when you do select().first() you're really fetching all from
> the db and discarding all but one row.
>
> The time difference may be negligible with a few records, but if you have
> lots of them, stick with limitby=(0,1) and orderby=field or orderby=~field
>
>
> On Wednesday, March 27, 2013 10:34:25 PM UTC+1, Roberto Perdomo wrote:
>
>> Sorry, the function must be return a string in order to concatenate with
>> the  filename
>> El mar 27, 2013 4:59 PM, "Roberto Perdomo" <[email protected]> escribió:
>>
>>>  And what about something like this:
>>>
>>> Field('image_filename', readable=False, writable=False, compute = lambda
>>> row: request.post_vars.image.**filename + next_id())
>>>
>>> def next_id():
>>>     last_row = db().select(db.table.id).last(**)
>>>     last_id = int(last_row[`table.id`])
>>>     return last_id + 1
>>>
>>> This was written from my cel phone and dont test it but  hope that helps
>>> ;-)
>>>  El mar 27, 2013 3:25 PM, "Roberto Perdomo" <[email protected]>
>>> escribió:
>>>
>>>>  :-S
>>>> I was thinking on represent attribute from fields, not compute.
>>>> El mar 27, 2013 3:07 PM, "Niphlod" <[email protected]> escribió:
>>>>
>>>> boys ..... how can the id be present if what you're trying to insert is
>>>>> not yet a row in a table ????
>>>>>
>>>>> On Wednesday, March 27, 2013 8:18:38 PM UTC+1, Roberto Perdomo wrote:
>>>>>>
>>>>>> Ummm, the id is readable?
>>>>>>
>>>>>> db.table.id.readable = True
>>>>>> El mar 27, 2013 12:55 PM, "Tito Garrido" <[email protected]>
>>>>>> escribió:
>>>>>>
>>>>>>> I just checked... id is not present:
>>>>>>> "<Row {'artista': 387, 'nome': 'aaaa', 'image': 'personagem.image.**
>>>>>>> b2754a53c6cd**cc7e.**69626d2d4c6f676f2e6a7067.**jpg', 'novela':
>>>>>>> '9', 'slug': 'aaaa', 'descricao': 'aaaa'}>"
>>>>>>>
>>>>>>>
>>>>>>> On Wed, Mar 27, 2013 at 2:24 PM, Roberto Perdomo <[email protected]
>>>>>>> > wrote:
>>>>>>>
>>>>>>>> Try:
>>>>>>>>
>>>>>>>> Field('image_filename', readable=False, writable=False, compute =
>>>>>>>> lambda row: request.post_vars.image.**filena**me + row.id),
>>>>>>>> El mar 27, 2013 12:39 PM, "Tito Garrido" <[email protected]>
>>>>>>>> escribió:
>>>>>>>>
>>>>>>>> How could I also append the id of the row in image_filename?
>>>>>>>>>
>>>>>>>>> Thanks!
>>>>>>>>>
>>>>>>>>> Tito
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Mon, Mar 25, 2013 at 4:58 PM, Tito Garrido 
>>>>>>>>> <[email protected]>wrote:
>>>>>>>>>
>>>>>>>>>> Worked! It should go to the book :) http://web2py.com/books/**
>>>>>>>>>> defaul**t/chapter/29/07#Storing-**the-**original-filename<http://web2py.com/books/default/chapter/29/07#Storing-the-original-filename>
>>>>>>>>>>
>>>>>>>>>> Thanks!
>>>>>>>>>>
>>>>>>>>>> Tito
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Mon, Mar 25, 2013 at 4:53 PM, Massimo Di Pierro <
>>>>>>>>>> [email protected]> wrote:
>>>>>>>>>>
>>>>>>>>>>> You can use this:
>>>>>>>>>>>  Field('image_filename', readable=False, writable=False, compute
>>>>>>>>>>> = lambda row: request.post_vars.image.**filena**me),
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On Monday, 25 March 2013 13:28:19 UTC-5, Tito Garrido wrote:
>>>>>>>>>>>>
>>>>>>>>>>>> Hi!
>>>>>>>>>>>>
>>>>>>>>>>>> Why this does not work:
>>>>>>>>>>>> Field('image', 'upload', requires=IS_NOT_EMPTY(),
>>>>>>>>>>>> uploadseparate=True, autodelete=True,),
>>>>>>>>>>>>     Field('image_filename', readable=False, writable=False,
>>>>>>>>>>>> compute = lambda row: row.image.filename),
>>>>>>>>>>>>
>>>>>>>>>>>> Using a form I can follow the book and fill the image filename:
>>>>>>>>>>>>     if request.vars.image!=None:
>>>>>>>>>>>>         try:
>>>>>>>>>>>>             form.vars.image_filename =
>>>>>>>>>>>> request.vars.image.filename
>>>>>>>>>>>>         except:
>>>>>>>>>>>>             form.vars.image_filename = request.vars.image
>>>>>>>>>>>>
>>>>>>>>>>>> How can I do the same using SQLFORM.grid?
>>>>>>>>>>>>
>>>>>>>>>>>> Regards,
>>>>>>>>>>>>
>>>>>>>>>>>> Tito
>>>>>>>>>>>>
>>>>>>>>>>>> --
>>>>>>>>>>>>
>>>>>>>>>>>> Linux User #387870
>>>>>>>>>>>> .........____
>>>>>>>>>>>> .... _/_õ|__|
>>>>>>>>>>>> ..º[ .-.___.-._| . . . .
>>>>>>>>>>>> .__( o)__( o).:_______
>>>>>>>>>>>>
>>>>>>>>>>>  --
>>>>>>>>>>>
>>>>>>>>>>> ---
>>>>>>>>>>> You received this message because you are subscribed to the
>>>>>>>>>>> Google Groups "web2py-users" group.
>>>>>>>>>>> To unsubscribe from this group and stop receiving emails from
>>>>>>>>>>> it, send an email to web2py+un...@**googlegroups.com.
>>>>>>>>>>> For more options, visit https://groups.google.com/**grou**
>>>>>>>>>>> ps/opt_out <https://groups.google.com/groups/opt_out>.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>>
>>>>>>>>>> Linux User #387870
>>>>>>>>>> .........____
>>>>>>>>>> .... _/_õ|__|
>>>>>>>>>> ..º[ .-.___.-._| . . . .
>>>>>>>>>> .__( o)__( o).:_______
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>>
>>>>>>>>> Linux User #387870
>>>>>>>>> .........____
>>>>>>>>> .... _/_õ|__|
>>>>>>>>> ..º[ .-.___.-._| . . . .
>>>>>>>>> .__( o)__( o).:_______
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>>
>>>>>>>>> ---
>>>>>>>>> You received this message because you are subscribed to the Google
>>>>>>>>> Groups "web2py-users" group.
>>>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>>>> send an email to web2py+un...@**googlegroups.com.
>>>>>>>>> For more options, visit https://groups.google.com/**grou**
>>>>>>>>> ps/opt_out <https://groups.google.com/groups/opt_out>.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>  --
>>>>>>>>
>>>>>>>> ---
>>>>>>>> You received this message because you are subscribed to the Google
>>>>>>>> Groups "web2py-users" group.
>>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>>> send an email to web2py+un...@**googlegroups.com.
>>>>>>>> For more options, visit https://groups.google.com/**grou**
>>>>>>>> ps/opt_out <https://groups.google.com/groups/opt_out>.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>>
>>>>>>> Linux User #387870
>>>>>>> .........____
>>>>>>> .... _/_õ|__|
>>>>>>> ..º[ .-.___.-._| . . . .
>>>>>>> .__( o)__( o).:_______
>>>>>>>
>>>>>>> --
>>>>>>>
>>>>>>> ---
>>>>>>> You received this message because you are subscribed to the Google
>>>>>>> Groups "web2py-users" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>> send an email to web2py+un...@**googlegroups.com.
>>>>>>> For more options, visit 
>>>>>>> https://groups.google.com/**grou**ps/opt_out<https://groups.google.com/groups/opt_out>
>>>>>>> .
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>  --
>>>>>
>>>>> ---
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "web2py-users" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to web2py+un...@**googlegroups.com.
>>>>> For more options, visit 
>>>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>>>> .
>>>>>
>>>>>
>>>>>
>>>>   --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 

Linux User #387870
.........____
.... _/_õ|__|
..º[ .-.___.-._| . . . .
.__( o)__( o).:_______

-- 

--- 
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to