def show():
item_id = request.args(0)
item_slug = request.args(1)
query = (db.items.id == item_id) & (db.items.slug == item_slug)
item = db(query).select().first()
return dict(item=item)
http://<myapp>/items/show/1/awesome-product
http://<myapp>/items/show/2/awesome-product
On Sun, Aug 26, 2012 at 4:01 AM, SeamusSeamus
<[email protected]>wrote:
> I would like to make it part of the URL....but am unsure how to do
> it...any tutorials or a quick way?
>
>
> On Saturday, August 25, 2012 6:59:29 PM UTC-6, Anthony wrote:
>>
>> Oh, yeah, I guess you probably can't use the id in a compute because
>> there is no id until the record has been inserted. You could instead make
>> the id part of the URL (like Stack Overflow), or maybe make it a virtual
>> field, or generate your own unique id (separate from the record id).
>>
>> Anthony
>>
>> On Saturday, August 25, 2012 8:34:22 PM UTC-4, SeamusSeamus wrote:
>>>
>>> Thanks for the info Anthony...
>>> When I do this:
>>> Field('slug', compute=lambda row: IS_SLUG()(row.title + "-" + str(
>>> row.id))[0])
>>>
>>> I get none as a slug...
>>>
>>>
>>>
>>> On Saturday, August 25, 2012 5:53:49 PM UTC-6, Anthony wrote:
>>>>
>>>> Sure, something like that seems fine. Look at what SO does -- for
>>>> example: http://stackoverflow.**com/questions/12050934/web2py-**
>>>> build-forms-in-controller-or-**view<http://stackoverflow.com/questions/12050934/web2py-build-forms-in-controller-or-view>.
>>>> I think they use the number as the unique record identifier, but also
>>>> include a slug (which doesn't necessarily have to be unique).
>>>>
>>>> Anthony
>>>>
>>>> On Saturday, August 25, 2012 7:16:50 PM UTC-4, SeamusSeamus wrote:
>>>>>
>>>>> This runs into a problem where if I have two items of the same
>>>>> 'title', the user will only be linked to the first one that was created.
>>>>> Can I make it so the slug is a field that I designate? Or make it so the
>>>>> slug adds a incrementing number such as:
>>>>> Field('slug', compute=lambda row: IS_SLUG()(row.title *+ row.id*
>>>>> )[0])
>>>>> I know thats not how you do it, but do you get what I mean? Is there
>>>>> a better way?
>>>>>
>>>>>
>>>>> On Thursday, August 23, 2012 1:18:16 AM UTC-6, Anthony wrote:
>>>>>>
>>>>>> links = [lambda ro
>>>>>>> w: A('Details',_href=URL('**default','show', args=[row.slug]))]
>>>>>>> fields = [db.equipment.category, db.equipment.title,
>>>>>>> db.equipment.price]
>>>>>>>
>>>>>>
>>>>>> You have not included "slug" in your list of fields, so I believe it
>>>>>> will not be included in the data query. Instead of specifying the list of
>>>>>> fields, you can set the readable attribute to False for fields you don't
>>>>>> want displayed (including "slug"). In that case, all fields will be
>>>>>> included in the query (including "slug"), but only the fields you want to
>>>>>> show will be visible in the grid.
>>>>>>
>>>>>> Anthony
>>>>>>
>>>>> --
>
>
>
>
--