On Feb 28, 2:26 am, "Jorge Vargas" <[EMAIL PROTECTED]> wrote:
> On 2/26/07, Rainy <[EMAIL PROTECTED]> wrote:
>
> > I can't reproduce this error right now because TG fails to access
> > database.. but this was bugging me for the last few days. I have a
> > form with 4 drop down menus.. When first menu is chosen, it loads the
> > second through ajax. When second is chosen, it loads 3 & 4 through
> > ajax. (1st is country, second is state, 3 & 4 are county and city). It
> > works fine at home but on remote server only the second (state) menu
> > loads, when I change 2nd menu, 3&4 do not load and I get a traceback
> > from TG that goes, AssertionError: This transaction has already gone
> > through ROLLBACK; begin another transaction .
>
> first of all if it works ok on one env and the other we should list
> the differences, if your using different db engines maybe you have hit
> a bug in one of SO's backends. there is no reason for code to work
> different on two hardwares with the same environment.
Doh, google swallowed my previous very detailed reply, maybe because I
pasted it from vim. Anyway, when I use debian Sarge apt package
turbogears-1.0 and dependent packages, it works. When I do
easy_install turbogears (which gets tg 1.0.1) and dependent packages,
it doesn't work. easy_install will not download tg 1.0. Turbogears
website doesn't have 1.0 either. easy_install also does not get
various other versions of packages that are used by debian sarge and
that work. Debian sarge does not list versions of all packages it
uses, and tg-admin info in debian sarge fails.
easy_install and pypi are very annoying.. the docs list -m option to
remove but it actually is a 'multiple version' option. -D option for
deletion is outdated and there is no clear answer on how to delete
packages. Pypi doesn't have older versions for most anything.
I don't really know what to do now. I think I will try to print
information telling me what transaction is active and what's going on
generally with transactions in and around these functions. Another
option is to install debian Sarge on server. That's a lovely solution,
in a way - install a newer operating system that will install older
TurboGears: problem solved.
>
>
>
> > The code in question is this:
>
> > @expose(format="json")
> > def getCounties(self, state_id, tg_errors=None):
> > # print "###getCounties, counties, ",
> > model.State.get(state_id).counties
> > tmp = {"id": "0", "countyName": "Select county.."}
> > is_id = False
> > try:
> > state = int(state_id)
> > is_id = True
> > except:
> > state = state_id
> > is_id = False
>
> > if is_id:
> > counties = [tmp] + model.State.get(state).counties
> > else:
> > counties = [tmp] + model.State.selectBy(stateName=state)
> > [0].counties
> > return dict(counties=counties)
>
> just a note on the structure of the code, instead of using the same
> variable to store the key param and the string param why not add 2
> named params something like
> @expose(format="json")
> def getCounties(self,state_id=None,state_name=None,tg_errors=None):
> if state_id:
> state = int(state_id)
> counties = model.State.get(state).counties
> if state_name:
> counties = model.State.selectBy(stateName=state)[0].counties
> return dict(counties=counties)
>
> play around with SO exceptions for the missing entries and also add a
> check so both are not there, it can be improved a lot but you get the
> idea....
>
> also the tmp variable is not a good idea I don't see why your turning
> it later into a list why not just leave that on the template and just
> move the actual data in the controller, it's always going to be
> "Select county" right?
Because I have jscript code there that loads the options for drop down
menu (singleselectfield). I have no idea how to add an option there..
so I did it in python. I searched the mochikit docs for some
information on this but they don't have anything (actually I was
looking for a way to set value for the option..) I guess I should read
a book on javascript or something, but that will take a long time.
>
> > getCities is similar. Note that at home I just have try: State.get(id)
> > except: State.selectBy(name=state) and it works fine. On remote server
> > I tried to do this because I thought it might be related to the
> > Rollback error. It didn't help of course..
>
> > The reason I'm not sure if I will get an id or a name is that when the
> > menu is loaded from ajax, sometimes it will return name and sometimes
> > id. Menu created by me of course always returns id, as it well should.
>
> ok that makes no sense at all what menu? if this is actually happening
> that's a bug on your menu code.
Well, here's what happens.. There's this javascript line:
> > return OPTION((p.id,p.stateName))
It does not set <option value=p.id>. I think it only returns
<option>statename</option>. But I'm not sure how to check because in
browser, if you choose view source, it shows only static html that was
preloaded, not the new things that were set by javascript.
So, I just check whether it's name or id in the code. This is only a
problem if one name was able to be cast to integer, but that will
never happen here.. "I live in a little town called 3045".
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---