I wonder if someone you explain to me my error, I've been 'stuck' on
the problem below for a while now and can't work it out.
Basically this is a variation on the (in?)famous moviedemo tutorial.
I have modified to work against one of our existing databases so I
know that the data relationships are fairly solid and all the straight
SqlAlchemytesting i've done suggests this is so.
However when I generate the links in the table the next table gets
built but it has no records to show.
<snip>
producer_job_filler = ProducerJobTableFiller(DBSession)
class ProducerJobTableFiller(TableFiller):
__model__ = Job
def producer(self, obj, **kw):
producer = kw['producer']
producers = ', '.join(['<a href="/
activejobs/'+str(producer.producer_id)+'">'+producer.title+'</a>'
for producer in obj.producers if obj.job_id==Job.job_id])
return producers.join(('<div>', '</div>'))
def _do_get_provider_count_and_objs(self, producer=None, **kw):
#jobs = DBSession.query(Job).filter(Job.producer ==
producer).all()
getjobs =
DBSession.query(Job).filter(Job.producer.contains(producer)).all()#original
#return len(jobs), jobs
return len(getjobs), getjobs
controller code:
producer_job_table = ProducerJobTable(DBSession)
@expose('jayne.templates.producer.activejobs')
def activejobs(self,producer_id, **kw):
"""Display Producer Active Jobs"""
tmpl_context.widget = producer_job_table #Generates Producers
table
active =
DBSession.query(Job).filter(Job.producer.contains(producer_id))
#active = DBSession.query(Job).filter(Job.producer =='active')
#active = DBSession.query(Job).filter(producer_id)
value = producer_job_filler.get_value(active=active)
return dict(active=active, value=value)
<snip>
So if i generate a table of jobs with producers, I create a link to
the producer. I am attempting to return;
1 all jobs related to a producer
2 then only those jobs related to that producer which are marked as
'active' in our system.
example: Address in browser bar
http://localhost:8080/activejobs/1 <- producer_id or Job.producer
server output:
FROM jobs
WHERE jobs.producer LIKE concat(concat('%%', %s),'%%')
So i'm missing something fundamental and no doubt obvious but the
ProducerJob
TableFiller is producing links to the producer as strings.
But the server string isn't searching for that string, how would I
chase this down?
TIA
Chriso
--
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.