--- Begin Message ---
Package: luma
Version: 2.4-2
Severity: wishlist
Tags: patch
Hi,
the luma 2.4-2 Browser plugin derives the attrbrutes to be shown in the search
result list from the attributes used in the filter.
This is sometimes a bit pointless as one often shows the values used in the
filter
[e.g. with the filter "(sn=Marschall)", the value of the sn attribute gets
shown,
which always contains at least the value "Marschall"]
The attached patch tries to be a bit more flexible:
It adds an "Attributes:" input box that allows entering attribute names,
separated
by space or comma and dispalys these attributes instead of the ones from the
filter.
If the "Attributes" input field is empty, the original behaviour is used.
Thanks for maintaining luma in Debian
Peter
-- System Information:
Debian Release: squeeze/sid
APT prefers testing
APT policy: (990, 'testing'), (500, 'unstable'), (500, 'stable')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.26-2-amd64 (SMP w/2 CPU cores)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages luma depends on:
ii python 2.5.4-4 An interactive high-level object-o
ii python-ldap 2.3.10-1 LDAP interface module for Python
ii python-qt3 3.18.1-2 Qt3 bindings for Python
ii python-support 1.0.6 automated rebuilding support for P
luma recommends no packages.
luma suggests no packages.
-- no debconf information
#! /bin/sh /usr/share/dpatch/dpatch-run
## luma-2.4-search.patch
## DP: allow searching with attributes
# From: Peter Marschall <[email protected]>
# Subject: allow searching with attributes
--- luma-2.4/lib/luma/base/backend/SmartDataObject.py
+++ luma-2.4/lib/luma/base/backend/SmartDataObject.py
@@ -33,17 +33,19 @@ class SmartDataObject (object):
self.doSchemaChecks = True
self.isValid = False
self.checkErrorMessageList = ["No error checking done yet."]
+ self.attributeMap = {}
self.dn = data[0]
self.data = data[1]
# This is the string representing our key for the objectclasses.
# Important for lower- and uppercase variants
+ # also add a map for lowercase attribute names to real ones
self.objectClassName = None
for x in self.data.keys():
+ self.attributeMap[x.lower()] = x
if "objectclass" == x.lower():
self.objectClassName = x
- break
# Set server meta information
self.serverMeta = serverMeta
@@ -170,6 +172,8 @@ class SmartDataObject (object):
if None == attributeName:
raise FunctionArgumentException("Function getAttributeValueList( attributeName ) called without a parameter.")
+ attributeName = self.attributeMap[attributeName.lower()]
+
if self.data.has_key(attributeName):
# Binary values are returned normally.
# String values have to be decoded from utf-8 to unicode.
@@ -195,7 +199,8 @@ class SmartDataObject (object):
if (None == attributeName) or (None == valueIndex):
raise FunctionArgumentException("Function getAttributeValue( attributeName, valueIndex ) called without correct parameters.")
-
+ attributeName = self.attributeMap[attributeName.lower()]
+
if self.data.has_key(attributeName):
# Is the data length of the attribute compatible with the given index?
if valueIndex < len(self.data[attributeName]):
@@ -238,6 +243,8 @@ class SmartDataObject (object):
if None == attributeName:
raise FunctionArgumentException("Function addAttributeValue( attributeName, valueList) called without correct parameters.")
+ attributeName = self.attributeMap[attributeName.lower()]
+
# Do we work on an existing attribute?
if self.data.has_key(attributeName):
@@ -359,6 +366,8 @@ class SmartDataObject (object):
if (None == attributeName) or (None == valueIndex) or (None == newValue):
raise FunctionArgumentException("Function setAttributeValue( attributeName, valueIndex, newValue ) called without correct parameters.")
+ attributeName = self.attributeMap[attributeName.lower()]
+
if self.data.has_key(attributeName):
# Is the data length of the attribute compatible with the given index?
if valueIndex < len(self.data[attributeName]):
--- luma-2.4/lib/luma/base/utils/gui/SearchForm.py
+++ luma-2.4/lib/luma/base/utils/gui/SearchForm.py
@@ -144,11 +144,16 @@ class SearchForm(SearchFormDesign):
###############################################################################
def getSearchCriteria(self):
- filterString = unicode(self.searchEdit.currentText()).encode('utf-8')
- filterPattern = re.compile("\(\w*=")
- tmpList = filterPattern.findall(filterString)
-
- return map(lambda x: x[1:-1], tmpList)
+ attributeString = unicode(self.attributeEdit.currentText()).encode('utf-8')
+ if attributeString:
+ attributeString = attributeString.replace(",", " ")
+ return attributeString.split()
+ else:
+ filterPattern = re.compile("\(\w*=")
+ filterString = unicode(self.searchEdit.currentText()).encode('utf-8')
+ filterPattern = re.compile("\(\w*=")
+ tmpList = filterPattern.findall(filterString)
+ return map(lambda x: x[1:-1], tmpList)
###############################################################################
--- luma-2.4/lib/luma/base/utils/gui/SearchResultView.py
+++ luma-2.4/lib/luma/base/utils/gui/SearchResultView.py
@@ -30,7 +30,6 @@ from base.utils import getSortedDnList
-
class SearchResultView(SearchResultViewDesign):
def __init__(self, parent=None, name=None, fl=0):
@@ -145,7 +144,7 @@ class SearchResultView(SearchResultViewD
while self.resultListView.columns():
self.resultListView.removeColumn(0)
-
+
self.FILTER_COLUMN_POS = {}
position = self.resultListView.addColumn("dn")
self.FILTER_COLUMN_POS["dn"] = position
@@ -179,6 +178,7 @@ class SearchResultView(SearchResultViewD
self.resultListView.insertItem(listItem)
self.resultListView.setColumnWidth(0, 250)
+ self.resultListView.setResizeMode(QListView.AllColumns)
self.resultListView.triggerUpdate()
--- luma-2.4/lib/luma/base/utils/gui/SearchFormDesign.ui
+++ luma-2.4/lib/luma/base/utils/gui/SearchFormDesign.ui
@@ -98,6 +98,22 @@
<bool>true</bool>
</property>
</widget>
+ <widget class="QComboBox" row="2" column="1" rowspan="1" colspan="4">
+ <property name="name">
+ <cstring>attributeEdit</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ </widget>
<widget class="QLabel" row="0" column="2">
<property name="name">
<cstring>textLabel1</cstring>
@@ -135,6 +151,22 @@
<string>Filter:</string>
</property>
</widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>textLabel7</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Attributes:</string>
+ </property>
+ </widget>
<widget class="QLabel" row="0" column="0">
<property name="name">
<cstring>textLabel2</cstring>
@@ -203,8 +235,9 @@
<tabstops>
<tabstop>serverBox</tabstop>
<tabstop>baseBox</tabstop>
- <tabstop>searchEdit</tabstop>
<tabstop>filterWizardButton</tabstop>
+ <tabstop>searchEdit</tabstop>
+ <tabstop>attributeEdit</tabstop>
<tabstop>startButton</tabstop>
</tabstops>
<slots>
--- luma-2.4/lib/luma/base/utils/gui/SearchFormDesign.py
+++ luma-2.4/lib/luma/base/utils/gui/SearchFormDesign.py
@@ -44,6 +44,12 @@
groupFrameLayout.addMultiCellWidget(self.searchEdit,1,1,1,4)
+ self.attributeEdit = QComboBox(0,self.groupFrame,"attributeEdit")
+ self.attributeEdit.setSizePolicy(QSizePolicy(QSizePolicy.Expanding,QSizePolicy.Fixed,0,0,self.attributeEdit.sizePolicy().hasHeightForWidth()))
+ self.attributeEdit.setEditable(1)
+
+ groupFrameLayout.addMultiCellWidget(self.attributeEdit,2,2,1,4)
+
self.textLabel1 = QLabel(self.groupFrame,"textLabel1")
self.textLabel1.setSizePolicy(QSizePolicy(QSizePolicy.Fixed,QSizePolicy.Preferred,0,0,self.textLabel1.sizePolicy().hasHeightForWidth()))
@@ -58,6 +64,11 @@
groupFrameLayout.addWidget(self.textLabel6,1,0)
+ self.textLabel7 = QLabel(self.groupFrame,"textLabel7")
+ self.textLabel7.setSizePolicy(QSizePolicy(QSizePolicy.Fixed,QSizePolicy.Preferred,0,0,self.textLabel7.sizePolicy().hasHeightForWidth()))
+
+ groupFrameLayout.addWidget(self.textLabel7,2,0)
+
self.textLabel2 = QLabel(self.groupFrame,"textLabel2")
self.textLabel2.setSizePolicy(QSizePolicy(QSizePolicy.Fixed,QSizePolicy.Preferred,0,0,self.textLabel2.sizePolicy().hasHeightForWidth()))
@@ -81,9 +92,10 @@
self.connect(self.serverBox,SIGNAL("activated(const QString&)"),self.serverChanged)
self.setTabOrder(self.serverBox,self.baseBox)
- self.setTabOrder(self.baseBox,self.searchEdit)
- self.setTabOrder(self.searchEdit,self.filterWizardButton)
- self.setTabOrder(self.filterWizardButton,self.startButton)
+ self.setTabOrder(self.baseBox,self.filterWizardButton)
+ self.setTabOrder(self.filterWizardButton,self.searchEdit)
+ self.setTabOrder(self.searchEdit,self.attributeEdit)
+ self.setTabOrder(self.attributeEdit,self.startButton)
def languageChange(self):
@@ -92,6 +104,7 @@
self.filterWizardButton.setAccel(self.__tr("Alt+F"))
self.textLabel1.setText(self.__tr("Base DN:"))
self.textLabel6.setText(self.__tr("Filter:"))
+ self.textLabel7.setText(self.__tr("Attributes:"))
self.textLabel2.setText(self.__tr("Server:"))
self.startButton.setText(self.__tr("&Search"))
self.startButton.setAccel(self.__tr("Alt+S"))
--- End Message ---