Re: [web2py] Re: SEO Friendly URLs and Page Titles

2012-08-27 Thread SeamusSeamus
Okay, but do  I leave everything else alone? All I want to do is make it 
www.mysite.com/equipment/id/title
currently, title is set up as slug in the DB. What am I doing wrong. 

 In my view:

equipment_id = request.args(0)
equipment_slug = request.args(1)
query = (db.equipment.id == item_id)  (db.equipment.slug == item_slug)
item = db(query).select().first()

try:
equipment = db.equipment[int(request.args(0))]
except:
equipment = db.equipment(request.args(0)) or db(db.equipment.slug 
== request.args(0)).select().first()


and then my link in sqlform:

links = [lambda row: A('Details',_href=URL('default','equipment', 
args=[row.slug]))]


On Sunday, August 26, 2012 5:52:52 PM UTC-6, rochacbruno wrote:


 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 
 morrisjam...@gmail.comjavascript:
  wrote:

 I would like to make it part of the URLbut 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-**viewhttp://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 

  -- 
  
  
  




-- 





Re: [web2py] Re: SEO Friendly URLs and Page Titles

2012-08-27 Thread Limedrop

I don't know if you picked this up, but you don't seem to have row.id as 
part of the sqlfrom url.

Perhaps try: 
links = [lambda row: A('Details',_href=URL('default','equipment', 
args=[row.id, row.slug]))]


On Tuesday, August 28, 2012 10:28:39 AM UTC+12, SeamusSeamus wrote:

 Okay, but do  I leave everything else alone? All I want to do is make it 
 www.mysite.com/equipment/id/title
 currently, title is set up as slug in the DB. What am I doing wrong. 

  In my view:

 equipment_id = request.args(0)
 equipment_slug = request.args(1)
 query = (db.equipment.id == item_id)  (db.equipment.slug == 
 item_slug)
 item = db(query).select().first()
 
 try:
 equipment = db.equipment[int(request.args(0))]
 except:
 equipment = db.equipment(request.args(0)) or db(db.equipment.slug 
 == request.args(0)).select().first()


 and then my link in sqlform:

 links = [lambda row: A('Details',_href=URL('default','equipment', 
 args=[row.slug]))]





-- 





Re: [web2py] Re: SEO Friendly URLs and Page Titles

2012-08-27 Thread SeamusSeamus
ah, yes, all is well now...however, this is strange. 
  Now, when I click the link on the table to take me to the 
'equipment.html' page (I renamed it from details.html), it shows the 
controller in the URL:
www.mysite.com/default/equipment/id/title

 how do I make it so the 'default' does not show up? It didnt show up 
before it looked like this:

links = [lambda row: A('Details',_href=URL('default', 'details', 
args=[row.id, row.slug]))]
I changed to 
links = [lambda row: A('Details',_href=URL('default', 'equipment', 
args=[row.id, row.slug]))]

I also changed the controller from def default to def equipment, and also 
changed default.html to equipment.html in views...

now it shows the controller in the URL...
 
 my routes looks like this

routers = dict(
BASE = dict(default_application='equipment',
default_controller = 'default',),
)


On Monday, August 27, 2012 4:38:41 PM UTC-6, Limedrop wrote:


 I don't know if you picked this up, but you don't seem to have row.id as 
 part of the sqlfrom url.

 Perhaps try: 
 links = [lambda row: A('Details',_href=URL('default','equipment', 
 args=[row.id, row.slug]))]


 On Tuesday, August 28, 2012 10:28:39 AM UTC+12, SeamusSeamus wrote:

 Okay, but do  I leave everything else alone? All I want to do is make it 
 www.mysite.com/equipment/id/title
 currently, title is set up as slug in the DB. What am I doing wrong. 

  In my view:

 equipment_id = request.args(0)
 equipment_slug = request.args(1)
 query = (db.equipment.id == item_id)  (db.equipment.slug == 
 item_slug)
 item = db(query).select().first()
 
 try:
 equipment = db.equipment[int(request.args(0))]
 except:
 equipment = db.equipment(request.args(0)) or db(db.equipment.slug 
 == request.args(0)).select().first()


 and then my link in sqlform:

 links = [lambda row: A('Details',_href=URL('default','equipment', 
 args=[row.slug]))]





-- 





Re: [web2py] Re: SEO Friendly URLs and Page Titles

2012-08-27 Thread SeamusSeamus
nevermind I fixed it. Not sure why, but if it was named 'equipment' the 
controller showed up...any other name it doesnt. I just renamed

On Monday, August 27, 2012 5:05:44 PM UTC-6, SeamusSeamus wrote:

 ah, yes, all is well now...however, this is strange. 
   Now, when I click the link on the table to take me to the 
 'equipment.html' page (I renamed it from details.html), it shows the 
 controller in the URL:
 www.mysite.com/default/equipment/id/title

  how do I make it so the 'default' does not show up? It didnt show up 
 before it looked like this:

 links = [lambda row: A('Details',_href=URL('default', 'details', args=[
 row.id, row.slug]))]
 I changed to 
 links = [lambda row: A('Details',_href=URL('default', 'equipment', 
 args=[row.id, row.slug]))]

 I also changed the controller from def default to def equipment, and also 
 changed default.html to equipment.html in views...

 now it shows the controller in the URL...
  
  my routes looks like this

 routers = dict(
 BASE = dict(default_application='equipment',
 default_controller = 'default',),
 )


 On Monday, August 27, 2012 4:38:41 PM UTC-6, Limedrop wrote:


 I don't know if you picked this up, but you don't seem to have row.id as 
 part of the sqlfrom url.

 Perhaps try: 
 links = [lambda row: A('Details',_href=URL('default','equipment', 
 args=[row.id, row.slug]))]


 On Tuesday, August 28, 2012 10:28:39 AM UTC+12, SeamusSeamus wrote:

 Okay, but do  I leave everything else alone? All I want to do is make it 
 www.mysite.com/equipment/id/title
 currently, title is set up as slug in the DB. What am I doing wrong. 

  In my view:

 equipment_id = request.args(0)
 equipment_slug = request.args(1)
 query = (db.equipment.id == item_id)  (db.equipment.slug == 
 item_slug)
 item = db(query).select().first()
 
 try:
 equipment = db.equipment[int(request.args(0))]
 except:
 equipment = db.equipment(request.args(0)) or 
 db(db.equipment.slug == request.args(0)).select().first()


 and then my link in sqlform:

 links = [lambda row: A('Details',_href=URL('default','equipment', 
 args=[row.slug]))]





-- 





Re: [web2py] Re: SEO Friendly URLs and Page Titles

2012-08-27 Thread Jonathan Lundell
On 27 Aug 2012, at 4:56 PM, SeamusSeamus morrisjamespatr...@gmail.com wrote:
 nevermind I fixed it. Not sure why, but if it was named 'equipment' the 
 controller showed up...any other name it doesnt. I just renamed

Because you also have an application named 'equipment', so some URLs are 
ambiguous.

 
 On Monday, August 27, 2012 5:05:44 PM UTC-6, SeamusSeamus wrote:
 ah, yes, all is well now...however, this is strange. 
   Now, when I click the link on the table to take me to the 'equipment.html' 
 page (I renamed it from details.html), it shows the controller in the URL:
 www.mysite.com/default/equipment/id/title
 
  how do I make it so the 'default' does not show up? It didnt show up before 
 it looked like this:
 
 links = [lambda row: A('Details',_href=URL('default', 'details', 
 args=[row.id, row.slug]))]
 I changed to 
 links = [lambda row: A('Details',_href=URL('default', 'equipment', 
 args=[row.id, row.slug]))]
 
 I also changed the controller from def default to def equipment, and also 
 changed default.html to equipment.html in views...
 
 now it shows the controller in the URL...
  
  my routes looks like this
 
 routers = dict(
 BASE = dict(default_application='equipment',
 default_controller = 'default',),
 )


-- 





Re: [web2py] Re: SEO Friendly URLs and Page Titles

2012-08-26 Thread SeamusSeamus
I would like to make it part of the URLbut 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.
  
 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 



-- 





Re: [web2py] Re: SEO Friendly URLs and Page Titles

2012-08-26 Thread Bruno Rocha
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
morrisjamespatr...@gmail.comwrote:

 I would like to make it part of the URLbut 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-**viewhttp://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

  --





-- 





Re: [web2py] Re: SEO Friendly URLs and Page Titles

2012-08-25 Thread SeamusSeamus
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 


-- 





Re: [web2py] Re: SEO Friendly URLs and Page Titles

2012-08-25 Thread Anthony
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.
 
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 



-- 





Re: [web2py] Re: SEO Friendly URLs and Page Titles

2012-08-25 Thread SeamusSeamus
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.
  
 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 



-- 





Re: [web2py] Re: SEO Friendly URLs and Page Titles

2012-08-25 Thread Anthony
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.
  
 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 



-- 





Re: [web2py] Re: SEO Friendly URLs and Page Titles

2012-08-23 Thread SeamusSeamus
Your are right, I need to change the links to default. This is what I have 
done so far, sorry for confusion:

in controller:

def index():

links = [lambda row: A('Details',_href=URL('default','show', 
args=[row.slug]))]
fields = [db.equipment.category, db.equipment.title, db.equipment.price]
grid = SQLFORM.grid(fields=fields, 
 links=links,
)

return dict(grid=grid)

def show():
try:
equipment = db.equipment[int(request.args(0))]
except:
equipment = db(db.equipment.slug == 
request.args(0)).select().first()
return equipment


and in models db.py:
db.define_table('equipment',
Field('title'),
...
Field('slug', compute=lambda row: IS_SLUG()(row.title)[0])


On Wednesday, August 22, 2012 11:49:49 PM UTC-6, Anthony wrote:

 equipment is the table.


 Yes, but in your code, it simply said args=[equipment.slug]. If your db 
 object has a table named equipment, you would refer to it as 
 db.equipment, but in any case, that would not be relevant here.
  

 the equipment details page is 'show' or 'details'. In reality, I thought 
 I could get away with the default 'view' from sqlform.grid, using a 
 slug...but it appears I cannot, so I have to create a custom 'show' or 
 'details' page. If I do 
 links = [lambda row: A('Details',_href=URL('show','show', 
 args=[row.slug]))]

  

 i get a key error.


 What is the key error? Is your grid selecting from the equipment table 
 (with the slug field)?

 Why is the URL now URL('show', 'show')? Is the controller named show.py, 
 with a function called show()? In the URL() function, the first argument 
 should be the controller and the second the function.

 Anthony


-- 





Re: [web2py] Re: SEO Friendly URLs and Page Titles

2012-08-23 Thread Anthony


 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 include 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 

-- 





Re: [web2py] Re: SEO Friendly URLs and Page Titles

2012-08-23 Thread SeamusSeamus
Thanks, that worked. I just added db.equipment.slug to the fields


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 


-- 





Re: [web2py] Re: SEO Friendly URLs and Page Titles

2012-08-22 Thread SeamusSeamus
In my SQLForm.grid I added this
links = [lambda row: A('Details',_href=URL('default','show', 
args=[equipment.slug]))]
grid = SQLFORM.grid(query=query, links=links)


I also added the is_slug into the model...but get this error..

links = [lambda row: A('Details',_href=URL('equipment','show', 
args=equipment.slug))]
AttributeError: 'function' object has no attribute 'slug'



On Tuesday, August 21, 2012 3:49:55 PM UTC-6, rochacbruno wrote:

 You want to create a slug?

 web2py comes with IS_SLUG validator which helps with this.

 db.define_table(product,
 Field(title, unique=True),
 ...
 ...
 Field(slug, compute=lambda row: IS_SLUG()(row.title)[0]
 )

 So now you can use slug field to build your urls.

  URL(product, show, args=product.slug)

 in product/show/product-name

 def show():
 try:
 product = db.product[int(request.args(0))]
 except:
 product = db(db.product.slug == request.args(0)).select().first()
return product




 On Tue, Aug 21, 2012 at 6:18 PM, SeamusSeamus 
 morrisjam...@gmail.comjavascript:
  wrote:

 I didnt mean to do {{ }}, but I mean domain.com/product/productname   
 (Product name being the name of the variable in the field from the model)



 On Tuesday, August 21, 2012 2:43:35 PM UTC-6, Anthony wrote:

 What is {{fieldname title}}? How do you get that value?

 On Tuesday, August 21, 2012 4:31:54 PM UTC-4, SeamusSeamus wrote:

 Thanks, what about URLs so it is 
 www.domain.com/product/{{**fieldnamehttp://www.domain.com/product/%7B%7Bfieldnametitle}}


 On Tuesday, August 21, 2012 10:56:49 AM UTC-6, Anthony wrote:

 You can set response.title and response.meta in the controller or 
 function to make it specific to particular controllers or functions (or 
 you 
 can set them conditionally in a model file). If you need to use a 
 database 
 value, just do a query to get the value (your probably want to cache it 
 to 
 improve performance).

 Anthony

 On Tuesday, August 21, 2012 12:49:00 PM UTC-4, SeamusSeamus wrote:


 1. What is the easiest way to make it so each page has it's own 
 title? Currently it is set by layout.html, but what if I want its own 
 page 
 to have an independent title? 
 2. How can I make it so the title of the page is the name of a 
 field in a model? I am using SQLForm now, and have /product/1 and would 
 like to have /product/purple-desk
 3. How can I make it so the meta description on each page has its own 
 ? For example, the description is the data in the field 'product 
 description' used in the model.

 Thanks.

  -- 
  
  
  




-- 





Re: [web2py] Re: SEO Friendly URLs and Page Titles

2012-08-22 Thread Anthony
What is equipment?

On Thursday, August 23, 2012 12:53:10 AM UTC-4, SeamusSeamus wrote:

 In my SQLForm.grid I added this
 links = [lambda row: A('Details',_href=URL('default','show', 
 args=[equipment.slug]))]
 grid = SQLFORM.grid(query=query, links=links)


 I also added the is_slug into the model...but get this error..

 links = [lambda row: A('Details',_href=URL('equipment','show', 
 args=equipment.slug))]
 AttributeError: 'function' object has no attribute 'slug'



 On Tuesday, August 21, 2012 3:49:55 PM UTC-6, rochacbruno wrote:

 You want to create a slug?

 web2py comes with IS_SLUG validator which helps with this.

 db.define_table(product,
 Field(title, unique=True),
 ...
 ...
 Field(slug, compute=lambda row: IS_SLUG()(row.title)[0]
 )

 So now you can use slug field to build your urls.

  URL(product, show, args=product.slug)

 in product/show/product-name

 def show():
 try:
 product = db.product[int(request.args(0))]
 except:
 product = db(db.product.slug == request.args(0)).select().first()
return product




 On Tue, Aug 21, 2012 at 6:18 PM, SeamusSeamus morrisjam...@gmail.comwrote:

 I didnt mean to do {{ }}, but I mean domain.com/product/productname   
 (Product name being the name of the variable in the field from the model)



 On Tuesday, August 21, 2012 2:43:35 PM UTC-6, Anthony wrote:

 What is {{fieldname title}}? How do you get that value?

 On Tuesday, August 21, 2012 4:31:54 PM UTC-4, SeamusSeamus wrote:

 Thanks, what about URLs so it is 
 www.domain.com/product/{{**fieldnamehttp://www.domain.com/product/%7B%7Bfieldnametitle}}


 On Tuesday, August 21, 2012 10:56:49 AM UTC-6, Anthony wrote:

 You can set response.title and response.meta in the controller or 
 function to make it specific to particular controllers or functions (or 
 you 
 can set them conditionally in a model file). If you need to use a 
 database 
 value, just do a query to get the value (your probably want to cache it 
 to 
 improve performance).

 Anthony

 On Tuesday, August 21, 2012 12:49:00 PM UTC-4, SeamusSeamus wrote:


 1. What is the easiest way to make it so each page has it's own 
 title? Currently it is set by layout.html, but what if I want its own 
 page 
 to have an independent title? 
 2. How can I make it so the title of the page is the name of a 
 field in a model? I am using SQLForm now, and have /product/1 and would 
 like to have /product/purple-desk
 3. How can I make it so the meta description on each page has its 
 own ? For example, the description is the data in the field 'product 
 description' used in the model.

 Thanks.

  -- 
  
  
  




-- 





Re: [web2py] Re: SEO Friendly URLs and Page Titles

2012-08-22 Thread SeamusSeamus
sorry, replace products with equipment. My bad. I renamed it since and am 
using equipment instead of 'products'. I have it set up now and it is 
taking me to the view, but I cannot get the sqlform.grid to show anything 
except row.id. 

On Wednesday, August 22, 2012 11:01:36 PM UTC-6, Anthony wrote:

 What is equipment?

 On Thursday, August 23, 2012 12:53:10 AM UTC-4, SeamusSeamus wrote:

 In my SQLForm.grid I added this
 links = [lambda row: A('Details',_href=URL('default','show', 
 args=[equipment.slug]))]
 grid = SQLFORM.grid(query=query, links=links)


 I also added the is_slug into the model...but get this error..

 links = [lambda row: A('Details',_href=URL('equipment','show', 
 args=equipment.slug))]
 AttributeError: 'function' object has no attribute 'slug'



 On Tuesday, August 21, 2012 3:49:55 PM UTC-6, rochacbruno wrote:

 You want to create a slug?

 web2py comes with IS_SLUG validator which helps with this.

 db.define_table(product,
 Field(title, unique=True),
 ...
 ...
 Field(slug, compute=lambda row: IS_SLUG()(row.title)[0]
 )

 So now you can use slug field to build your urls.

  URL(product, show, args=product.slug)

 in product/show/product-name

 def show():
 try:
 product = db.product[int(request.args(0))]
 except:
 product = db(db.product.slug == request.args(0)).select().first()
return product




 On Tue, Aug 21, 2012 at 6:18 PM, SeamusSeamus morrisjam...@gmail.comwrote:

 I didnt mean to do {{ }}, but I mean domain.com/product/productname   
 (Product name being the name of the variable in the field from the model)



 On Tuesday, August 21, 2012 2:43:35 PM UTC-6, Anthony wrote:

 What is {{fieldname title}}? How do you get that value?

 On Tuesday, August 21, 2012 4:31:54 PM UTC-4, SeamusSeamus wrote:

 Thanks, what about URLs so it is 
 www.domain.com/product/{{**fieldnamehttp://www.domain.com/product/%7B%7Bfieldnametitle}}


 On Tuesday, August 21, 2012 10:56:49 AM UTC-6, Anthony wrote:

 You can set response.title and response.meta in the controller or 
 function to make it specific to particular controllers or functions (or 
 you 
 can set them conditionally in a model file). If you need to use a 
 database 
 value, just do a query to get the value (your probably want to cache it 
 to 
 improve performance).

 Anthony

 On Tuesday, August 21, 2012 12:49:00 PM UTC-4, SeamusSeamus wrote:


 1. What is the easiest way to make it so each page has it's own 
 title? Currently it is set by layout.html, but what if I want its own 
 page 
 to have an independent title? 
 2. How can I make it so the title of the page is the name of a 
 field in a model? I am using SQLForm now, and have /product/1 and 
 would 
 like to have /product/purple-desk
 3. How can I make it so the meta description on each page has its 
 own ? For example, the description is the data in the field 'product 
 description' used in the model.

 Thanks.

  -- 
  
  
  




-- 





Re: [web2py] Re: SEO Friendly URLs and Page Titles

2012-08-22 Thread Anthony
The only argument to your lambda is row, so I assume you want row.slug. 
Because equipment is not an argument of the lambda, it will look for it 
in the outer scope. It looks like you must have a function named 
equipment, which is what is being referenced in the lambda.

Anthony

On Thursday, August 23, 2012 1:05:45 AM UTC-4, SeamusSeamus wrote:

 sorry, replace products with equipment. My bad. I renamed it since and am 
 using equipment instead of 'products'. I have it set up now and it is 
 taking me to the view, but I cannot get the sqlform.grid to show anything 
 except row.id. 

 On Wednesday, August 22, 2012 11:01:36 PM UTC-6, Anthony wrote:

 What is equipment?

 On Thursday, August 23, 2012 12:53:10 AM UTC-4, SeamusSeamus wrote:

 In my SQLForm.grid I added this
 links = [lambda row: A('Details',_href=URL('default','show', 
 args=[equipment.slug]))]
 grid = SQLFORM.grid(query=query, links=links)


 I also added the is_slug into the model...but get this error..

 links = [lambda row: A('Details',_href=URL('equipment','show', 
 args=equipment.slug))]
 AttributeError: 'function' object has no attribute 'slug'



 On Tuesday, August 21, 2012 3:49:55 PM UTC-6, rochacbruno wrote:

 You want to create a slug?

 web2py comes with IS_SLUG validator which helps with this.

 db.define_table(product,
 Field(title, unique=True),
 ...
 ...
 Field(slug, compute=lambda row: IS_SLUG()(row.title)[0]
 )

 So now you can use slug field to build your urls.

  URL(product, show, args=product.slug)

 in product/show/product-name

 def show():
 try:
 product = db.product[int(request.args(0))]
 except:
 product = db(db.product.slug == 
 request.args(0)).select().first()
return product




 On Tue, Aug 21, 2012 at 6:18 PM, SeamusSeamus 
 morrisjam...@gmail.comwrote:

 I didnt mean to do {{ }}, but I mean domain.com/product/productname   
 (Product name being the name of the variable in the field from the model)



 On Tuesday, August 21, 2012 2:43:35 PM UTC-6, Anthony wrote:

 What is {{fieldname title}}? How do you get that value?

 On Tuesday, August 21, 2012 4:31:54 PM UTC-4, SeamusSeamus wrote:

 Thanks, what about URLs so it is www.domain.com/product/{{**
 fieldname http://www.domain.com/product/%7B%7Bfieldname title}}


 On Tuesday, August 21, 2012 10:56:49 AM UTC-6, Anthony wrote:

 You can set response.title and response.meta in the controller or 
 function to make it specific to particular controllers or functions 
 (or you 
 can set them conditionally in a model file). If you need to use a 
 database 
 value, just do a query to get the value (your probably want to cache 
 it to 
 improve performance).

 Anthony

 On Tuesday, August 21, 2012 12:49:00 PM UTC-4, SeamusSeamus wrote:


 1. What is the easiest way to make it so each page has it's own 
 title? Currently it is set by layout.html, but what if I want its own 
 page 
 to have an independent title? 
 2. How can I make it so the title of the page is the name of a 
 field in a model? I am using SQLForm now, and have /product/1 and 
 would 
 like to have /product/purple-desk
 3. How can I make it so the meta description on each page has its 
 own ? For example, the description is the data in the field 'product 
 description' used in the model.

 Thanks.

  -- 
  
  
  




-- 





Re: [web2py] Re: SEO Friendly URLs and Page Titles

2012-08-22 Thread SeamusSeamus
equipment is the table.
the equipment details page is 'show' or 'details'. In reality, I thought I 
could get away with the default 'view' from sqlform.grid, using a 
slug...but it appears I cannot, so I have to create a custom 'show' or 
'details' page. If I do 
links = [lambda row: A('Details',_href=URL('show','show', 
args=[row.slug]))]

i get a key error.
show and show being the html page and the controller...
 
 My apologize in advanced if I am making this more confusing than it needs 
to be. The help truly is greatly appreciated. I am essentially moving my 
whole entire online business on to web2py from an old modified shopping 
cart...so far I have the minimal but it way better and more simple using 
web2py


On Wednesday, August 22, 2012 11:25:24 PM UTC-6, Anthony wrote:

 The only argument to your lambda is row, so I assume you want row.slug. 
 Because equipment is not an argument of the lambda, it will look for it 
 in the outer scope. It looks like you must have a function named 
 equipment, which is what is being referenced in the lambda.

 Anthony

 On Thursday, August 23, 2012 1:05:45 AM UTC-4, SeamusSeamus wrote:

 sorry, replace products with equipment. My bad. I renamed it since and am 
 using equipment instead of 'products'. I have it set up now and it is 
 taking me to the view, but I cannot get the sqlform.grid to show anything 
 except row.id. 

 On Wednesday, August 22, 2012 11:01:36 PM UTC-6, Anthony wrote:

 What is equipment?

 On Thursday, August 23, 2012 12:53:10 AM UTC-4, SeamusSeamus wrote:

 In my SQLForm.grid I added this
 links = [lambda row: A('Details',_href=URL('default','show', 
 args=[equipment.slug]))]
 grid = SQLFORM.grid(query=query, links=links)


 I also added the is_slug into the model...but get this error..

 links = [lambda row: A('Details',_href=URL('equipment','show', 
 args=equipment.slug))]
 AttributeError: 'function' object has no attribute 'slug'



 On Tuesday, August 21, 2012 3:49:55 PM UTC-6, rochacbruno wrote:

 You want to create a slug?

 web2py comes with IS_SLUG validator which helps with this.

 db.define_table(product,
 Field(title, unique=True),
 ...
 ...
 Field(slug, compute=lambda row: IS_SLUG()(row.title)[0]
 )

 So now you can use slug field to build your urls.

  URL(product, show, args=product.slug)

 in product/show/product-name

 def show():
 try:
 product = db.product[int(request.args(0))]
 except:
 product = db(db.product.slug == 
 request.args(0)).select().first()
return product




 On Tue, Aug 21, 2012 at 6:18 PM, SeamusSeamus 
 morrisjam...@gmail.comwrote:

 I didnt mean to do {{ }}, but I mean domain.com/product/productname   
 (Product name being the name of the variable in the field from the model)



 On Tuesday, August 21, 2012 2:43:35 PM UTC-6, Anthony wrote:

 What is {{fieldname title}}? How do you get that value?

 On Tuesday, August 21, 2012 4:31:54 PM UTC-4, SeamusSeamus wrote:

 Thanks, what about URLs so it is www.domain.com/product/{{**
 fieldname http://www.domain.com/product/%7B%7Bfieldname title}}


 On Tuesday, August 21, 2012 10:56:49 AM UTC-6, Anthony wrote:

 You can set response.title and response.meta in the controller or 
 function to make it specific to particular controllers or functions 
 (or you 
 can set them conditionally in a model file). If you need to use a 
 database 
 value, just do a query to get the value (your probably want to cache 
 it to 
 improve performance).

 Anthony

 On Tuesday, August 21, 2012 12:49:00 PM UTC-4, SeamusSeamus wrote:


 1. What is the easiest way to make it so each page has it's own 
 title? Currently it is set by layout.html, but what if I want its 
 own page 
 to have an independent title? 
 2. How can I make it so the title of the page is the name of 
 a field in a model? I am using SQLForm now, and have /product/1 and 
 would 
 like to have /product/purple-desk
 3. How can I make it so the meta description on each page has its 
 own ? For example, the description is the data in the field 'product 
 description' used in the model.

 Thanks.

  -- 
  
  
  




-- 





Re: [web2py] Re: SEO Friendly URLs and Page Titles

2012-08-22 Thread Anthony


 equipment is the table.


Yes, but in your code, it simply said args=[equipment.slug]. If your db 
object has a table named equipment, you would refer to it as 
db.equipment, but in any case, that would not be relevant here.
 

 the equipment details page is 'show' or 'details'. In reality, I thought I 
 could get away with the default 'view' from sqlform.grid, using a 
 slug...but it appears I cannot, so I have to create a custom 'show' or 
 'details' page. If I do 
 links = [lambda row: A('Details',_href=URL('show','show', 
 args=[row.slug]))]

 

 i get a key error.


What is the key error? Is your grid selecting from the equipment table 
(with the slug field)?

Why is the URL now URL('show', 'show')? Is the controller named show.py, 
with a function called show()? In the URL() function, the first argument 
should be the controller and the second the function.

Anthony

-- 





[web2py] Re: SEO Friendly URLs and Page Titles

2012-08-21 Thread Anthony
You can set response.title and response.meta in the controller or function 
to make it specific to particular controllers or functions (or you can set 
them conditionally in a model file). If you need to use a database value, 
just do a query to get the value (your probably want to cache it to improve 
performance).

Anthony

On Tuesday, August 21, 2012 12:49:00 PM UTC-4, SeamusSeamus wrote:


 1. What is the easiest way to make it so each page has it's own title? 
 Currently it is set by layout.html, but what if I want its own page to have 
 an independent title? 
 2. How can I make it so the title of the page is the name of a field 
 in a model? I am using SQLForm now, and have /product/1 and would like to 
 have /product/purple-desk
 3. How can I make it so the meta description on each page has its own ? 
 For example, the description is the data in the field 'product description' 
 used in the model.

 Thanks.

-- 





[web2py] Re: SEO Friendly URLs and Page Titles

2012-08-21 Thread SeamusSeamus
Thanks, what about URLs so it is www.domain.com/product/{{fieldname title}}


On Tuesday, August 21, 2012 10:56:49 AM UTC-6, Anthony wrote:

 You can set response.title and response.meta in the controller or function 
 to make it specific to particular controllers or functions (or you can set 
 them conditionally in a model file). If you need to use a database value, 
 just do a query to get the value (your probably want to cache it to improve 
 performance).

 Anthony

 On Tuesday, August 21, 2012 12:49:00 PM UTC-4, SeamusSeamus wrote:


 1. What is the easiest way to make it so each page has it's own title? 
 Currently it is set by layout.html, but what if I want its own page to have 
 an independent title? 
 2. How can I make it so the title of the page is the name of a field 
 in a model? I am using SQLForm now, and have /product/1 and would like to 
 have /product/purple-desk
 3. How can I make it so the meta description on each page has its own ? 
 For example, the description is the data in the field 'product description' 
 used in the model.

 Thanks.



-- 





[web2py] Re: SEO Friendly URLs and Page Titles

2012-08-21 Thread Anthony
What is {{fieldname title}}? How do you get that value?

On Tuesday, August 21, 2012 4:31:54 PM UTC-4, SeamusSeamus wrote:

 Thanks, what about URLs so it is 
 www.domain.com/product/{{fieldnamehttp://www.domain.com/product/%7B%7Bfieldnametitle}}


 On Tuesday, August 21, 2012 10:56:49 AM UTC-6, Anthony wrote:

 You can set response.title and response.meta in the controller or 
 function to make it specific to particular controllers or functions (or you 
 can set them conditionally in a model file). If you need to use a database 
 value, just do a query to get the value (your probably want to cache it to 
 improve performance).

 Anthony

 On Tuesday, August 21, 2012 12:49:00 PM UTC-4, SeamusSeamus wrote:


 1. What is the easiest way to make it so each page has it's own title? 
 Currently it is set by layout.html, but what if I want its own page to have 
 an independent title? 
 2. How can I make it so the title of the page is the name of a field 
 in a model? I am using SQLForm now, and have /product/1 and would like to 
 have /product/purple-desk
 3. How can I make it so the meta description on each page has its own ? 
 For example, the description is the data in the field 'product description' 
 used in the model.

 Thanks.



-- 





[web2py] Re: SEO Friendly URLs and Page Titles

2012-08-21 Thread SeamusSeamus
I didnt mean to do {{ }}, but I mean domain.com/product/productname   
(Product name being the name of the variable in the field from the model)


On Tuesday, August 21, 2012 2:43:35 PM UTC-6, Anthony wrote:

 What is {{fieldname title}}? How do you get that value?

 On Tuesday, August 21, 2012 4:31:54 PM UTC-4, SeamusSeamus wrote:

 Thanks, what about URLs so it is 
 www.domain.com/product/{{fieldnamehttp://www.domain.com/product/%7B%7Bfieldnametitle}}


 On Tuesday, August 21, 2012 10:56:49 AM UTC-6, Anthony wrote:

 You can set response.title and response.meta in the controller or 
 function to make it specific to particular controllers or functions (or you 
 can set them conditionally in a model file). If you need to use a database 
 value, just do a query to get the value (your probably want to cache it to 
 improve performance).

 Anthony

 On Tuesday, August 21, 2012 12:49:00 PM UTC-4, SeamusSeamus wrote:


 1. What is the easiest way to make it so each page has it's own title? 
 Currently it is set by layout.html, but what if I want its own page to 
 have 
 an independent title? 
 2. How can I make it so the title of the page is the name of a 
 field in a model? I am using SQLForm now, and have /product/1 and would 
 like to have /product/purple-desk
 3. How can I make it so the meta description on each page has its own ? 
 For example, the description is the data in the field 'product 
 description' 
 used in the model.

 Thanks.



-- 





Re: [web2py] Re: SEO Friendly URLs and Page Titles

2012-08-21 Thread Bruno Rocha
You want to create a slug?

web2py comes with IS_SLUG validator which helps with this.

db.define_table(product,
Field(title, unique=True),
...
...
Field(slug, compute=lambda row: IS_SLUG()(row.title)[0]
)

So now you can use slug field to build your urls.

URL(product, show, args=product.slug)

in product/show/product-name

def show():
try:
product = db.product[int(request.args(0))]
except:
product = db(db.product.slug == request.args(0)).select().first()
   return product




On Tue, Aug 21, 2012 at 6:18 PM, SeamusSeamus
morrisjamespatr...@gmail.comwrote:

 I didnt mean to do {{ }}, but I mean domain.com/product/productname
 (Product name being the name of the variable in the field from the model)



 On Tuesday, August 21, 2012 2:43:35 PM UTC-6, Anthony wrote:

 What is {{fieldname title}}? How do you get that value?

 On Tuesday, August 21, 2012 4:31:54 PM UTC-4, SeamusSeamus wrote:

 Thanks, what about URLs so it is 
 www.domain.com/product/{{**fieldnamehttp://www.domain.com/product/%7B%7Bfieldnametitle}}


 On Tuesday, August 21, 2012 10:56:49 AM UTC-6, Anthony wrote:

 You can set response.title and response.meta in the controller or
 function to make it specific to particular controllers or functions (or you
 can set them conditionally in a model file). If you need to use a database
 value, just do a query to get the value (your probably want to cache it to
 improve performance).

 Anthony

 On Tuesday, August 21, 2012 12:49:00 PM UTC-4, SeamusSeamus wrote:


 1. What is the easiest way to make it so each page has it's own title?
 Currently it is set by layout.html, but what if I want its own page to 
 have
 an independent title?
 2. How can I make it so the title of the page is the name of a
 field in a model? I am using SQLForm now, and have /product/1 and would
 like to have /product/purple-desk
 3. How can I make it so the meta description on each page has its own
 ? For example, the description is the data in the field 'product
 description' used in the model.

 Thanks.

  --





--