Create a .lua fle from Python

2015-09-29 Thread Ariel Argañaraz
Hi,
This is my first post, I would like to know if a library that can help me
with this.


I want to parse a XML fle with Python and save the data into a Lua table
called for example "newTable", then I want to create a "table.lua" fle with
the "newTable" write on it.


for example:

the XML fle: cities.xml


 
  BuenosAires
  30
  

  Seatle
  25




And  I want to create a cities_temp.lua file

cities_temps ={
["Buenos Aires"] = 30,
["Seatle"] = 25,
}


Is that posible to do with LUPA (https://pypi.python.org/pypi/lupa)?? In
the docs I read that you can create lua tables but I did not see if there
is a way to create a .lua file with that table.


I could do it with python writing to a file line per line but i want some
more elegant.

Can anyone give some help?

Thanks.

-- 
Ariel Argañaraz
-- 
https://mail.python.org/mailman/listinfo/python-list


Problems with ZODB, I can not persist and object accessed from 2 threads

2014-04-29 Thread Ariel Argañaraz
Hello, I am sorry I am stuck in this. And I need some help

I want to persist an Object with ZODB, the object can be accessed from 2
different threads. The ZODB manual says:

A multi-threaded program should open a separate Connection instance for
each thread. Different threads can then modify objects and commit their
modifications independently.

But there isn't an example of how to create a connection for each thread.
Can someone tell me how to connect to the same DB from 2 threads??

I attached an example of what I am trying to do.

And I get this error.

Traceback (most recent call last):
 File /usr/lib/python2.7/threading.py, line 810, in __bootstrap_inner
   self.run()
 File /usr/lib/python2.7/threading.py, line 763, in run
   self.__target(*self.__args, **self.__kwargs)
 File main.py, line 33, in thread_1
   storage = FileStorage(/tmp/asdasd.fs)
 File /usr/lib/python2.7/site-packages/ZODB/FileStorage/FileStorage.py,
line 164, in *_init_*
   self._lock_file = LockFile(file_name + '.lock')
 File /usr/lib/python2.7/site-packages/zc/lockfile/__init__.py, line 84,
in *_init_*
   _lock_file(fp)
 File /usr/lib/python2.7/site-packages/zc/lockfile/__init__.py, line 59,
in _lock_file
   raise LockError(Couldn't lock %r % file.name)
LockError: Couldn't lock '/tmp/asdasd.fs.lock'


IF I don't connect in the thread_1 class I can change things but
sometimes the changes from the main thread are not commited.

When I debug, I can see that when a change is made from the Second thread,
the transaction_manager creates a new Transaction here:

#manager.py
def get(self):
 See ITransactionManager.

if self._txn is None:
self._txn = Transaction(self._synchs, self)
return self._txn

When it happens that commit Seems to be executed succesfully but it doest
save the changes to the DB.

-- 
Ariel Argañaraz


main.py
Description: application/download


objects.py
Description: application/download
-- 
https://mail.python.org/mailman/listinfo/python-list


Persist python objects without a relational DB

2014-02-28 Thread Ariel Argañaraz
Hi, I would like to know which is the best framework to persist my python
objects in disk.

I heard about ZODB (http://www.zodb.org/en/latest/index.html)

is this the best or there is another ?



-- 
Ariel Argañaraz
-- 
https://mail.python.org/mailman/listinfo/python-list