SF.net SVN: fclient: [65] trunk/fclient/fclient_lib/fcp/fcp2_0.py
Status: Pre-Alpha
Brought to you by:
jurner
From: <jU...@us...> - 2007-11-10 11:28:50
|
Revision: 65 http://fclient.svn.sourceforge.net/fclient/?rev=65&view=rev Author: jUrner Date: 2007-11-10 03:28:52 -0800 (Sat, 10 Nov 2007) Log Message: ----------- request identifiers can now be set explicitely + EventFileInfoProgress has gone + a bit of this and that Modified Paths: -------------- trunk/fclient/fclient_lib/fcp/fcp2_0.py Modified: trunk/fclient/fclient_lib/fcp/fcp2_0.py =================================================================== --- trunk/fclient/fclient_lib/fcp/fcp2_0.py 2007-11-10 11:27:11 UTC (rev 64) +++ trunk/fclient/fclient_lib/fcp/fcp2_0.py 2007-11-10 11:28:52 UTC (rev 65) @@ -167,8 +167,7 @@ 'IdentifierCollision', 'ClientRequestInfo', - 'ClientRequestInfoProgress', - + 'DataFound', 'GetFailed', 'SimpleProgress', @@ -321,6 +320,7 @@ class IdentifierPrefix: """Special purpose identifier prefixes""" + ClientGetFile = 'ClientGetFile::' ClientRequestInfo = 'ClientRequestInfo::' class InsertError(Exception): @@ -919,10 +919,7 @@ return True elif msg.name == self.Message.SimpleProgress: - if msg['Identifier'].startswith(self.IdentifierPrefix.ClientRequestInfo): - self.events.ClientRequestInfoProgress(msg.params) - else: - self.events.SimpleProgress(msg.params) + self.events.SimpleProgress(msg.params) return True elif msg.name == self.Message.IdentifierCollision: @@ -1192,10 +1189,13 @@ ## ########################################################## #TODO: not complete yet - def clientGetFile(self, uri, filename): + def clientGetFile(self, uri, filename, identifier=None): """ """ - identifier = self.new_identifier() + if identifier is None: + identifier = self.IdentifierPrefix.ClientGetFile + self.newIdentifier() + else: + assert identifier.startswith(self.IdentifierPrefix.ClientGetFile), 'Wrong prefix' msg = self.Message( self.Message.ClientGet, IgnoreDS='false', @@ -1219,20 +1219,29 @@ return identifier - def clientRequestInfo(self, uri, **params): + def clientRequestInfo(self, uri, identifier=None, **params): """Requests info about a file @param uri: uri of the file to request info about + @param identifier: request identifier or None to let the method create one. If an identifier is passed, it has to be + be prefixed with L{IdentifierPrefix.ClientRequestInfo} @event: clientGetInfo(event, params). If success, params will contain a key 'Metadata.ContentType' and 'DataLength'. Both may be '' (empty string) @event: GetInfoProgress(event, params). Triggered instead ofSimpleProgress @note: for other events see: L{clientGet} @return: (str) request identifier + @note: the request identifier returned is very likely to be unique but uniqueness is not guaranteed """ - identifier = self.IdentifierPrefix.ClientRequestInfo + self.newIdentifier() + if identifier is None: + identifier = self.IdentifierPrefix.ClientRequestInfo + self.newIdentifier() + else: + assert identifier.startswith(self.IdentifierPrefix.ClientRequestInfo), 'Wrong prefix' self.sendMessage( self.Message.ClientGet, Identifier=identifier, URI=uri, + #TODO: persistance??? + #Persistence='forever', + # suggested by Mathew Toseland to use about 32k for mimeType requests # basic sizes of keys are: 1k for SSks and 32k for CHKs MaxSize='32000', This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |