Hey everyone,

First of all, i'm sory because i'm not very good in english. I'm also
very new in Python and Turbogears. I found Turbogears a few months
ago. After i study Turbogears from a lot of internet source and book,
i can run Turbogears properly. i like turbogears because it's easy to
use, i can customize it and a lot of fun tools.

but i have a problem when i'm trying to store the current user_id to
others table after i search on the Turbogears google group and on the
web i can find a solution for this problem. something like this

# class tg_user(SQLObject):
#     schedules = MultipleJoin("schedules",joinColumn='tg_user_id')
#     events = MultipleJoin("events",joinColumn='tg_user_id')
#     appointments =
MultipleJoin("appointments",joinColumn='tg_user_id')

# class appointments(SQLObject):
#     appointment_time =
DateTimeCol(alternateID=True,default=datetime.now)
#     subject = UnicodeCol(alternateID=True)
#     message = UnicodeCol()
#     status = UnicodeCol()
#     tg_user = ForeignKey("tg_user")

CREATE TABLE `tg_user` (
           `id` int(11) NOT NULL auto_increment,
           `user_name` varchar(16) NOT NULL,
           `password` varchar(40) default NULL,
           `email_address` varchar(255) NOT NULL,
           `display_name` varchar(255) default NULL,
           `ic_no` varchar(40) default NULL,
           `phone_no` varchar(40) default NULL,
           `address` text,
           `created` datetime default NULL,
           PRIMARY KEY  (`id`),
           UNIQUE KEY `user_name` (`user_name`),
           UNIQUE KEY `email_address` (`email_address`)
         ) ENGINE=InnoDB DEFAULT CHARSET=latin1

CREATE TABLE `appointments`
(
                `id` int(11) NOT NULL
auto_increment,
                `appointment_time` datetime NOT
NULL,
                `subject` varchar(255) NOT
NULL,
                `message` varchar(255) default
NULL,
                `status` varchar(255) default
NULL,
                `user_id` int(11) default
NULL,
                PRIMARY KEY
(`id`),
                UNIQUE KEY `appointment_time`
(`appointment_time`),
                UNIQUE KEY `subject`
(`subject`),
                KEY `appointments_user_id_exists`
(`user_id`),
                CONSTRAINT `appointments_user_id_exists` FOREIGN KEY
(`user_id`) REFERENCES `tg_user` (`id`)
              ) ENGINE=InnoDB DEFAULT CHARSET=latin1

i'm trying to store current user_id on the table appointments as a
foreign key. their relationship is  1:M. one user can make many
appointments.

i'm using turbogears 1.0.3.2, SQLObject and MySQL.

the problem is how the way to store current user_id on the other table
as a foreign key.

is anynone has a better solution for this problem?

Thanks for your help !


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to