Skip to content

Commit c2fecb8

Browse files
author
Richard Jones
committed
merge from HEAD
1 parent 14ceade commit c2fecb8

File tree

4 files changed

+55
-46
lines changed

4 files changed

+55
-46
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Fixed:
1212
953678)
1313
- fix anydbm sort/group direction handling, and make RDBMS sort/group use
1414
Link'ed "order" properties (sf bug 953148)
15+
- fix Interval editing (sf bug 954891)
1516

1617

1718
2004-05-07 0.7.1

roundup/backends/back_mysql.py

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -539,23 +539,25 @@ def filter(self, search_matches, filterspec, sort=(None,None),
539539
self.db.sql('select nodeid from %s'%tn)
540540
s = ','.join([x[0] for x in self.db.sql_fetchall()])
541541

542-
where.append('id not in (%s)'%s)
542+
where.append('_%s.id not in (%s)'%(cn, s))
543543
elif isinstance(v, type([])):
544544
frum.append(tn)
545545
s = ','.join([a for x in v])
546-
where.append('id=%s.nodeid and %s.linkid in (%s)'%(tn,tn,s))
546+
where.append('_%s.id=%s.nodeid and %s.linkid in (%s)'%(cn,
547+
tn, tn, s))
547548
args = args + v
548549
else:
549550
frum.append(tn)
550-
where.append('id=%s.nodeid and %s.linkid=%s'%(tn, tn, a))
551+
where.append('_%s.id=%s.nodeid and %s.linkid=%s'%(cn, tn,
552+
tn, a))
551553
args.append(v)
552554
elif k == 'id':
553555
if isinstance(v, type([])):
554556
s = ','.join([a for x in v])
555-
where.append('%s in (%s)'%(k, s))
557+
where.append('_%s.%s in (%s)'%(cn, k, s))
556558
args = args + v
557559
else:
558-
where.append('%s=%s'%(k, a))
560+
where.append('_%s.%s=%s'%(cn, k, a))
559561
args.append(v)
560562
elif isinstance(propclass, String):
561563
if not isinstance(v, type([])):
@@ -567,44 +569,45 @@ def filter(self, search_matches, filterspec, sort=(None,None),
567569
v = ['%%'+self.db.sql_stringquote(s)+'%%' for s in v]
568570

569571
# now add to the where clause
570-
where.append(' or '.join(["_%s LIKE '%s'"%(k, s) for s in v]))
572+
where.append(' or '.join(["_%s._%s LIKE '%s'"%(cn, k, s)
573+
for s in v]))
571574
# note: args are embedded in the query string now
572575
elif isinstance(propclass, Link):
573576
if isinstance(v, type([])):
574577
if '-1' in v:
575578
v = v[:]
576579
v.remove('-1')
577-
xtra = ' or _%s is NULL'%k
580+
xtra = ' or _%s._%s is NULL'%(cn, k)
578581
else:
579582
xtra = ''
580583
if v:
581584
s = ','.join([a for x in v])
582-
where.append('(_%s in (%s)%s)'%(k, s, xtra))
585+
where.append('(_%s._%s in (%s)%s)'%(cn, k, s, xtra))
583586
args = args + v
584587
else:
585-
where.append('_%s is NULL'%k)
588+
where.append('_%s._%s is NULL'%(cn, k))
586589
else:
587590
if v == '-1':
588591
v = None
589-
where.append('_%s is NULL'%k)
592+
where.append('_%s._%s is NULL'%(cn, k))
590593
else:
591-
where.append('_%s=%s'%(k, a))
594+
where.append('_%s._%s=%s'%(cn, k, a))
592595
args.append(v)
593596
elif isinstance(propclass, Date):
594597
dc = self.db.hyperdb_to_sql_value[hyperdb.Date]
595598
if isinstance(v, type([])):
596599
s = ','.join([a for x in v])
597-
where.append('_%s in (%s)'%(k, s))
600+
where.append('_%s._%s in (%s)'%(cn, k, s))
598601
args = args + [dc(date.Date(x)) for x in v]
599602
else:
600603
try:
601604
# Try to filter on range of dates
602605
date_rng = Range(v, date.Date, offset=timezone)
603606
if date_rng.from_value:
604-
where.append('_%s >= %s'%(k, a))
607+
where.append('_%s._%s >= %s'%(cn, k, a))
605608
args.append(dc(date_rng.from_value))
606609
if date_rng.to_value:
607-
where.append('_%s <= %s'%(k, a))
610+
where.append('_%s._%s <= %s'%(cn, k, a))
608611
args.append(dc(date_rng.to_value))
609612
except ValueError:
610613
# If range creation fails - ignore that search parameter
@@ -613,28 +616,28 @@ def filter(self, search_matches, filterspec, sort=(None,None),
613616
# filter using the __<prop>_int__ column
614617
if isinstance(v, type([])):
615618
s = ','.join([a for x in v])
616-
where.append('__%s_int__ in (%s)'%(k, s))
619+
where.append('_%s.__%s_int__ in (%s)'%(cn, k, s))
617620
args = args + [date.Interval(x).as_seconds() for x in v]
618621
else:
619622
try:
620623
# Try to filter on range of intervals
621624
date_rng = Range(v, date.Interval)
622625
if date_rng.from_value:
623-
where.append('__%s_int__ >= %s'%(k, a))
626+
where.append('_%s.__%s_int__ >= %s'%(cn, k, a))
624627
args.append(date_rng.from_value.as_seconds())
625628
if date_rng.to_value:
626-
where.append('__%s_int__ <= %s'%(k, a))
629+
where.append('_%s.__%s_int__ <= %s'%(cn, k, a))
627630
args.append(date_rng.to_value.as_seconds())
628631
except ValueError:
629632
# If range creation fails - ignore that search parameter
630633
pass
631634
else:
632635
if isinstance(v, type([])):
633636
s = ','.join([a for x in v])
634-
where.append('_%s in (%s)'%(k, s))
637+
where.append('_%s._%s in (%s)'%(cn, k, s))
635638
args = args + v
636639
else:
637-
where.append('_%s=%s'%(k, a))
640+
where.append('_%s._%s=%s'%(cn, k, a))
638641
args.append(v)
639642

640643
# don't match retired nodes
@@ -644,7 +647,7 @@ def filter(self, search_matches, filterspec, sort=(None,None),
644647
if search_matches is not None:
645648
v = search_matches.keys()
646649
s = ','.join([a for x in v])
647-
where.append('id in (%s)'%s)
650+
where.append('_%s.id in (%s)'%(cn, s))
648651
args = args + v
649652

650653
# "grouping" is just the first-order sorting in the SQL fetch
@@ -672,9 +675,9 @@ def filter(self, search_matches, filterspec, sort=(None,None),
672675
ordercols.append(tn + '._order')
673676
o = tn + '._order'
674677
elif prop == 'id':
675-
o = 'id'
678+
o = '_%s.id'%cn
676679
else:
677-
o = '_'+prop
680+
o = '_%s._%s'%(cn, prop)
678681
ordercols.append(o)
679682
if sdir == '-':
680683
o += ' desc'

roundup/backends/rdbms_common.py

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: rdbms_common.py,v 1.98.2.2 2004-05-16 09:33:13 richard Exp $
1+
# $Id: rdbms_common.py,v 1.98.2.3 2004-05-16 22:00:08 richard Exp $
22
''' Relational database (SQL) backend common code.
33
44
Basics:
@@ -2024,23 +2024,26 @@ def filter(self, search_matches, filterspec, sort=(None,None),
20242024
if v in ('-1', ['-1']):
20252025
# only match rows that have count(linkid)=0 in the
20262026
# corresponding multilink table)
2027-
where.append('id not in (select nodeid from %s)'%tn)
2027+
where.append('_%s.id not in (select nodeid from %s)'%(cn,
2028+
tn))
20282029
elif isinstance(v, type([])):
20292030
frum.append(tn)
20302031
s = ','.join([a for x in v])
2031-
where.append('id=%s.nodeid and %s.linkid in (%s)'%(tn,tn,s))
2032+
where.append('_%s.id=%s.nodeid and %s.linkid in (%s)'%(cn,
2033+
tn, tn, s))
20322034
args = args + v
20332035
else:
20342036
frum.append(tn)
2035-
where.append('id=%s.nodeid and %s.linkid=%s'%(tn, tn, a))
2037+
where.append('_%s.id=%s.nodeid and %s.linkid=%s'%(cn, tn,
2038+
tn, a))
20362039
args.append(v)
20372040
elif k == 'id':
20382041
if isinstance(v, type([])):
20392042
s = ','.join([a for x in v])
2040-
where.append('%s in (%s)'%(k, s))
2043+
where.append('_%s.%s in (%s)'%(cn, k, s))
20412044
args = args + v
20422045
else:
2043-
where.append('%s=%s'%(k, a))
2046+
where.append('_%s.%s=%s'%(cn, k, a))
20442047
args.append(v)
20452048
elif isinstance(propclass, String):
20462049
if not isinstance(v, type([])):
@@ -2052,44 +2055,45 @@ def filter(self, search_matches, filterspec, sort=(None,None),
20522055
v = ['%%'+self.db.sql_stringquote(s)+'%%' for s in v]
20532056

20542057
# now add to the where clause
2055-
where.append(' or '.join(["_%s LIKE '%s'"%(k, s) for s in v]))
2058+
where.append(' or '.join(["_%s._%s LIKE '%s'"%(cn, k, s)
2059+
for s in v]))
20562060
# note: args are embedded in the query string now
20572061
elif isinstance(propclass, Link):
20582062
if isinstance(v, type([])):
20592063
if '-1' in v:
20602064
v = v[:]
20612065
v.remove('-1')
2062-
xtra = ' or _%s is NULL'%k
2066+
xtra = ' or _%s._%s is NULL'%(cn, k)
20632067
else:
20642068
xtra = ''
20652069
if v:
20662070
s = ','.join([a for x in v])
2067-
where.append('(_%s in (%s)%s)'%(k, s, xtra))
2071+
where.append('(_%s._%s in (%s)%s)'%(cn, k, s, xtra))
20682072
args = args + v
20692073
else:
2070-
where.append('_%s is NULL'%k)
2074+
where.append('_%s._%s is NULL'%(cn, k))
20712075
else:
20722076
if v == '-1':
20732077
v = None
2074-
where.append('_%s is NULL'%k)
2078+
where.append('_%s._%s is NULL'%(cn, k))
20752079
else:
2076-
where.append('_%s=%s'%(k, a))
2080+
where.append('_%s._%s=%s'%(cn, k, a))
20772081
args.append(v)
20782082
elif isinstance(propclass, Date):
20792083
dc = self.db.hyperdb_to_sql_value[hyperdb.Date]
20802084
if isinstance(v, type([])):
20812085
s = ','.join([a for x in v])
2082-
where.append('_%s in (%s)'%(k, s))
2086+
where.append('_%s._%s in (%s)'%(cn, k, s))
20832087
args = args + [dc(date.Date(v)) for x in v]
20842088
else:
20852089
try:
20862090
# Try to filter on range of dates
20872091
date_rng = Range(v, date.Date, offset=timezone)
20882092
if date_rng.from_value:
2089-
where.append('_%s >= %s'%(k, a))
2093+
where.append('_%s._%s >= %s'%(cn, k, a))
20902094
args.append(dc(date_rng.from_value))
20912095
if date_rng.to_value:
2092-
where.append('_%s <= %s'%(k, a))
2096+
where.append('_%s._%s <= %s'%(cn, k, a))
20932097
args.append(dc(date_rng.to_value))
20942098
except ValueError:
20952099
# If range creation fails - ignore that search parameter
@@ -2098,28 +2102,28 @@ def filter(self, search_matches, filterspec, sort=(None,None),
20982102
# filter using the __<prop>_int__ column
20992103
if isinstance(v, type([])):
21002104
s = ','.join([a for x in v])
2101-
where.append('__%s_int__ in (%s)'%(k, s))
2105+
where.append('_%s.__%s_int__ in (%s)'%(cn, k, s))
21022106
args = args + [date.Interval(x).as_seconds() for x in v]
21032107
else:
21042108
try:
21052109
# Try to filter on range of intervals
21062110
date_rng = Range(v, date.Interval)
21072111
if date_rng.from_value:
2108-
where.append('__%s_int__ >= %s'%(k, a))
2112+
where.append('_%s.__%s_int__ >= %s'%(cn, k, a))
21092113
args.append(date_rng.from_value.as_seconds())
21102114
if date_rng.to_value:
2111-
where.append('__%s_int__ <= %s'%(k, a))
2115+
where.append('_%s.__%s_int__ <= %s'%(cn, k, a))
21122116
args.append(date_rng.to_value.as_seconds())
21132117
except ValueError:
21142118
# If range creation fails - ignore that search parameter
21152119
pass
21162120
else:
21172121
if isinstance(v, type([])):
21182122
s = ','.join([a for x in v])
2119-
where.append('_%s in (%s)'%(k, s))
2123+
where.append('_%s._%s in (%s)'%(cn, k, s))
21202124
args = args + v
21212125
else:
2122-
where.append('_%s=%s'%(k, a))
2126+
where.append('_%s._%s=%s'%(cn, k, a))
21232127
args.append(v)
21242128

21252129
# don't match retired nodes
@@ -2129,7 +2133,7 @@ def filter(self, search_matches, filterspec, sort=(None,None),
21292133
if search_matches is not None:
21302134
v = search_matches.keys()
21312135
s = ','.join([a for x in v])
2132-
where.append('id in (%s)'%s)
2136+
where.append('_%s.id in (%s)'%(cn, s))
21332137
args = args + v
21342138

21352139
# "grouping" is just the first-order sorting in the SQL fetch
@@ -2157,9 +2161,9 @@ def filter(self, search_matches, filterspec, sort=(None,None),
21572161
ordercols.append(tn + '._order')
21582162
o = tn + '._order'
21592163
elif prop == 'id':
2160-
o = 'id'
2164+
o = '_%s.id'%cn
21612165
else:
2162-
o = '_'+prop
2166+
o = '_%s._%s'%(cn, prop)
21632167
ordercols.append(o)
21642168
if sdir == '-':
21652169
o += ' desc'
@@ -2187,6 +2191,7 @@ def filter(self, search_matches, filterspec, sort=(None,None),
21872191
args = tuple(args)
21882192
if __debug__:
21892193
print >>hyperdb.DEBUG, 'filter', (self, sql, args)
2194+
__traceback_info__ = (sql, args)
21902195
if args:
21912196
self.db.cursor.execute(sql, args)
21922197
else:

roundup/cgi/templating.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1387,7 +1387,7 @@ def field(self, size = 30):
13871387
else:
13881388
value = cgi.escape(str(self._value))
13891389

1390-
if is_edit_ok():
1390+
if self.is_edit_ok():
13911391
value = '&quot;'.join(value.split('"'))
13921392
return self.input(name=self._formname,value=value,size=size)
13931393

0 commit comments

Comments
 (0)