check_key
John.H
xiaocong.hust at gmail.com
Wed Aug 29 14:53:50 UTC 2007
when you set a key,for example key is 'key1'
you will send a command 'set key1 0 0 1' to the server and server will use
space as separator,
if your key is 'key 1',
the command will be 'set key 1 0 0 1',
that would cause an error
2007/8/29, jacques.ales at bnpparibas.com <jacques.ales at bnpparibas.com>:
>
>
> I don't understand why space is considered as a control char,
> while and del is not considered so.
>
>
>
>
>
> *I*nternet
> philipn at gmail.com@lists.danga.com - 08/28/2007 06:13 PM
>
>
> Sent by: memcached-bounces at lists.danga.com
>
> To: memcached
>
> cc:
>
> Subject: *Re: check_key*
>
>
> >>> c = 'hi there'
> >>> space = c[2]
> >>> ord(space)
> 32
>
> The memcached protocol spec says no control chars. ord(c) < 33 does that.
>
> That is the latest version of the client. You can grab new releases
> here: http://www.tummy.com/Community/software/python-memcached/
>
> --Philip Neustrom
>
> On 8/28/07, jacques.ales at bnpparibas.com <jacques.ales at bnpparibas.com>
> wrote:
> >
> > hello
> >
> > I'm using the python wrapper for memcached in it's version
> > __author__ = "Evan Martin <martine at danga.com>"
> > __version__ = "1.36"
> > __copyright__ = "Copyright (C) 2003 Danga Interactive"
> > __license__ = "Python"
> >
> > I can't figure out if this is the latest since the verion available in
> the
> > svn repository is
> > http://code.sixapart.com/svn/memcached/trunk/api/python/memcache.py
> > __author__ = "Evan Martin <martine at danga.com>"
> > __version__ = "1.2"
> > __copyright__ = "Copyright (C) 2003 Danga Interactive"
> > __license__ = "Python"
> >
> >
> > anyway, my concern is that version 1.36 checks key validity with the
> > followinf function, that excludes spaces char (ascii32)
> > as being 'control characters'.
> >
> > I was wondering is this is correct.
> > and also wondering why other chars as DEL(ascii127) are not excluded
> >
> > thanks for your clues
> >
> > jacques
> >
> >
> >
> > def check_key(key, key_extra_len=0):
> > """Checks sanity of key. Fails if:
> > Key length is > SERVER_MAX_KEY_LENGTH (Raises
> MemcachedKeyLength).
> > Contains control characters (Raises
> MemcachedKeyCharacterError).
> > Is not a string (Raises MemcachedStringEncodingError)
> > """
> > if not isinstance(key, str):
> > raise Client.MemcachedStringEncodingError, ("Keys
> > must be str()'s, not"
> > "unicode. Convert your unicode strings using "
> > "mystring.encode(charset)!")
> >
> > if isinstance(key, basestring):
> > if len(key) + key_extra_len > SERVER_MAX_KEY_LENGTH:
> > raise Client.MemcachedKeyLengthError, ("Key length is > %s"
> > % SERVER_MAX_KEY_LENGTH)
> > for char in key:
> > if ord(char) < 33:
> > raise Client.MemcachedKeyCharacterError,
> > "Control characters not allowed"
> >
> >
> >
> >
> >
> >
> > This message and any attachments (the "message") is intended solely for
> the
> > addressees and is confidential.
> > If you receive this message in error, please delete it and immediately
> > notify the sender. Any use not in accord with
> > its purpose, any dissemination or disclosure, either whole or partial,
> is
> > prohibited except formal approval.
> > The internet can not guarantee the integrity of this message.
> > BNP PARIBAS (and its subsidiaries) shall (will) not therefore be liable
> for
> > the message if modified.
> > Do not print this message unless it is necessary, consider the
> environment.
> > ---------------------------------------------
> > Ce message et toutes les pieces jointes (ci-apres le "message") sont
> etablis
> > a l'intention exclusive de ses destinataires et sont confidentiels. Si
> vous
> > recevez ce
> > message par erreur, merci de le detruire et d'en avertir immediatement
> > l'expediteur.
> > Toute utilisation de ce message non conforme a sa destination, toute
> > diffusion ou toute publication, totale ou partielle, est interdite, sauf
> > autorisation expresse.
> > L'internet ne permettant pas d'assurer l'integrite de ce message, BNP
> > PARIBAS (et ses filiales) decline(nt) toute responsabilite au titre de
> ce
> > message, dans l'hypothese ou il aurait ete modifie.
> > N'imprimez ce message que si necessaire, pensez a l'environnement.
> >
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.danga.com/pipermail/memcached/attachments/20070829/dfca1840/attachment.html
More information about the memcached
mailing list