Download http://web2py-crm.appspot.com It contains a plugin_tagging that is reusable. I have a new version in the working with some minor improvements that you will be able to swap when done.
Massimo On Jan 5, 8:02 pm, s...@pobox.com wrote: > In the reading and experimenting I've done so far I have been frankly amazed > and how quickly I could put together something quasi-operational - database > with a few tables, a couple entry forms, not a lick of HTML (:barf:). Kudos > on the effective implementation of the 80/20 rule. > > 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 - s...@pobox.com -http://www.smontanaro.net/
-- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.