Now I'm at a stage where I suspect I am going to have to get fancier (and
messier). If everything entered is one-to-one mapped against tables in the
database it's pretty straightforward. (And, as I indicated above, no HTMLs
were harmed during that testing - yay.) I would like to allow searching on
a number of different text elements (category names, item titles, and random
user-provided tags). Also, when users input item data I would like them to
be able to just enter tags at that point without worrying about entering
them separately.
Let me make this more concrete. Suppose my database contains various types
of toy vehicles: trucks, cars, motorcycles, boats. Tags might include the
manufacturer, the type (dump truck, race car, flat-bed, etc), the scale
(1/43, 1/50, 1/12, etc), heck, maybe even the color, model manufacturer and
manufacturer of the real vehicle the model copies. I'd like to have a few
easy-to-understand categories (the type of vehicles), but have everything
else in the tags and item descriptions.
So some guy comes to my site and wants to search for blue Matchbox Porsches.
These values are probably scattered throughout the database. I suppose I
can peel off the category and make the user specify that separately, and can
concoct complex DAL-ish searches which allow me to find what the guy is
looking for. That will be a slog, but I think I can figure it out. (OTOH,
is there a better way of thinking about the general database search
problem? Maybe take all text associated with a record, fabricate a blob
field then constrain searches to it?)
I'm more worried about creating submission forms which have fields which
don't necessarily map one-to-one to tables in the database. Consider this
table definition:
db.define_table("products",
Field("name", "string", length=512, notnull=True, default=None),
Field("location", "string", length=512, notnull=True, default=None),
Field("part_number", "string", length=32, notnull=False, default=""),
Field("image", "upload", notnull=False),
Field("id_categories", db.categories))
Now a simple table of tags:
db.define_table("tags",
Field("name", "string", length=32, notnull=True, default=None))
and a many-to-many association:
db.define_table("itemtags",
Field("id_tags", db.tags),
Field("id_products", db.products))
If I have a submission form for a new records in the products table (I
learned the hard way I couldn't name the table "items") how would I add a
tags row so the user could enter a comma-separated list of tags such as
("yellow, 914, 1/87, Corgi")? Even better might be to create a multi-select
list from existing known tags and allow the user to input new ones.
Then, when the form is submitted, how do I process that list of tags
separately from the main part of the form, inserting rows in the tags table
as necessary and creating associations in the itemtags table mapping between
each tag and the newly entered product? I can't even tell where the default
form creation and processing takes place so I can begin to explore how to
override it. (God, please let it not require HTML...)
Thanks,
--
Skip Montanaro - sk...@pobox.com - http://www.smontanaro.net/
Massimo
> Skip Montanaro - s...@pobox.com -http://www.smontanaro.net/
On Jan 6, 5:07 am, mdipierro <mdipie...@cs.depaul.edu> wrote:
> Downloadhttp://web2py-crm.appspot.com
On Jan 6, 5:50 am, selecta <gr...@delarue-berlin.de> wrote:
> or you could use my improved versionhttp://groups.google.com/group/web2py/browse_thread/thread/4f9dfc4e9c...
-Thadeus
> --
> You received this message because you are subscribed to the Google Groups "web2py-users" group.
> To post to this group, send email to web...@googlegroups.com.
> To unsubscribe from this group, send email to web2py+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/web2py?hl=en.
>
>
>
>
Thanks, I downloaded Massimo's CRM app then overlaid your version of the
plugin. It seems to work, I think. I'm not quite sure about the expected
behavior in the tag-related stuff, but the obvious CRM stuff seems to work.
Some questions:
* The Search box in the upper right of every page doesn't seem to ever
trigger any search activity. I can't follow the logic in layout.html well
enough to tell where I should be looking for code which implements that
action. The action is empty. I don't know where that's supposed to lead
back to in the code.
* In the controllers directory I now have a plugin_tagging.py file which
defines these functions: tag, tag_cloud, tag_cloud_table,
tag_cloud_record. This URL works:
http://127.0.0.1:8000/crm/plugin_tagging/tag_cloud
but this yields 404:
http://127.0.0.1:8000/crm/plugin_tagging/tag
Why is that?
* Is the tag cloud supposed to be mouse-sensitive? (I've not used tag
clouds before and don't plan to use one for my app, at least initially, so
it's no big deal. Mostly I'm just curious.)
Thx,