svn commit: r1481259 - /bloodhound/trunk/installer/requirements.txt
Author: andrej Date: Sat May 11 06:54:24 2013 New Revision: 1481259 URL: http://svn.apache.org/r1481259 Log: including bhrelations egg in requirements.txt Modified: bloodhound/trunk/installer/requirements.txt Modified: bloodhound/trunk/installer/requirements.txt URL: http://svn.apache.org/viewvc/bloodhound/trunk/installer/requirements.txt?rev=1481259r1=1481258r2=1481259view=diff == --- bloodhound/trunk/installer/requirements.txt (original) +++ bloodhound/trunk/installer/requirements.txt Sat May 11 06:54:24 2013 @@ -28,4 +28,4 @@ TracThemeEngine ../bloodhound_theme TracPermRedirect ../bloodhound_search - +-e ../bloodhound_relations
svn commit: r1478770 - in /bloodhound/trunk/bloodhound_relations/bhrelations: api.py tests/api.py
Author: andrej Date: Fri May 3 13:18:56 2013 New Revision: 1478770 URL: http://svn.apache.org/r1478770 Log: adding multi-product fixes and tests to bhrelations - towards BEP-0006 Modified: bloodhound/trunk/bloodhound_relations/bhrelations/api.py bloodhound/trunk/bloodhound_relations/bhrelations/tests/api.py Modified: bloodhound/trunk/bloodhound_relations/bhrelations/api.py URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_relations/bhrelations/api.py?rev=1478770r1=1478769r2=1478770view=diff == --- bloodhound/trunk/bloodhound_relations/bhrelations/api.py (original) +++ bloodhound/trunk/bloodhound_relations/bhrelations/api.py Fri May 3 13:18:56 2013 @@ -414,9 +414,14 @@ class ResourceIdSerializer(object): * resource_instance: can be instance of a ticket, wiki page etc. resource = resource_instance.resource -rsys = ResourceSystem(manager_for_neighborhood( -env, resource.neighborhood)) -nbhprefix = rsys.neighborhood_prefix(resource.neighborhood) +# nbhprefix = ResourceSystem(env).neighborhood_prefix( +# resource.neighborhood) + +#TODO: temporary workaround for the ticket specific behavior +#change it to generic resource behaviour +ticket = resource_instance +nbhprefix = ticket[product] + resource_full_id = cls.RESOURCE_ID_DELIMITER.join( (nbhprefix, resource.realm, unicode(resource.id)) ) @@ -471,10 +476,9 @@ class TicketRelationsSpecifics(Component Bloodhound Relations % resource.realm) def _get_env_for_resource(self, resource): -if hasattr(resource, nbhprefix) and resource.nbhprefix: -env = ProductEnvironment(resource.nbhprefix) -elif hasattr(self.env, parent) and self.env.parent: -env = self.env.parent +if hasattr(resource, neighborhood): +env = ResourceSystem(self.env).load_component_manager( +resource.neighborhood) else: env = self.env return env Modified: bloodhound/trunk/bloodhound_relations/bhrelations/tests/api.py URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_relations/bhrelations/tests/api.py?rev=1478770r1=1478769r2=1478770view=diff == --- bloodhound/trunk/bloodhound_relations/bhrelations/tests/api.py (original) +++ bloodhound/trunk/bloodhound_relations/bhrelations/tests/api.py Fri May 3 13:18:56 2013 @@ -19,12 +19,15 @@ # under the License. from datetime import datetime from _sqlite3 import OperationalError, IntegrityError -from bhrelations.api import EnvironmentSetup, RelationsSystem, CycleValidationError, ParentValidationError, TicketRelationsSpecifics +from bhrelations.api import (EnvironmentSetup, RelationsSystem, + CycleValidationError, ParentValidationError, + TicketRelationsSpecifics) +from multiproduct.env import ProductEnvironment +from tests.env import MultiproductTestCase from trac.ticket.model import Ticket from trac.test import EnvironmentStub, Mock from trac.core import TracError from trac.util.datefmt import utc -import unittest try: from babel import Locale @@ -32,23 +35,30 @@ try: except ImportError: locale_en = None -class ApiTestCase(unittest.TestCase): +class ApiTestCase(MultiproductTestCase): def setUp(self): -self.env = EnvironmentStub( +env = EnvironmentStub( default_data=True, -enable=['trac.*', 'bhrelations.*'] +enable=['trac.*', 'multiproduct.*', 'bhrelations.*'] ) config_name = RelationsSystem.RELATIONS_CONFIG_NAME -self.env.config.set(config_name, 'dependency', 'dependson,dependent') -self.env.config.set(config_name, 'dependency.validator', 'no_cycle') -self.env.config.set(config_name, 'dependent.blocks', 'true') -self.env.config.set(config_name, 'parent_children','parent,children') -self.env.config.set(config_name, 'parent_children.validator', +env.config.set(config_name, 'dependency', 'dependson,dependent') +env.config.set(config_name, 'dependency.validator', 'no_cycle') +env.config.set(config_name, 'dependent.blocks', 'true') +env.config.set(config_name, 'parent_children','parent,children') +env.config.set(config_name, 'parent_children.validator', 'parent_child') -self.env.config.set(config_name, 'children.label', 'Overridden') -self.env.config.set(config_name, 'parent.copy_fields', +env.config.set(config_name, 'children.label', 'Overridden') +env.config.set(config_name, 'parent.copy_fields', 'summary, foo
svn commit: r1477664 - /bloodhound/trunk/bloodhound_dashboard/bhdashboard/model.py
Author: andrej Date: Tue Apr 30 14:39:00 2013 New Revision: 1477664 URL: http://svn.apache.org/r1477664 Log: adding detailed column specification functionality to bhdashboard.Model - towards bhrelations Modified: bloodhound/trunk/bloodhound_dashboard/bhdashboard/model.py Modified: bloodhound/trunk/bloodhound_dashboard/bhdashboard/model.py URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_dashboard/bhdashboard/model.py?rev=1477664r1=1477663r2=1477664view=diff == --- bloodhound/trunk/bloodhound_dashboard/bhdashboard/model.py (original) +++ bloodhound/trunk/bloodhound_dashboard/bhdashboard/model.py Tue Apr 30 14:39:00 2013 @@ -46,9 +46,20 @@ class ModelBase(object): _meta = {'table_name':'mytable', 'object_name':'WhatIWillCallMyselfInMessages', 'key_fields':['id','id2'], - 'non_key_fields':['thing','anotherthing'], + 'non_key_fields':[ +'thing', +{ +name:field_name_x, +type='int64', +size=None, +key_size=None, +auto_increment=False +}], 'auto_inc_fields': ['id',], } +key_fields and non_key_fields parameters may contain field name only (for +text columns) or dict with detailed column specification. In case of +detailed column specification 'name' parameter is obligatory). def __init__(self, env, keys=None): @@ -61,13 +72,18 @@ class ModelBase(object): self._data = {} self._exists = False self._env = env -self._all_fields = self._meta['key_fields'] + \ - self._meta['non_key_fields'] +self._key_fields = self._get_field_names(self._meta['key_fields']) +self._non_key_fields = self._get_field_names( +self._meta['non_key_fields']) +self._all_fields = self._key_fields + self._non_key_fields +self._unique_fields = self._meta['unique_fields'] +self._auto_inc_fields = self._get_auto_inc_field_names() + if keys is not None: self._get_row(keys) else: self._update_from_row(None) - + def update_field_dict(self, field_dict): Updates the object's copy of the db fields (no db transaction) self._data.update(field_dict) @@ -93,7 +109,7 @@ class ModelBase(object): def _update_from_row(self, row = None): uses a provided database row to update the model -fields = self._meta['key_fields']+self._meta['non_key_fields'] +fields = self._all_fields self._exists = row is not None if row is None: row = [None]*len(fields) @@ -104,8 +120,8 @@ class ModelBase(object): def _get_row(self, keys): queries the database and stores the result in the model row = None -where, values = fields_to_kv_str(self._meta['key_fields'], keys) -fields = ','.join(self._meta['key_fields']+self._meta['non_key_fields']) +where, values = fields_to_kv_str(self._key_fields, keys) +fields = ','.join(self._all_fields) sdata = {'fields':fields, 'where':where} sdata.update(self._meta) @@ -125,7 +141,7 @@ class ModelBase(object): Deletes the matching record from the database if not self._exists: raise TracError('%(object_name)s does not exist' % self._meta) -where, values = fields_to_kv_str(self._meta['key_fields'], self._data) +where, values = fields_to_kv_str(self._key_fields, self._data) sdata = {'where': where} sdata.update(self._meta) sql = DELETE FROM %(table_name)s @@ -144,33 +160,29 @@ class ModelBase(object): sdata = None if self._exists or len(self.select(self._env, where = dict([(k,self._data[k]) - for k in self._meta['key_fields']]))): + for k in self._key_fields]))): sdata = {'keys':','.join([%s='%s' % (k, self._data[k]) - for k in self._meta['key_fields']])} -elif self._meta['unique_fields'] and len(self.select(self._env, where = + for k in self._key_fields])} +elif self._unique_fields and len(self.select(self._env, where = dict([(k,self._data[k]) - for k in self._meta['unique_fields']]))): + for k in self._unique_fields]))): sdata = {'keys':','.join([%s='%s' % (k, self._data[k]) - for k in self._meta['unique_fields']])} + for k in self._unique_fields])} if sdata
svn commit: r1477673 - in /bloodhound/trunk/bloodhound_relations/bhrelations: api.py db_default.py
Author: andrej Date: Tue Apr 30 14:50:40 2013 New Revision: 1477673 URL: http://svn.apache.org/r1477673 Log: fixing forgotten increment of bhrelations db_version - towards BPE-0006 Modified: bloodhound/trunk/bloodhound_relations/bhrelations/api.py bloodhound/trunk/bloodhound_relations/bhrelations/db_default.py Modified: bloodhound/trunk/bloodhound_relations/bhrelations/api.py URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_relations/bhrelations/api.py?rev=1477673r1=1477672r2=1477673view=diff == --- bloodhound/trunk/bloodhound_relations/bhrelations/api.py (original) +++ bloodhound/trunk/bloodhound_relations/bhrelations/api.py Tue Apr 30 14:50:40 2013 @@ -64,7 +64,7 @@ class EnvironmentSetup(Component): with self.env.db_direct_transaction as db: if db_installed_version 1: self._initialize_db(db) -self._update_db_version(db, 1) +self._update_db_version(db, db_default.DB_VERSION) #add upgrade logic later if needed def _get_version(self): Modified: bloodhound/trunk/bloodhound_relations/bhrelations/db_default.py URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_relations/bhrelations/db_default.py?rev=1477673r1=1477672r2=1477673view=diff == --- bloodhound/trunk/bloodhound_relations/bhrelations/db_default.py (original) +++ bloodhound/trunk/bloodhound_relations/bhrelations/db_default.py Tue Apr 30 14:50:40 2013 @@ -20,7 +20,7 @@ from bhrelations.model import Relation DB_SYSTEM_KEY = 'bhrelations' -DB_VERSION = 1 +DB_VERSION = 2 SCHEMA = [mcls._get_schema() for mcls in (Relation, )]
svn commit: r1477361 - in /bloodhound/trunk: bloodhound_multiproduct/multiproduct/dbcursor.py bloodhound_relations/bhrelations/api.py bloodhound_relations/bhrelations/model.py bloodhound_relations/bhr
Author: andrej Date: Mon Apr 29 21:44:59 2013 New Revision: 1477361 URL: http://svn.apache.org/r1477361 Log: adding resolution blocking for ticketfor bhrelations - work in progress Modified: bloodhound/trunk/bloodhound_multiproduct/multiproduct/dbcursor.py bloodhound/trunk/bloodhound_relations/bhrelations/api.py bloodhound/trunk/bloodhound_relations/bhrelations/model.py bloodhound/trunk/bloodhound_relations/bhrelations/tests/api.py Modified: bloodhound/trunk/bloodhound_multiproduct/multiproduct/dbcursor.py URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_multiproduct/multiproduct/dbcursor.py?rev=1477361r1=1477360r2=1477361view=diff == --- bloodhound/trunk/bloodhound_multiproduct/multiproduct/dbcursor.py (original) +++ bloodhound/trunk/bloodhound_multiproduct/multiproduct/dbcursor.py Mon Apr 29 21:44:59 2013 @@ -32,7 +32,7 @@ SKIP_TABLES = ['auth_cookie', 'cache', 'repository', 'revision', 'node_change', 'bloodhound_product', 'bloodhound_productresourcemap', 'bloodhound_productconfig', - 'sqlite_master' + 'sqlite_master', 'bloodhound_relations' ] TRANSLATE_TABLES = ['system', 'ticket', 'ticket_change', 'ticket_custom', Modified: bloodhound/trunk/bloodhound_relations/bhrelations/api.py URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_relations/bhrelations/api.py?rev=1477361r1=1477360r2=1477361view=diff == --- bloodhound/trunk/bloodhound_relations/bhrelations/api.py (original) +++ bloodhound/trunk/bloodhound_relations/bhrelations/api.py Mon Apr 29 21:44:59 2013 @@ -25,12 +25,16 @@ from trac.core import Component, impleme from trac.env import IEnvironmentSetupParticipant from trac.db import DatabaseManager from trac.resource import (manager_for_neighborhood, ResourceSystem, Resource, - get_resource_shortname) -from trac.ticket import Ticket + get_resource_shortname, get_resource_description, + get_resource_summary, get_relative_resource, Neighborhood) +from trac.ticket import Ticket, ITicketManipulator PLUGIN_NAME = 'Bloodhound Relations Plugin' -class ValidationError(TracError): +class CycleValidationError(TracError): +pass + +class ParentValidationError(TracError): pass class EnvironmentSetup(Component): @@ -97,9 +101,8 @@ class EnvironmentSetup(Component): class RelationsSystem(Component): PARENT_RELATION_TYPE = 'parent' +CHILDREN_RELATION_TYPE = 'children' RELATIONS_CONFIG_NAME = 'bhrelations_links' -RESOURCE_ID_DELIMITER = u: -RELATION_ID_DELIMITER = u, def __init__(self): self._links, self._labels, \ @@ -122,9 +125,10 @@ class RelationsSystem(Component): relation_type, comment = None, ): -source = self.get_resource_id_from_instance(source_resource_instance) -destination = self.get_resource_id_from_instance( -destination_resource_instance) +source = ResourceIdSerializer.get_resource_id_from_instance( +self.env, source_resource_instance) +destination = ResourceIdSerializer.get_resource_id_from_instance( +self.env, destination_resource_instance) relation = Relation(self.env) relation.source = source relation.destination = destination @@ -133,28 +137,23 @@ class RelationsSystem(Component): self.add_relation(relation) def add_relation(self, relation): -self.validate(relation) #TBD: add changes in source and destination ticket history +self.validate(relation) with self.env.db_transaction: relation.insert() other_end = self.link_ends_map[relation.type] if other_end: reverted_relation = relation.clone_reverted(other_end) +# self.validate(relation) reverted_relation.insert() def delete( self, relation_id, ): -source, destination, relation_type = self._parse_relation_id( -relation_id) -#TODO: some optimization can be introduced here to not load relations +#TODO: some optimization can be made here by not loading relations #before actual DELETE SQL -relation = Relation(self.env, keys=dict( -source=source, -destination=destination, -type=relation_type -)) +relation = Relation.load_by_relation_id(self.env, relation_id) self._delete_relation(relation) def _delete_relation(self, relation): @@ -180,22 +179,24 @@ class RelationsSystem(Component): def get_relations(self, resource_instance): relation_list
svn commit: r1476161 - /bloodhound/trunk/bloodhound_dashboard/bhdashboard/model.py
Author: andrej Date: Fri Apr 26 12:16:31 2013 New Revision: 1476161 URL: http://svn.apache.org/r1476161 Log: fixing auto_inc_fields behaviour, adding ORDER BY feature to model select function Modified: bloodhound/trunk/bloodhound_dashboard/bhdashboard/model.py Modified: bloodhound/trunk/bloodhound_dashboard/bhdashboard/model.py URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_dashboard/bhdashboard/model.py?rev=1476161r1=1476160r2=1476161view=diff == --- bloodhound/trunk/bloodhound_dashboard/bhdashboard/model.py (original) +++ bloodhound/trunk/bloodhound_dashboard/bhdashboard/model.py Fri Apr 26 12:16:31 2013 @@ -158,21 +158,32 @@ class ModelBase(object): raise TracError('%(object_name)s %(keys)s already exists %(values)s' % sdata) +auto_inc = self._meta.get('auto_inc_fields', []) for key in self._meta['key_fields']: -if self._data[key] is None: +if self._data[key] is None and key not in auto_inc: sdata = {'key':key} sdata.update(self._meta) raise TracError('%(key)s required for %(object_name)s' % sdata) -fields = self._meta['key_fields']+self._meta['non_key_fields'] + +auto_inc = self._meta.get('auto_inc_fields', []) +non_auto_increment_key_fields = [ +field for field in self._meta['key_fields'] +if field not in auto_inc] +fields = non_auto_increment_key_fields + self._meta['non_key_fields'] sdata = {'fields':','.join(fields), 'values':','.join(['%s'] * len(fields))} sdata.update(self._meta) - + sql = INSERT INTO %(table_name)s (%(fields)s) VALUES (%(values)s) % sdata with self._env.db_transaction as db: -db(sql, [self._data[f] for f in fields]) +cursor = db.cursor() +cursor.execute(sql, [self._data[f] for f in fields]) +for auto_in_field in auto_inc: +self._data[auto_in_field] = db.get_last_id( +cursor, sdata[table_name], auto_in_field) + self._exists = True self._old_data.update(self._data) TicketSystem(self._env).reset_ticket_fields() @@ -216,10 +227,13 @@ class ModelBase(object): ResourceSystem(self._env).resource_changed(self, old_values) - @classmethod -def select(cls, env, db=None, where=None, limit=None): -Query the database to get a set of records back +def select(cls, env, db=None, where=None, limit=None, order_by=None): + +Query the database to get a set of records back +* order_by: is list of fields with optional sort direction +(asc or desc) e.g. [field1, field2 desc] + rows = [] fields = cls._meta['key_fields']+cls._meta['non_key_fields'] @@ -229,11 +243,13 @@ class ModelBase(object): wherestr, values = dict_to_kv_str(where) if wherestr: wherestr = ' WHERE ' + wherestr +final_sql = sql + wherestr if limit is not None: -limitstr = ' LIMIT ' + str(int(limit)) -else: -limitstr = '' -for row in env.db_query(sql + wherestr + limitstr, values): +final_sql += ' LIMIT ' + str(int(limit)) +final_sql +if order_by: +final_sql += \nORDER BY + ', '.join(order_by) +for row in env.db_query(final_sql, values): # we won't know which class we need until called model = cls.__new__(cls) data = dict([(fields[i], row[i]) for i in range(len(fields))])
svn commit: r1476162 - in /bloodhound/trunk: ./ bloodhound_relations/ bloodhound_relations/bhrelations/ bloodhound_relations/bhrelations/tests/ bloodhound_relations/trac_ticket_links/
Author: andrej Date: Fri Apr 26 12:17:58 2013 New Revision: 1476162 URL: http://svn.apache.org/r1476162 Log: adding bhrelation api draft implementation, removing trac-ticket-links dependencies Added: bloodhound/trunk/bloodhound_relations/bhrelations/db_default.py bloodhound/trunk/bloodhound_relations/bhrelations/model.py bloodhound/trunk/bloodhound_relations/bhrelations/tests/api.py Removed: bloodhound/trunk/bloodhound_relations/bhrelations/tests/bhrelations_links.py bloodhound/trunk/bloodhound_relations/bhrelations/ticket_links_other.py bloodhound/trunk/bloodhound_relations/trac_ticket_links/ Modified: bloodhound/trunk/.rat-ignore bloodhound/trunk/bloodhound_relations/README bloodhound/trunk/bloodhound_relations/bhrelations/api.py bloodhound/trunk/bloodhound_relations/setup.py Modified: bloodhound/trunk/.rat-ignore URL: http://svn.apache.org/viewvc/bloodhound/trunk/.rat-ignore?rev=1476162r1=1476161r2=1476162view=diff == --- bloodhound/trunk/.rat-ignore (original) +++ bloodhound/trunk/.rat-ignore Fri Apr 26 12:17:58 2013 @@ -10,7 +10,6 @@ doc/html-templates/js/jquery-1.8.2.js doc/wireframes/src/ installer/README.rst trac/ -bloodhound_relations/bhrelations/trac/ bloodhound_relations/bhrelations/default-pages/ bloodhound_multiproduct/tests/admin/*.txt bloodhound_multiproduct/tests/*.txt \ No newline at end of file Modified: bloodhound/trunk/bloodhound_relations/README URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_relations/README?rev=1476162r1=1476161r2=1476162view=diff == --- bloodhound/trunk/bloodhound_relations/README (original) +++ bloodhound/trunk/bloodhound_relations/README Fri Apr 26 12:17:58 2013 @@ -28,8 +28,4 @@ If you have any issues, please create a == The Trac ticket-links branch Bloodhound Relations plugin contains the code from the Trac ticket-links branch, which -is licensed under the same license as Trac (http://trac.edgewall.org/wiki/TracLicense). -The plugin trac_ticket_links directory represents an updated copy of the combined vendor branch -located on https://svn.apache.org/repos/asf/bloodhound/vendor/trac-ticket-links. -The combined vendor branch represents a source tree merged from the several original -vendor branches. For more information on the original vendor branches, see //svn.apache.org/repos/asf/bloodhound/vendor/README +is licensed under the same license as Trac (http://trac.edgewall.org/wiki/TracLicense). \ No newline at end of file Modified: bloodhound/trunk/bloodhound_relations/bhrelations/api.py URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_relations/bhrelations/api.py?rev=1476162r1=1476161r2=1476162view=diff == --- bloodhound/trunk/bloodhound_relations/bhrelations/api.py (original) +++ bloodhound/trunk/bloodhound_relations/bhrelations/api.py Fri Apr 26 12:17:58 2013 @@ -17,5 +17,280 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +from bhrelations import db_default +from bhrelations.model import Relation +from multiproduct.env import ProductEnvironment +from trac.core import Component, implements, TracError +from trac.env import IEnvironmentSetupParticipant +from trac.db import DatabaseManager +from trac.resource import manager_for_neighborhood, ResourceSystem +from trac.ticket import Ticket +PLUGIN_NAME = 'Bloodhound Relations Plugin' + + +class EnvironmentSetup(Component): +implements(IEnvironmentSetupParticipant) + +def environment_created(self): +self.found_db_version = 0 +self.upgrade_environment(self.env.db_transaction) + +def environment_needs_upgrade(self, db): +Detects if the installed db version matches the running system +db_installed_version = self._get_version() + +db_version = db_default.DB_VERSION +if db_installed_version db_version: +raise TracError('''Current db version (%d) newer than supported by +this version of the %s (%d).''' % (db_installed_version, + PLUGIN_NAME, + db_version)) +needs_upgrade = db_installed_version db_version +return needs_upgrade + +def upgrade_environment(self, db): +self.log.debug(upgrading existing environment for %s plugin. % + PLUGIN_NAME) +db_installed_version = self._get_version() +with self.env.db_direct_transaction as db: +if db_installed_version 1: +self._initialize_db(db) +self._update_db_version(db, 1) +#add upgrade logic later if needed + +def _get_version(self): +Finds the current
svn commit: r1469222 - /bloodhound/trunk/installer/bloodhound_setup.py
Author: andrej Date: Thu Apr 18 08:18:57 2013 New Revision: 1469222 URL: http://svn.apache.org/r1469222 Log: disabling bhrelations.* components by default during installation - towards bep-0006 Modified: bloodhound/trunk/installer/bloodhound_setup.py Modified: bloodhound/trunk/installer/bloodhound_setup.py URL: http://svn.apache.org/viewvc/bloodhound/trunk/installer/bloodhound_setup.py?rev=1469222r1=1469221r2=1469222view=diff == --- bloodhound/trunk/installer/bloodhound_setup.py (original) +++ bloodhound/trunk/installer/bloodhound_setup.py Thu Apr 18 08:18:57 2013 @@ -63,6 +63,7 @@ BASE_CONFIG = {'components': {'bhtheme.* 'themeengine.api.*': 'enabled', 'themeengine.web_ui.*': 'enabled', 'bhsearch.*': 'enabled', + 'bhrelations.*': 'disabled', 'trac.ticket.web_ui.ticketmodule': 'disabled', 'trac.ticket.report.reportmodule': 'disabled', },
svn commit: r1469232 - in /bloodhound/trunk/trac/trac/ticket: api.py tests/api.py
Author: andrej Date: Thu Apr 18 09:13:37 2013 New Revision: 1469232 URL: http://svn.apache.org/r1469232 Log: patching trac with a new method ITicketFieldProvider.get_raw_fields - the change is required by bhrelations plugin Modified: bloodhound/trunk/trac/trac/ticket/api.py bloodhound/trunk/trac/trac/ticket/tests/api.py Modified: bloodhound/trunk/trac/trac/ticket/api.py URL: http://svn.apache.org/viewvc/bloodhound/trunk/trac/trac/ticket/api.py?rev=1469232r1=1469231r2=1469232view=diff == --- bloodhound/trunk/trac/trac/ticket/api.py (original) +++ bloodhound/trunk/trac/trac/ticket/api.py Thu Apr 18 09:13:37 2013 @@ -187,6 +187,16 @@ class ITicketFieldProvider(Interface): specified as optional. +def get_raw_fields(): +Returns a list of fields, each represents ticket field +dictionary. For example: +* name: field name +* type: field type +* label: the label to display, preferably wrapped with N_() +* format: field format +* other appropriate field properties + + class TicketSystem(Component): implements(IPermissionRequestor, IWikiSyntaxProvider, IResourceManager, ITicketFieldProvider) @@ -386,12 +396,33 @@ class TicketSystem(Component): field['custom'] = True fields.append(field) +#TODO: this is Bloodhound specific patch to the Trac. Contact Trac +# community about possibility to apply the change to the Trac codebase +self._add_raw_fields_from_field_providers(fields) + return fields reserved_field_names = ['report', 'order', 'desc', 'group', 'groupdesc', 'col', 'row', 'format', 'max', 'page', 'verbose', 'comment', 'or'] +def _add_raw_fields_from_field_providers(self, fields): +for field_provider in self.ticket_field_providers: +if hasattr(field_provider, 'get_raw_fields'): +raw_fields = field_provider.get_raw_fields() +if raw_fields: +for raw_field in raw_fields: +self._add_raw_field( +raw_field, fields) + +def _add_raw_field(self, raw_field, fields): +if raw_field[name] in [f['name'] for f in fields]: +self.log.warning( +'Duplicate field name %s (ignoring)', raw_field[name]) +else: +fields.append(raw_field) + + def get_custom_fields(self): return copy.deepcopy(self.custom_fields) Modified: bloodhound/trunk/trac/trac/ticket/tests/api.py URL: http://svn.apache.org/viewvc/bloodhound/trunk/trac/trac/ticket/tests/api.py?rev=1469232r1=1469231r2=1469232view=diff == --- bloodhound/trunk/trac/trac/ticket/tests/api.py (original) +++ bloodhound/trunk/trac/trac/ticket/tests/api.py Thu Apr 18 09:13:37 2013 @@ -1,10 +1,26 @@ from trac.perm import PermissionCache, PermissionSystem -from trac.ticket.api import TicketSystem +from trac.ticket.api import TicketSystem, ITicketFieldProvider from trac.ticket.model import Ticket from trac.test import EnvironmentStub, Mock +from trac.core import implements, Component import unittest +class TestFieldProvider(Component): +implements(ITicketFieldProvider) + +def __init__(self): +self.raw_fields = [] + +def get_select_fields(self): +return [] + +def get_radio_fields(self): +return [] + +def get_raw_fields(self): +return self.raw_fields + class TicketSystemTestCase(unittest.TestCase): @@ -121,6 +137,41 @@ class TicketSystemTestCase(unittest.Test self.assertEqual(['leave'], self._get_actions({'status': 'reopened'})) self.assertEqual(['leave'], self._get_actions({'status': 'closed'})) +def test_can_add_raw_fields_from_field_providers(self): +testFieldProvider = self.env[TestFieldProvider] +self.assertIsNotNone(testFieldProvider) +testFieldProvider.raw_fields = [ +{ +'name': test_name, +'type': 'some_type', +'label': some_label, +}, +] +fields = TicketSystem(self.env).get_ticket_fields() +row_added_fields = [ +field for field in fields if field[name] == test_name] +self.assertEqual(1, len(row_added_fields)) + +def test_does_not_add_duplicated_raw_fields_from_field_providers(self): +testFieldProvider = self.env[TestFieldProvider] +self.assertIsNotNone(testFieldProvider) +testFieldProvider.raw_fields = [ +{ +'name': test_name, +'type': 'some_type1', +'label': some_label1, +}, +{ +'name': test_name, +'type
svn commit: r1467907 - in /bloodhound/trunk: ./ bloodhound_relations/ bloodhound_relations/bhrelations/default-pages/ bloodhound_relations/bhrelations/trac/ bloodhound_relations/bhrelations/trac/ticke
Author: andrej Date: Mon Apr 15 09:00:02 2013 New Revision: 1467907 URL: http://svn.apache.org/r1467907 Log: adding track-links files to the bhrelations source tree Added: bloodhound/trunk/bloodhound_relations/bhrelations/default-pages/ bloodhound/trunk/bloodhound_relations/bhrelations/trac/ - copied from r1466510, bloodhound/vendor/trac-ticket-links/trac/ bloodhound/trunk/bloodhound_relations/bhrelations/trac/ticket/__init__.py - copied unchanged from r1467897, bloodhound/trunk/bloodhound_relations/bhrelations/__init__.py bloodhound/trunk/bloodhound_relations/bhrelations/trac/ticket/tests/__init__.py Modified: bloodhound/trunk/.rat-ignore bloodhound/trunk/bloodhound_relations/MANIFEST.in bloodhound/trunk/bloodhound_relations/setup.py Modified: bloodhound/trunk/.rat-ignore URL: http://svn.apache.org/viewvc/bloodhound/trunk/.rat-ignore?rev=1467907r1=1467906r2=1467907view=diff == --- bloodhound/trunk/.rat-ignore (original) +++ bloodhound/trunk/.rat-ignore Mon Apr 15 09:00:02 2013 @@ -10,4 +10,5 @@ doc/html-templates/js/jquery-1.8.2.js doc/wireframes/src/ installer/README.rst trac/ - +bloodhound_relations/bhrelations/trac/ +bloodhound_relations/bhrelations/default-pages/ Modified: bloodhound/trunk/bloodhound_relations/MANIFEST.in URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_relations/MANIFEST.in?rev=1467907r1=1467906r2=1467907view=diff == --- bloodhound/trunk/bloodhound_relations/MANIFEST.in (original) +++ bloodhound/trunk/bloodhound_relations/MANIFEST.in Mon Apr 15 09:00:02 2013 @@ -1,4 +1,3 @@ include README CHANGES graft bhrelations/templates - Added: bloodhound/trunk/bloodhound_relations/bhrelations/trac/ticket/tests/__init__.py URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_relations/bhrelations/trac/ticket/tests/__init__.py?rev=1467907view=auto == --- bloodhound/trunk/bloodhound_relations/bhrelations/trac/ticket/tests/__init__.py (added) +++ bloodhound/trunk/bloodhound_relations/bhrelations/trac/ticket/tests/__init__.py Mon Apr 15 09:00:02 2013 @@ -0,0 +1,20 @@ +#!/usr/bin/env python +# -*- coding: UTF-8 -*- + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# License); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + Modified: bloodhound/trunk/bloodhound_relations/setup.py URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_relations/setup.py?rev=1467907r1=1467906r2=1467907view=diff == --- bloodhound/trunk/bloodhound_relations/setup.py (original) +++ bloodhound/trunk/bloodhound_relations/setup.py Mon Apr 15 09:00:02 2013 @@ -89,7 +89,7 @@ finally: chglog.close() DIST_NM = 'BloodhoundRelationsPlugin' -PKG_INFO = {'bhrelations' : ('bhrelations', # Package dir +PKG_INFO = {'bhrelations': ('bhrelations', # Package dir # Package data ['../CHANGES', '../TODO', '../COPYRIGHT', '../NOTICE', '../README', '../TESTING_README', @@ -97,10 +97,12 @@ PKG_INFO = {'bhrelations' : ('bhrelation 'htdocs/img/*.*', 'htdocs/js/*.js', 'templates/*', 'default-pages/*'], ), -'bhrelations.tests' : ('bhrelations/tests', # Package dir -# Package data -['data/*.*'], - ), +'bhrelations.tests': ( +'bhrelations/tests', ['data/*.*']), +'bhrelations.trac.ticket': ( +'bhrelations/trac/ticket', []), +'bhrelations.trac.ticket.tests' : ( +'bhrelations/trac/ticket/tests', []), } ENTRY_POINTS = {