|
From: Mikel L. <mla...@co...> - 2005-03-30 15:08:40
|
Peter Valckx wrote:
> Hi everybody,
>
> We use Openflow as a product in our own product. To delete an
> application, we use the function openflow.deleteApplication. The
> function doesn't work 100%. When we create an application with name
> 'test and we want to delete it, nothing happends... When we use 'x'
> everything works fine.. What's the problem? That we add an activity,
> using name and that the removal goes with the ID? Help...
Hi Peter:
If we look at addApplication method in openflow.py, we'll find that the
application name is used as its 'id' (if we can say so) and add to the
dictionary at ._applications to store it.
Looking at deleteApplication, we can see that the parameter indicating
the application to delete must be a list because deleteApplication
iterates over the parameter to delete an existing application:
def deleteApplication(self, app_ids=None, REQUEST=None):
""" removes an application """
for name in app_ids:
if name in self._applications.keys():
del(self._applications[name])
If you use 'x' as application name, when you are going to delete it, the
delete method makes: for name in 'x': .... and name takes the value 'x'
and the application is deleted succesfully.
Nevertheless, when your application's name is 'test', deleteApplication
executes: for name in 'test' and it tries to delete application 't',
then application 'e', later application 's' and at last application 't'.
That happens because python strings can be used as lists of characters.
So, try calling deleteApplication, with the application id to delete in
a list, for example: deleteApplication(['test'])
Regards,
--
Mikel Larreategi
mla...@co...
CodeSyntax
Azitaingo Industrialdea 3 K
E-20600 Eibar
Tel: (+34) 943 82 17 80
|