[Erp5-dev] own workflow state catalogged in own table, its translation - how to?

Łukasz Nowak lukasz.nowak at ventis.com.pl
Thu Sep 11 11:55:11 CEST 2008


Hello,

We are using our own workflow state - operation_state.

I created my own table for this state in catalog: ventisopstate.

Searching/sorting is working for this operation_state column. So far so
good.

But I wanted to be able to sort/search by this state translated title.

So I've copy&pasted:
 * z_related_translated_validation_state
=> z_related_translated_operation_state

 * z_related_translated_validation_state_title =>
z_related_translated_operation_state_title

Modified both scripts, updated sql_catalog_related_keys.

So columns using this state are automatically recognised as
searchable/sortable.

But invoking such simple script:

return context.portal_catalog(
  portal_type='Production Order',
  translated_operation_state_title='Finished',
)

Gives me attached traceback.

Ok - I understand, that no column is found in those tables, as there is
no such column. But what else shall I do, to have my own table in this
query? I've analysed catalog properties, but no property is looking good
to configure this... Where can I read more about it (except code - I'll
do it anyway if anything else fails...)

Regards,
Luke

-- 
Łukasz Nowak R&D Ventis http://www.ventis.com.pl/
tel: +48 32 768 16 85 fax: +48 32 392 10 61
``Use the Source, Luke...'' I am only craftsman.

-------------- next part --------------
Traceback (innermost last):

Module ZPublisher.Publish, line 114, in publish
112 |                      missing_name,
113 |                      dont_publish_class,
114>|                      request, bind=1)
115 |
116 |        if result is not response:

Module ZPublisher.mapply, line 88, in mapply
086 |
087 |    args=tuple(args)
088>|    if debug is not None: return debug(object,args,context)
089 |    else: return object(*args)

Module ZPublisher.Publish, line 40, in call_object
038 |
039 |def call_object(object, args, request):
040>|    result=apply(object,args) # Type s<cr> to step into published object.
041 |    return result
042 |

Module Shared.DC.Scripts.Bindings, line 311, in __call__
309 |    def __call__(self, *args, **kw):
310 |        '''Calls the script.'''
311>|        return self._bindAndExec(args, kw, None)
312 |
313 |    def __render_with_namespace__(self, namespace):

Module Shared.DC.Scripts.Bindings, line 348, in _bindAndExec
346 |                exec bindcode
347 |                bound_data = bound_data[0]
348>|            return self._exec(bound_data, args, kw)
349 |        finally:
350 |            security.removeContext(self)

Module Products.PythonScripts.PythonScript, line 324, in _exec
322 |        f = new.function(fcode, g, None, fadefs)
323 |
324>|        result = f(*args, **kw)
325 |        if keyset is not None:
326 |            # Store the result in the cache.

Module None, line 2, in test_py
   - <PythonScript at /erp5/portal_skins/custom/test_py>   - Line 2
000 |return context.portal_catalog(
001>|  portal_type='Production Order',
002 |  translated_operation_state_title='Finished',
003 |)
Module Products.ERP5Catalog.CatalogTool, line 620, in searchResults
618 |        #LOG("searchResult", INFO, catalog_id)
619 |        #         LOG("searchResult", INFO, ZCatalog.searchResults(self, query=query, sql_catalog_id=catalog_id, src__=1, **kw))
620>|        return ZCatalog.searchResults(self, query=query, sql_catalog_id=catalog_id, **kw)
621 |
622 |    __call__ = searchResults

Module Products.ZSQLCatalog.ZSQLCatalog, line 1054, in searchResults
1052 |    catalog = self.getSQLCatalog(sql_catalog_id)
1053 |    if catalog is not None:
1054>|      return apply(catalog.searchResults, (REQUEST,used), kw)
1055 |    return []
1056 |

Module Products.ZSQLCatalog.SQLCatalog, line 2160, in searchResults
2158 |    # The used argument is deprecated and is ignored
2159 |    method = getattr(self, self.sql_search_results)
2160>|    return self.queryResults(method, REQUEST=REQUEST, used=used, **kw)
2161 |
2162 |  __call__ = searchResults

Module Products.ZSQLCatalog.SQLCatalog, line 2154, in queryResults
2152 |    #LOG('queryResults',0,'kw: %s' % str(kw))
2153 |    #LOG('queryResults',0,'from_table_list: %s' % str(query['from_table_list']))
2154>|    return sql_method(src__=src__, **kw)
2155 |      
2156 |  def searchResults(self, REQUEST=None, used=None, **kw):

Module Products.ERP5Type.patches.DA, line 220, in DA__call__
218 |#         if 'portal_ids' in query:
219 |#           LOG("DA query", INFO, "query = %s" %(query,))
220>|        result=DB__.query(query, self.max_rows_)
221 |      except:
222 |        LOG("DA call raise", ERROR, "DB = %s, c = %s, query = %s" %(DB__, c, query), error=sys.exc_info())

Module Products.ZMySQLDA.db, line 295, in query
293 |
294 |    def query(self, *args, **kw):
295>|        return self._access_db(method_id='query', args=args, kw=kw)
296 |
297 |    def string_literal(self, *args, **kw):

Module Products.ZMySQLDA.db, line 286, in _access_db
284 |                    transactions=self._transactions)
285 |            self._pool_set(ident, db)
286>|        return getattr(db, method_id)(*args, **kw)
287 |
288 |    def tables(self, *args, **kw):

Module Products.ZMySQLDA.db, line 421, in query
419 |                qs = "%s LIMIT %d" % (qs,max_rows)
420 |                r=0
421>|            c = self._query(qs)
422 |            if desc is not None:
423 |                if c and (c.describe() != desc):

Module Products.ZMySQLDA.db, line 396, in _query
394 |        except OperationalError, m:
395 |            if m[0] in query_syntax_error:
396>|              raise OperationalError(m[0], '%s: %s' % (m[1], query))
397 |            if m[0] in lock_error:
398 |              raise ConflictError('%s: %s: %s' % (m[0], m[1], query))
OperationalError: (1054, 'Unknown column \'ventisopstate.operation_state\' in \'where clause\': SELECT DISTINCT\n   catalog.path,   catalog.uid    \nFROM\n       catalog AS catalog, translation AS related_translation_0      \nWHERE \n  1 = 1 \n  AND (((((related_translation_0.translated_message = \'Finished\'))))) AND (((((catalog.portal_type = \'Production Order\'))))) AND (((catalog.security_uid IN (147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196)) OR (((((((catalog.viewable_owner = \'ERP5TypeTestCase\'))))))))) AND (related_translation_0.original_message = ventisopstate.operation_state\n AND related_translation_0.message_context = "operation_state_title"\n AND related_translation_0.language = \'en\')\nLIMIT 1000')


More information about the Erp5-dev mailing list