本文整理汇总了Python中MaKaC.common.PickleJar.DictPickler类的典型用法代码示例。如果您正苦于以下问题:Python DictPickler类的具体用法?Python DictPickler怎么用?Python DictPickler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DictPickler类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getVars
def getVars( self ):
vars = wcomponents.WTemplated.getVars( self )
plugins = self._tabPlugins
singleBookingPlugins, multipleBookingPlugins = CollaborationTools.splitPluginsByAllowMultiple(plugins)
CSBookingManager = self._conf.getCSBookingManager()
bookingsS = {}
for p in singleBookingPlugins:
bookingList = CSBookingManager.getBookingList(filterByType = p.getName())
if len(bookingList) > 0:
bookingsS[p.getName()] = DictPickler.pickle(bookingList[0])
bookingsM = DictPickler.pickle(CSBookingManager.getBookingList(
sorted = True,
notify = True,
filterByType = [p.getName() for p in multipleBookingPlugins]))
vars["Conference"] = self._conf
vars["AllPlugins"] = plugins
vars["SingleBookingPlugins"] = singleBookingPlugins
vars["BookingsS"] = bookingsS
vars["MultipleBookingPlugins"] = multipleBookingPlugins
vars["BookingsM"] = bookingsM
vars["Tab"] = self._activeTab
vars["EventDate"] = formatDateTime(getAdjustedDate(nowutc(),self._conf))
from MaKaC.webinterface.rh.collaboration import RCCollaborationAdmin, RCCollaborationPluginAdmin
vars["UserIsAdmin"] = RCCollaborationAdmin.hasRights(user = self._user) or RCCollaborationPluginAdmin.hasRights(user = self._user, plugins = self._tabPlugins)
singleBookingForms = {}
multipleBookingForms = {}
JSCodes = {}
canBeNotified = {}
for plugin in singleBookingPlugins:
pluginName = plugin.getName()
templateClass = CollaborationTools.getTemplateClass(pluginName, "WNewBookingForm")
singleBookingForms[pluginName] = templateClass(self._conf, pluginName, self._user).getHTML()
for plugin in multipleBookingPlugins:
pluginName = plugin.getName()
templateClass = CollaborationTools.getTemplateClass(pluginName, "WNewBookingForm")
multipleBookingForms[pluginName] = templateClass(self._conf, pluginName, self._user).getHTML()
for plugin in plugins:
pluginName = plugin.getName()
templateClass = CollaborationTools.getTemplateClass(pluginName, "WMain")
JSCodes[pluginName] = templateClass(pluginName, self._conf).getHTML()
bookingClass = CollaborationTools.getCSBookingClass(pluginName)
canBeNotified[pluginName] = bookingClass._canBeNotifiedOfEventDateChanges
vars["SingleBookingForms"] = singleBookingForms
vars["MultipleBookingForms"] = multipleBookingForms
vars["JSCodes"] = JSCodes
vars["CanBeNotified"] = canBeNotified
return vars
示例2: _getAnswer
def _getAnswer( self):
if self._info == None:
return UserGetPersonalInfo(self._params, self._aw.getIP(), self._aw.getSession()).process()
pInfo = self._target.getPersonalInfo()
DictPickler.update(pInfo, self._info)
return DictPickler.pickle(pInfo)
示例3: _getAnswer
def _getAnswer(self):
"""
Updates the material with the new properties
"""
self.changeUserList(self._material, self._newUserList)
DictPickler.update(self._material, self._newProperties)
return DictPickler.pickle(self._material)
示例4: __addPresenters
def __addPresenters(self, subcontrib):
# add each presenter
for presenterValues in self._presenters:
# magically update a new ContributionParticipation with JSON data, using the DictPickler
presenter = conference.SubContribParticipation()
DictPickler.update(presenter, presenterValues)
subcontrib.newSpeaker(presenter)
示例5: _getAnswer
def _getAnswer(self):
results = search.searchPeople(surName = self._params.get("surName", ""),
name = self._params.get("name", ""),
organisation = self._params.get("organisation", ""),
email = self._params.get("email", ""),
group = self._params.get("group", ""),
conferenceId = self._params.get("conferenceId", None),
exactMatch = self._params.get("exactMatch", False),
searchExt = self._params.get("searchExt", False))
results["people"] = sorted([DictPickler.pickle(human) for human in results.get("people", [])], cmp=SearchUsersGroups._cmpUsers)
results["groups"] = sorted([DictPickler.pickle(group) for group in results.get("groups", [])], cmp=SearchUsersGroups._cmpGroups)
return results
示例6: _getAnswer
def _getAnswer( self ):
""" Calls _handleGet() or _handleSet() on the derived classes, in order to make it happen. Provides
them with self._value.
When calling _handleGet(), it will return the value to return.
When calling _handleSet(), it will return:
-either self._value if there were no problems
-either a FieldModificationWarning object (pickled) if there are warnings to give to the user
"""
# fetch the 'value' parameter (default for text)
if self._params.has_key('value'):
self._value = self._params['value']
else:
# None if not passed
self._value = None
if self._value == None:
return self._handleGet()
else:
setResult = self._handleSet()
if isinstance(setResult, Warning):
return DictPickler.pickle(ResultWithWarning(self._value, setResult))
else:
return self._value
示例7: _getResult
def _getResult(self, module):
if module.hasObject(self._obj):
raise ServiceError("ERR-O3", "Object is already in the list!")
module.addObject(self._obj, self._objWeight, datetime.timedelta(days=self._objDelta))
return DictPickler.pickle(module.getObjectList()[-1])
示例8: _handleGet
def _handleGet(self):
contributions = self._conf.getContributionList()
filter = {}
# filtering if the active user is a referee: he can only see his own contribs
isOnlyReferee = (
RCReferee.hasRights(self)
and not RCPaperReviewManager.hasRights(self)
and not self._conf.canModify(self.getAW())
)
if isOnlyReferee:
filter["referee"] = self._getUser()
elif self._showWithReferee:
filter["referee"] = "any"
else:
filter["referee"] = None
if self._showWithEditor:
filter["editor"] = "any"
else:
filter["editor"] = None
if self._showWithReviewer:
filter["reviewer"] = "any"
else:
filter["reviewer"] = None
# note by David: I added "if self._selTypes..." and the other ifs after this line,
# in order to make the recording request load contributions work
# but, it may break the paper reviewing module -> assign contributions filter
if self._selTypes:
filter["type"] = self._selTypes
if self._selTracks:
filter["track"] = self._selTracks
if self._selSessions:
filter["session"] = self._selSessions
if self._poster:
filter["poster"] = self._poster
filterCrit = ContributionsReviewingFilterCrit(self._conf, filter)
sortingCrit = contribFilters.SortingCriteria(["number"])
if self._selTypes:
filterCrit.getField("type").setShowNoValue(self._typeShowNoValue)
if self._selTracks:
filterCrit.getField("track").setShowNoValue(self._trackShowNoValue)
if self._selSessions:
filterCrit.getField("session").setShowNoValue(self._sessionShowNoValue)
if self._poster:
filterCrit.getField("poster").setShowNoValue(self._posterShowNoValue)
filterCrit.getField("referee").setShowNoValue(not isOnlyReferee)
f = filters.SimpleFilter(filterCrit, sortingCrit)
contributions = f.apply(contributions)
return DictPickler.pickle(contributions)
示例9: getBookings
def getBookings(self, indexName, viewBy, orderBy, minKey, maxKey,
tz = 'UTC', onlyPending = False, conferenceId = None, categoryId = None,
pickle = False, dateFormat = None, page = None, resultsPerPage = None):
if onlyPending:
indexName += "_pending"
reverse = orderBy == "descending"
try:
index = self.getIndex(indexName)
totalInIndex = index.getCount()
if categoryId and not CategoryManager().hasKey(categoryId) or conferenceId and not ConferenceHolder().hasKey(conferenceId):
finalResult = QueryResult([], 0, 0, totalInIndex, 0)
else:
if viewBy == "conferenceTitle":
items, nBookings = index.getBookingsByConfTitle(minKey, maxKey, conferenceId, categoryId)
elif viewBy == "conferenceStartDate":
items, nBookings = index.getBookingsByConfDate(minKey, maxKey, conferenceId, categoryId)
else:
items, nBookings = index.getBookingsByDate(viewBy, minKey, maxKey, tz, conferenceId, categoryId, dateFormat)
if reverse:
items.reverse()
nGroups = len(items)
if page:
page = int(page)
if resultsPerPage:
resultsPerPage = int(resultsPerPage)
else:
resultsPerPage = 10
nPages = nGroups / resultsPerPage
if nGroups % resultsPerPage > 0:
nPages = nPages + 1
if page > nPages:
finalResult = QueryResult([], 0, 0, totalInIndex, nPages)
else:
finalResult = QueryResult(items[(page - 1) * resultsPerPage : page * resultsPerPage], nBookings, nGroups, totalInIndex, nPages)
else:
finalResult = QueryResult(items, nBookings, nGroups, totalInIndex, 0)
except KeyError:
Logger.get("VideoServ").warning("Tried to retrieve index with name " + indexName + " but the index did not exist. Maybe no bookings have been added to it yet")
finalResult = QueryResult([], 0, 0, 0)
if pickle:
return DictPickler.pickle(finalResult, tz)
else:
return finalResult
示例10: _getAnswer
def _getAnswer(self):
newsModule=ModulesHolder().getById("news")
item=newsModule.getNewsItemById(self._id)
if item:
item.setTitle(self._title)
item.setType(self._type)
item.setContent(self._content)
tz = self.getAW().getUser().getTimezone() #this is an admin service so user is always logged in (or _checkProtection detects it before)
return DictPickler.pickle(item, tz)
else:
raise Exception("News item does not exist")
示例11: _getAnswer
def _getAnswer(self):
return DictPickler.pickle(
self._CSBookingManager.createTestBooking(bookingParams=self._bookingParams),
timezone=self._conf.getTimezone(),
)
示例12: RequestError
raise RequestError("ERR-R3", "Error parsing json request.", e)
if "id" in requestBody:
responseBody["id"] = requestBody["id"]
result = invokeMethod(str(requestBody["method"]), requestBody.get("params", []), req)
# serialize result
try:
responseBody["result"] = result
except Exception, e:
raise ProcessError("ERR-P1", "Error during serialization.")
except CausedError, e:
errorInfo = DictPickler.pickle(e);
if isinstance(e, NoReportError):
# NoReport errors (i.e. not logged in) shouldn't be logged
pass
else:
Logger.get('rpc').exception('Service request failed. Request text:\r\n%s\r\n\r\n' % str(requestText))
if requestBody:
errorInfo["requestInfo"] = {"method": str(requestBody["method"]),
"params": requestBody.get("params", [])}
Logger.get('rpc').debug('Arguments: %s' % errorInfo['requestInfo'])
responseBody["error"] = errorInfo
示例13: _process
def _process(self, rh, params):
# We will need to pickle the data back into JSON
from MaKaC.common.PickleJar import DictPickler
errorList=[]
user = rh.getAW().getUser()
try:
owner = self._target
title = owner.getTitle()
if type(owner) == Conference:
ownerType = "event"
elif type(owner) == Session:
ownerType = "session"
elif type(owner) == Contribution:
ownerType = "contribution"
elif type(owner) == SubContribution:
ownerType = "subcontribution"
else:
ownerType = ""
text = " in %s %s" % (ownerType,title)
except:
owner = None
text = ""
errorList=self._getErrorList()
file = self._file
link = self._link
resource = None
if self._uploadType == "file":
if len(errorList)==0:
mat = self._getMaterial()
if mat == None:
errorList.append("Unknown material");
else:
resource = LocalFile()
resource.setFileName(file["fileName"])
resource.setName(resource.getFileName())
resource.setFilePath(file["filePath"])
resource.setDescription(self._description)
mat.addResource(resource)
#apply conversion
if self._topdf and fileConverter.CDSConvFileConverter.hasAvailableConversionsFor(os.path.splitext(resource.getFileName())[1].strip().lower()):
fileConverter.CDSConvFileConverter.convert(resource.getFilePath(), "pdf", mat)
if not type(self._target) is Category:
self._target.getConference().getLogHandler().logAction({"subject":"Added file %s%s" % (file["fileName"],text)},"Files",user)
# in case of db conflict we do not want to send the file to conversion again
self._topdf = False
if len(errorList) > 0:
status = "ERROR"
info = errorList
else:
status = "OK"
info = DictPickler.pickle(resource)
info['material'] = mat.getId();
elif self._uploadType == "link":
if len(errorList)==0:
mat = self._getMaterial()
if mat == None:
mat = Material()
mat.setTitle(link["matType"])
self._target.addMaterial( mat )
resource = Link()
resource.setURL(link["url"])
resource.setName(resource.getURL())
resource.setDescription(self._description)
mat.addResource(resource)
if not type(self._target) is Category:
self._target.getConference().getLogHandler().logAction({"subject":"Added link %s%s" % (resource.getURL(),text)},"Files",user)
status = "OK"
info = DictPickler.pickle(resource)
info['material'] = mat.getId();
else:
status = "ERROR"
info = errorList
else:
status = "ERROR"
info = "Unknown upload type"
# hackish, because of mime types. Konqueror, for instance, would assume text if there were no tags,
# and would try to open it
from MaKaC.services.interface.rpc import json
return "<html><head></head><body>"+json.encode({'status': status, 'info': info})+"</body></html>"