mmm first. Navigators nevers send the text of the link, so you cannot
get it anyway.

Second, you're using literals instead of variables. This line:

items.filter("type =", "merchandise_type")

must be:

items.filter("type =", merchandise_type)

There are a great difference between the string "merchandise_type" and
the variable merchandise_type that could be any value.

Third, you must use URL parameters for this purpose, so you links must
be something like this:

<a href="/dir?type=tshirt">Tshirt</a>
<a href="/dir?type=other">other</a>

And in your handler:

merchandise_type = self.request.get("type", "")
# save in a variable (called merchandise_type for example) the
parameter passed to the page
# first argument is the parameter name, and second the default value
if the parameter is not present (security!)

# and again, if you want more security
if not merchandise_type in ['tshirt', 'other']:
  #error message here
else:
  #show page items

# or if you don't matter about security show page items directly

On 20 ene, 18:02, Zeynel <[email protected]> wrote:
> Hello,
>
> I am creating a new directory page to list Merchandise. The /dir/
> dhp.html page has these links:
>
> <ul>
> <li><b>Merchandise</b></li>
> <ul>
> <li><a href="/dir">Tshirts</a></li>
> <li><a href="/dir">Mugs</a></li>
> <li><a href="/dir">Posters</a></li>
> </ul>
> <li><b>Articles</b></li>
> <li><b>Video</b></li>
> </ul>
>
> /dir is handled by the Directory handler which will get the relevant
> merchandise type from the database and display it.
>
> This is my model:
>
> class Item(db.Model):
>     user_who_liked_this_item = db.UserProperty()
>     title = db.StringProperty()
>     url = db.StringProperty()
>     date = db.DateTimeProperty(auto_now_add=True)
>     points = db.IntegerProperty(default=1)
>     type = db.StringProperty()
>
> In Directory handler I do this:
>
>     items = Item.all()
>     items.filter("type =", "merchandise_type")
>
>     for item in items:
>         # display the items...
>
> For this to work I need to get the link text for each merchandise and
> say, for instance
>
>     merchandise_type = "tshirt"
>     items = Item.all()
>     items.filter("type =", "merchandise_type")
>
> so that Directory handler fetches the "tshirt" type from the datastore
> when "tshirts" is clicked.
>
> I know this is easy to do but I could not figure it out. Thanks for
> your help.

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to