# HG changeset patch # User Adrien Di Mascio # Date 1253729611 -7200 # Node ID 0924d0d08d6005ee88659ae0ddbb9b62ae8af1b2 # Parent 1a63a252601f2cb417a4c9105f7180d6e302c112 [api] __regid__, cw_* and friends diff -r 1a63a252601f -r 0924d0d08d60 common/mixins.py --- a/common/mixins.py Wed Sep 23 20:12:48 2009 +0200 +++ b/common/mixins.py Wed Sep 23 20:13:31 2009 +0200 @@ -57,7 +57,7 @@ _done = set() for child in self.children(): if child.eid in _done: - self.error('loop in %s tree', self.id.lower()) + self.error('loop in %s tree', self.__regid__.lower()) continue yield child _done.add(child.eid) @@ -83,7 +83,7 @@ parent = self while parent: if parent.eid in path: - self.error('loop in %s tree', self.id.lower()) + self.error('loop in %s tree', self.__regid__.lower()) break path.append(parent.eid) try: @@ -220,7 +220,7 @@ class TreeViewMixIn(object): """a recursive tree view""" - id = 'tree' + __regid__ = 'tree' item_vid = 'treeitem' __select__ = implements(ITree) @@ -238,11 +238,11 @@ self.open_item(entity) entity.view(vid or self.item_vid, w=self.w, **kwargs) relatedrset = entity.children(entities=False) - self.wview(self.id, relatedrset, 'null', done=done, **kwargs) + self.wview(self.__regid__, relatedrset, 'null', done=done, **kwargs) self.close_item(entity) def open_item(self, entity): - self.w(u'
  • \n' % entity.id.lower()) + self.w(u'
  • \n' % entity.__regid__.lower()) def close_item(self, entity): self.w(u'
  • \n') @@ -266,7 +266,7 @@ return parent = entity.parent() if parent: - parent.view(self.id, w=self.w, done=done) + parent.view(self.__regid__, w=self.w, done=done) self.w(self.separator) entity.view(vid or self.item_vid, w=self.w) diff -r 1a63a252601f -r 0924d0d08d60 web/component.py --- a/web/component.py Wed Sep 23 20:12:48 2009 +0200 +++ b/web/component.py Wed Sep 23 20:13:31 2009 +0200 @@ -123,7 +123,7 @@ dumps(params.get('divid', 'paginated-content')), dumps(rql), dumps(params.pop('vid', None)), dumps(params)) else: - url = self.build_url(path, **params) + url = self._cw.build_url(path, **params) return url def page_link(self, path, params, start, stop, content): diff -r 1a63a252601f -r 0924d0d08d60 web/views/autoform.py --- a/web/views/autoform.py Wed Sep 23 20:12:48 2009 +0200 +++ b/web/views/autoform.py Wed Sep 23 20:13:31 2009 +0200 @@ -224,7 +224,7 @@ try: return self._action except AttributeError: - return self.build_url('validateform') + return self._cw.build_url('validateform') def set_action(self, value): """override default action""" diff -r 1a63a252601f -r 0924d0d08d60 web/views/calendar.py --- a/web/views/calendar.py Wed Sep 23 20:12:48 2009 +0200 +++ b/web/views/calendar.py Wed Sep 23 20:13:31 2009 +0200 @@ -49,7 +49,7 @@ def call(self): ical = iCalendar() for i in range(len(self.cw_rset.rows)): - task = self.complete_entity(i) + task = self.cw_rset.complete_entity(i, 0) event = ical.add('vevent') event.add('summary').value = task.dc_title() event.add('description').value = task.dc_description() @@ -80,15 +80,15 @@ def call(self): self.w(u'
    ') for i in range(len(self.cw_rset.rows)): - task = self.complete_entity(i) + task = self.cw_rset.complete_entity(i, 0) self.w(u'
    ') self.w(u'

    %s

    ' % xml_escape(task.dc_title())) self.w(u'
    %s
    ' % task.dc_description(format='text/html')) if task.start: - self.w(u'%s' % (task.start.isoformat(), self.format_date(task.start))) + self.w(u'%s' % (task.start.isoformat(), self._cw.format_date(task.start))) if task.stop: - self.w(u'%s' % (task.stop.isoformat(), self.format_date(task.stop))) + self.w(u'%s' % (task.stop.isoformat(), self._cw.format_date(task.stop))) self.w(u'
    ') self.w(u'
    ') @@ -97,13 +97,13 @@ __regid__ = 'calendaritem' def cell_call(self, row, col, dates=False): - task = self.complete_entity(row) + task = self.cw_rset.complete_entity(row, 0) task.view('oneline', w=self.w) if dates: if task.start and task.stop: - self.w('
    ' % self._cw._('from %(date)s' % {'date': self.format_date(task.start)})) - self.w('
    ' % self._cw._('to %(date)s' % {'date': self.format_date(task.stop)})) - self.w('
    to %s'%self.format_date(task.stop)) + self.w('
    ' % self._cw._('from %(date)s' % {'date': self._cw.format_date(task.start)})) + self.w('
    ' % self._cw._('to %(date)s' % {'date': self._cw.format_date(task.stop)})) + self.w('
    to %s'%self._cw.format_date(task.stop)) class CalendarLargeItemView(CalendarItemView): __regid__ = 'calendarlargeitem' @@ -287,7 +287,7 @@ etype = list(self.cw_rset.column_types(0))[0] url = self.build_url(vid='creation', etype=etype, schedule=True, - start=self.format_date(celldate), stop=self.format_date(celldate), + start=self._cw.format_date(celldate), stop=self._cw.format_date(celldate), __redirectrql=self.cw_rset.printable_rql(), __redirectparams=self._cw.build_url_params(year=curdate.year, month=curmonth), __redirectvid=self.__regid__ @@ -399,9 +399,9 @@ for i, day in enumerate(WEEKDAYS): wdate = first_day_of_week + timedelta(i) if wdate.isocalendar() == _today.isocalendar(): - self.w(u'%s
    %s' % (self._cw._(day), self.format_date(wdate))) + self.w(u'%s
    %s' % (self._cw._(day), self._cw.format_date(wdate))) else: - self.w(u'%s
    %s' % (self._cw._(day), self.format_date(wdate))) + self.w(u'%s
    %s' % (self._cw._(day), self._cw.format_date(wdate))) self.w(u'') # build week calendar diff -r 1a63a252601f -r 0924d0d08d60 web/views/cwuser.py --- a/web/views/cwuser.py Wed Sep 23 20:12:48 2009 +0200 +++ b/web/views/cwuser.py Wed Sep 23 20:13:31 2009 +0200 @@ -47,7 +47,7 @@ self.w(u'\n') def cell_call(self, row, col): - entity = self.complete_entity(row, col) + entity = self.cw_rset.complete_entity(row, col) self.w(u''' diff -r 1a63a252601f -r 0924d0d08d60 web/views/editforms.py --- a/web/views/editforms.py Wed Sep 23 20:12:48 2009 +0200 +++ b/web/views/editforms.py Wed Sep 23 20:13:31 2009 +0200 @@ -54,7 +54,7 @@ Button(stdmsgs.NO, cwaction='cancel')] @property def action(self): - return self.build_url('edit') + return self._cw.build_url('edit') def __init__(self, *args, **kwargs): super(DeleteConfForm, self).__init__(*args, **kwargs) @@ -291,15 +291,15 @@ title = _('edition') def cell_call(self, row, col, **kwargs): - entity = self.complete_entity(row, col) + entity = self.cw_rset.complete_entity(row, col) self.render_form(entity) def render_form(self, entity): """fetch and render the form""" self.form_title(entity) form = self._cw.vreg['forms'].select('edition', self._cw, rset=entity.rset, - row=entity.row, col=entity.col, entity=entity, - submitmsg=self.submited_message()) + row=entity.row, col=entity.col, entity=entity, + submitmsg=self.submited_message()) self.init_form(form, entity) self.w(form.form_render(formvid=u'edition')) diff -r 1a63a252601f -r 0924d0d08d60 web/views/massmailing.py --- a/web/views/massmailing.py Wed Sep 23 20:12:48 2009 +0200 +++ b/web/views/massmailing.py Wed Sep 23 20:13:31 2009 +0200 @@ -33,8 +33,8 @@ params = {'vid': 'massmailing', '__force_display': 1} if self._cw.form.has_key('rql'): params['rql'] = self._cw.form['rql'] - return self.build_url(self._cw.relative_path(includeparams=False), - **params) + return self._cw.build_url(self._cw.relative_path(includeparams=False), + **params) class MassMailingForm(forms.FieldsForm): diff -r 1a63a252601f -r 0924d0d08d60 web/views/navigation.py --- a/web/views/navigation.py Wed Sep 23 20:12:48 2009 +0200 +++ b/web/views/navigation.py Wed Sep 23 20:13:31 2009 +0200 @@ -159,7 +159,7 @@ nav.clean_params(params) # make a link to see them all if show_all_option: - url = xml_escape(self.build_url(__force_display=1, **params)) + url = xml_escape(self._cw.build_url(__force_display=1, **params)) w(u'%s\n' % (url, req._('show %s results') % len(rset))) rset.limit(offset=start, limit=stop-start, inplace=True) diff -r 1a63a252601f -r 0924d0d08d60 web/views/old_calendar.py --- a/web/views/old_calendar.py Wed Sep 23 20:12:48 2009 +0200 +++ b/web/views/old_calendar.py Wed Sep 23 20:13:31 2009 +0200 @@ -46,14 +46,14 @@ next2 = next_month(date, bigshift) rql = self.cw_rset.printable_rql() return self.NAV_HEADER % ( - xml_escape(self.build_url(rql=rql, vid=self.__regid__, year=prev2.year, - month=prev2.month)), - xml_escape(self.build_url(rql=rql, vid=self.__regid__, year=prev1.year, - month=prev1.month)), - xml_escape(self.build_url(rql=rql, vid=self.__regid__, year=next1.year, - month=next1.month)), - xml_escape(self.build_url(rql=rql, vid=self.__regid__, year=next2.year, - month=next2.month))) + xml_escape(self._cw.build_url(rql=rql, vid=self.__regid__, year=prev2.year, + month=prev2.month)), + xml_escape(self._cw.build_url(rql=rql, vid=self.__regid__, year=prev1.year, + month=prev1.month)), + xml_escape(self._cw.build_url(rql=rql, vid=self.__regid__, year=next1.year, + month=next1.month)), + xml_escape(self._cw.build_url(rql=rql, vid=self.__regid__, year=next2.year, + month=next2.month))) # Calendar building methods ############################################## @@ -69,7 +69,7 @@ """method responsible for building *one* HTML calendar""" # FIXME iterates between [first_day-first_day.day_of_week ; # last_day+6-last_day.day_of_week] - umonth = self.format_date(first_day, '%B %Y') # localized month name + umonth = self._cw.format_date(first_day, '%B %Y') # localized month name rows = [] current_row = [NO_CELL] * first_day.weekday() for daynum in xrange(0, days_in_month(first_day)): @@ -89,8 +89,8 @@ rql = self.cw_rset.printable_rql() if day.weekday() != 6: rows.append(u'%s%s' % (WEEKNUM_CELL % day.isocalendar()[1], ''.join(current_row))) - url = self.build_url(rql=rql, vid='calendarmonth', - year=first_day.year, month=first_day.month) + url = self._cw.build_url(rql=rql, vid='calendarmonth', + year=first_day.year, month=first_day.month) monthlink = u'%s' % (xml_escape(url), umonth) return CALENDAR(self._cw) % (monthlink, '\n'.join(rows)) @@ -111,7 +111,7 @@ for row in xrange(len(self.cw_rset.rows)): entity = self.cw_rset.get_entity(row,0) infos = u'
    ' - infos += self.view(itemvid, self.cw_rset, row=row) + infos += self._cw.view(itemvid, self.cw_rset, row=row) infos += u'
    ' for date_ in entity.matching_dates(begin, end): day = date(date_.year, date_.month, date_.day) @@ -200,9 +200,9 @@ self.w(u'') rql = self.cw_rset.printable_rql() for cur_month in date_range(begin, end, incmonth=1): - umonth = u'%s %s' % (self.format_date(cur_month, '%B'), cur_month.year) - url = self.build_url(rql=rql, vid=self.__regid__, - year=cur_month.year, month=cur_month.month) + umonth = u'%s %s' % (self._cw.format_date(cur_month, '%B'), cur_month.year) + url = self._cw.build_url(rql=rql, vid=self.__regid__, + year=cur_month.year, month=cur_month.month) self.w(u'%s' % (xml_escape(url), umonth)) self.w(u'') @@ -269,9 +269,9 @@ rql = self.cw_rset.printable_rql() _ = self._cw._ for monday, sunday in weeks: - umonth = self.format_date(monday, '%B %Y') - url = self.build_url(rql=rql, vid='calendarmonth', - year=monday.year, month=monday.month) + umonth = self._cw.format_date(monday, '%B %Y') + url = self._cw.build_url(rql=rql, vid='calendarmonth', + year=monday.year, month=monday.month) monthlink = '%s' % (xml_escape(url), umonth) self.w(u'%s %s (%s)' \ % (_('week'), monday.isocalendar()[1], monthlink)) @@ -295,10 +295,10 @@ next2 = date + ONEWEEK * bigshift rql = self.cw_rset.printable_rql() return self.NAV_HEADER % ( - xml_escape(self.build_url(rql=rql, vid=self.__regid__, year=prev2.year, week=prev2.isocalendar()[1])), - xml_escape(self.build_url(rql=rql, vid=self.__regid__, year=prev1.year, week=prev1.isocalendar()[1])), - xml_escape(self.build_url(rql=rql, vid=self.__regid__, year=next1.year, week=next1.isocalendar()[1])), - xml_escape(self.build_url(rql=rql, vid=self.__regid__, year=next2.year, week=next2.isocalendar()[1]))) + xml_escape(self._cw.build_url(rql=rql, vid=self.__regid__, year=prev2.year, week=prev2.isocalendar()[1])), + xml_escape(self._cw.build_url(rql=rql, vid=self.__regid__, year=prev1.year, week=prev1.isocalendar()[1])), + xml_escape(self._cw.build_url(rql=rql, vid=self.__regid__, year=next1.year, week=next1.isocalendar()[1])), + xml_escape(self._cw.build_url(rql=rql, vid=self.__regid__, year=next2.year, week=next2.isocalendar()[1]))) @@ -308,7 +308,7 @@ def build_calendar(self, schedule, first_day): """method responsible for building *one* HTML calendar""" - umonth = self.format_date(first_day, '%B %Y') # localized month name + umonth = self._cw.format_date(first_day, '%B %Y') # localized month name rows = [] # each row is: (am,pm), (am,pm) ... week_title current_row = [(NO_CELL, NO_CELL, NO_CELL)] * first_day.weekday() rql = self.cw_rset.printable_rql() @@ -324,7 +324,7 @@ AMPM_EMPTY % ("pmCell", "pm"))) # store & reset current row on Sundays if day.weekday() == 6: - url = self.build_url(rql=rql, vid='ampmcalendarweek', + url = self._cw.build_url(rql=rql, vid='ampmcalendarweek', year=day.year, week=day.isocalendar()[1]) weeklink = '%s' % (xml_escape(url), day.isocalendar()[1]) @@ -332,7 +332,7 @@ rows.append(current_row) current_row = [] current_row.extend([(NO_CELL, NO_CELL, NO_CELL)] * (6-day.weekday())) - url = self.build_url(rql=rql, vid='ampmcalendarweek', + url = self._cw.build_url(rql=rql, vid='ampmcalendarweek', year=day.year, week=day.isocalendar()[1]) weeklink = '%s' % (xml_escape(url), day.isocalendar()[1]) current_row.append(WEEKNUM_CELL % weeklink) @@ -348,7 +348,7 @@ formatted_rows.append(' %s'% '\n'.join(am_row)) formatted_rows.append(' %s'% '\n'.join(pm_row)) # tigh everything together - url = self.build_url(rql=rql, vid='ampmcalendarmonth', + url = self._cw.build_url(rql=rql, vid='ampmcalendarmonth', year=first_day.year, month=first_day.month) monthlink = '%s' % (xml_escape(url), umonth) return CALENDAR(self._cw) % (monthlink, '\n'.join(formatted_rows)) @@ -364,8 +364,8 @@ self.w(u'') rql = self.cw_rset.printable_rql() for cur_month in date_range(begin, end, incmonth=1): - umonth = u'%s %s' % (self.format_date(cur_month, '%B'), cur_month.year) - url = self.build_url(rql=rql, vid=self.__regid__, + umonth = u'%s %s' % (self._cw.format_date(cur_month, '%B'), cur_month.year) + url = self._cw.build_url(rql=rql, vid=self.__regid__, year=cur_month.year, month=cur_month.month) self.w(u'%s' % (xml_escape(url), umonth)) @@ -399,7 +399,7 @@ def build_calendar(self, schedule, first_day): """method responsible for building *one* HTML calendar""" - umonth = self.format_date(first_day, '%B %Y') # localized month name + umonth = self._cw.format_date(first_day, '%B %Y') # localized month name rows = [] # each row is: (am,pm), (am,pm) ... week_title current_row = [(NO_CELL, NO_CELL, NO_CELL)] * first_day.weekday() rql = self.cw_rset.printable_rql() @@ -415,16 +415,16 @@ AMPM_EMPTY % ("pmCell", "pm"))) # store & reset current row on Sundays if day.weekday() == 6: - url = self.build_url(rql=rql, vid='ampmcalendarweek', - year=day.year, week=day.isocalendar()[1]) + url = self._cw.build_url(rql=rql, vid='ampmcalendarweek', + year=day.year, week=day.isocalendar()[1]) weeklink = '%s' % (xml_escape(url), day.isocalendar()[1]) current_row.append(WEEKNUM_CELL % weeklink) rows.append(current_row) current_row = [] current_row.extend([(NO_CELL, NO_CELL, NO_CELL)] * (6-day.weekday())) - url = self.build_url(rql=rql, vid='ampmcalendarweek', - year=day.year, week=day.isocalendar()[1]) + url = self._cw.build_url(rql=rql, vid='ampmcalendarweek', + year=day.year, week=day.isocalendar()[1]) weeklink = '%s' % (xml_escape(url), day.isocalendar()[1]) current_row.append(WEEKNUM_CELL % weeklink) @@ -440,8 +440,8 @@ formatted_rows.append(' %s'% '\n'.join(am_row)) formatted_rows.append(' %s'% '\n'.join(pm_row)) # tigh everything together - url = self.build_url(rql=rql, vid='ampmcalendarmonth', - year=first_day.year, month=first_day.month) + url = self._cw.build_url(rql=rql, vid='ampmcalendarmonth', + year=first_day.year, month=first_day.month) monthlink = '%s' % (xml_escape(url), umonth) return CALENDAR(self._cw) % (monthlink, '\n'.join(formatted_rows)) @@ -458,9 +458,9 @@ w = self.w _ = self._cw._ for monday, sunday in weeks: - umonth = self.format_date(monday, '%B %Y') - url = self.build_url(rql=rql, vid='ampmcalendarmonth', - year=monday.year, month=monday.month) + umonth = self._cw.format_date(monday, '%B %Y') + url = self._cw.build_url(rql=rql, vid='ampmcalendarmonth', + year=monday.year, month=monday.month) monthlink = '%s' % (xml_escape(url), umonth) w(u'%s' % ( WEEK_TITLE % (_('week'), monday.isocalendar()[1], monthlink))) @@ -474,7 +474,7 @@ hours.sort() w(AMPM_DAYWEEK % ( len(hours), _(WEEKDAYS[day.weekday()]), - self.format_date(day))) + self._cw.format_date(day))) w(AMPM_WEEK_CELL % ( hours[0].hour, hours[0].minute, '\n'.join(events[hours[0]]))) @@ -486,7 +486,7 @@ else: w(AMPM_DAYWEEK_EMPTY % ( _(WEEKDAYS[day.weekday()]), - self.format_date(day))) + self._cw.format_date(day))) w(WEEK_EMPTY_CELL) w(u'') diff -r 1a63a252601f -r 0924d0d08d60 web/views/startup.py --- a/web/views/startup.py Wed Sep 23 20:12:48 2009 +0200 +++ b/web/views/startup.py Wed Sep 23 20:13:31 2009 +0200 @@ -74,7 +74,7 @@ def startupviews_table(self): for v in self._cw.vreg['views'].possible_views(self._cw, None): - if v.category != 'startupview' or v.id in ('index', 'tree', 'manage'): + if v.category != 'startupview' or v.__regid__ in ('index', 'tree', 'manage'): continue self.w('

    %s

    ' % ( xml_escape(v.url()), xml_escape(self._cw._(v.title).capitalize()))) diff -r 1a63a252601f -r 0924d0d08d60 web/views/tableview.py --- a/web/views/tableview.py Wed Sep 23 20:12:48 2009 +0200 +++ b/web/views/tableview.py Wed Sep 23 20:13:31 2009 +0200 @@ -60,7 +60,7 @@ self.w(u'
    ' % (divid, hidden and 'hidden' or '')) self.w(u'' % divid) self.w(u'') - filter_hiddens(self.w, facets=','.join(wdg.facet.id for wdg in fwidgets), + filter_hiddens(self.w, facets=','.join(wdg.facet.__regid__ for wdg in fwidgets), baserql=baserql) self.w(u'\n') self.w(u'\n') @@ -165,7 +165,6 @@ if not fromformfilter: self.w(u'\n') - def show_hide_actions(self, divid, currentlydisplayed=False): showhide = u';'.join(toggle_action('%s%s' % (divid, what))[11:] for what in ('Form', 'Show', 'Hide', 'Actions'))