Author: remi
Date: 2009-06-23 16:17:01 +0200 (Tue, 23 Jun 2009)
New Revision: 4872
Modified:
software_suite_v3/smart-core/smart-server/trunk/resources/04_robot_content_interactions/00_resourceRobotContentInteractions.py
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/ugc/Ugc.py
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/ugc/UgcContainer.py
Log:
* auto-sort of gadgets by time creation.
Modified:
software_suite_v3/smart-core/smart-server/trunk/resources/04_robot_content_interactions/00_resourceRobotContentInteractions.py
===================================================================
---
software_suite_v3/smart-core/smart-server/trunk/resources/04_robot_content_interactions/00_resourceRobotContentInteractions.py
2009-06-23 13:04:58 UTC (rev 4871)
+++
software_suite_v3/smart-core/smart-server/trunk/resources/04_robot_content_interactions/00_resourceRobotContentInteractions.py
2009-06-23 14:17:01 UTC (rev 4872)
@@ -373,7 +373,10 @@
def insertOnDemand(self, ugc):
"""
"""
- self.__onDemandList.append(ugc)
+ self.__onDemandList = []
+ for ugcObj in resourceUgcServer.getUgcContainer().getUgcs():
+ if ugcObj.getDescription().onDemandIsActivated():
+ self.__onDemandList.append(ugcObj)
self.computeOnDemandDictForThumbnailBar()
def removeOnDemand(self, ugc):
Modified:
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/ugc/Ugc.py
===================================================================
---
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/ugc/Ugc.py
2009-06-23 13:04:58 UTC (rev 4871)
+++
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/ugc/Ugc.py
2009-06-23 14:17:01 UTC (rev 4872)
@@ -34,6 +34,8 @@
self.__ugcFile = ugcFile
# Save the parent gadget object
self.__parentGadget = parentGadget
+ # Creation time of the ugc file
+ self.__ugcFileCreationTime = None
# Create descriptor
self.__description = UgcDescription(self, dictionary['description'])
# Create ugc parameters
@@ -227,6 +229,24 @@
return self.__ugcFile
#
--------------------------------------------------------------------------
+ # Set the creation time of the ugc file.
+ #
--------------------------------------------------------------------------
+ def setUgcFileCreationTime(self, value):
+ """Set the creation time of the ugc file.
+ @param value: An integer.
+ """
+ self.__ugcFileCreationTime = value
+
+ #
--------------------------------------------------------------------------
+ # Get the creation time of the ugc file.
+ #
--------------------------------------------------------------------------
+ def getUgcFileCreationTime(self):
+ """Get the creation time of the ugc file.
+ @return: An integer.
+ """
+ return self.__ugcFileCreationTime
+
+ #
--------------------------------------------------------------------------
# Get the parent UGCs container.
#
--------------------------------------------------------------------------
def getContainer(self):
Modified:
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/ugc/UgcContainer.py
===================================================================
---
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/ugc/UgcContainer.py
2009-06-23 13:04:58 UTC (rev 4871)
+++
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/ugc/UgcContainer.py
2009-06-23 14:17:01 UTC (rev 4872)
@@ -200,6 +200,7 @@
"Can't read the ugc file")
self.__mutex.release()
return False
+ (mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime) =
os.stat(fileName)
# Get the parent gadget
if not ugcDataDict.has_key('parentGadget'):
if self.__onUgcDeploymentErrorCallback != None:
@@ -220,6 +221,7 @@
# Create the Ugc
try:
ugc = Ugc(self, ugcDataDict, fileName, parentGadget)
+ ugc.setUgcFileCreationTime(ctime)
except:
if self.__onUgcDeploymentErrorCallback != None:
self.__onUgcDeploymentErrorCallback(observerName, fileName,
@@ -229,9 +231,23 @@
return False
# Add the Ugc in the container
self.__ugcs.append(ugc)
+ # Sort the ugc list by creation time
+ unSortedList = []
+ for ugcObj in self.__ugcs:
+ unSortedList.append(ugcObj)
+ self.__ugcs = []
+ while len(unSortedList) > 0:
+ older = 99999999999
+ match = None
+ for ugcObj in unSortedList:
+ if ugcObj.getUgcFileCreationTime() < older:
+ match = ugcObj
+ older = ugcObj.getUgcFileCreationTime()
+ unSortedList.remove(match)
+ self.__ugcs.append(match)
+ self.__mutex.release()
if self.__onUgcDeployedCallback != None:
self.__onUgcDeployedCallback(ugc, fileName)
- self.__mutex.release()
return True
#
--------------------------------------------------------------------------
------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn