SQLObject 3.9.1

2021-02-27 Thread Oleg Broytman
Hello!

I'm pleased to announce version 3.9.1, the first minor feature release
of branch 3.9 of SQLObject.


What's new in SQLObject
===

Drivers
---

* Adapt to the latest ``pg8000``.

* Protect ``getuser()`` - it can raise ``ImportError`` on w32
  due to absent of ``pwd`` module.

Build
-

* Change URLs for ``oursql`` in ``extras_require`` in ``setup.py``.
  Provide separate URLs for Python 2.7 and 3.4+.

* Add ``mariadb`` in ``extras_require`` in ``setup.py``.

CI
--

* For tests with Python 3.4 run ``tox`` under Python 3.5.

Tests
-

* Refactor ``tox.ini``.

For a more complete list, please see the news:
http://sqlobject.org/News.html


What is SQLObject
=

SQLObject is an object-relational mapper.  Your database tables are described
as classes, and rows are instances of those classes.  SQLObject is meant to be
easy to use and quick to get started with.

SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite;
connections to other backends - Firebird, Sybase, MSSQL
and MaxDB (also known as SAPDB) - are lesser debugged).

Python 2.7 or 3.4+ is required.


Where is SQLObject
==

Site:
http://sqlobject.org

Development:
http://sqlobject.org/devel/

Mailing list:
https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss

Download:
https://pypi.org/project/SQLObject/3.9.1

News and changes:
http://sqlobject.org/News.html

StackOverflow:
https://stackoverflow.com/questions/tagged/sqlobject


Example
===

Create a simple class that wraps a table::

  >>> from sqlobject import *
  >>>
  >>> sqlhub.processConnection = connectionForURI('sqlite:/:memory:')
  >>>
  >>> class Person(SQLObject):
  ... fname = StringCol()
  ... mi = StringCol(length=1, default=None)
  ... lname = StringCol()
  ...
  >>> Person.createTable()

Use the object::

  >>> p = Person(fname="John", lname="Doe")
  >>> p
  
  >>> p.fname
  'John'
  >>> p.mi = 'Q'
  >>> p2 = Person.get(1)
  >>> p2
  
  >>> p is p2
  True

Queries::

  >>> p3 = Person.selectBy(lname="Doe")[0]
  >>> p3
  
  >>> pc = Person.select(Person.q.lname=="Doe").count()
  >>> pc
  1

Oleg.
-- 
Oleg Broytmanhttps://phdru.name/[email protected]
   Programmers don't die, they just GOSUB without RETURN.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Tkinter needed as a legacy version 2.7 imports the module...

2021-02-27 Thread Alan Gauld via Python-list
On 26/02/2021 22:23, Kevin M. Wilson via Python-list wrote:
> Hey Community,    Is there a site where I might/can download a version of 
> Tkinter for Python 2.7?

Which OS?

If it's Linux you may need to fetch the tkinter
package for your distro.

In Windoze it should come as standard

In MacOS (or any other OS) ... Ask someone who knows...


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


-- 
https://mail.python.org/mailman/listinfo/python-list


Not able to use python properly

2021-02-27 Thread Sahaj Verma
    

   I am not able to install and use pip .

   I have installed python 3.9.2 version on my laptop but I am unable to use
   pip function.

   Kindly look into this matter as soon as possible.

   Thanking You.

   Sahaj Verma

    

   Sent from [1]Mail for Windows 10

    

References

   Visible links
   1. https://go.microsoft.com/fwlink/?LinkId=550986
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Tkinter needed as a legacy version 2.7 imports the module...

2021-02-27 Thread Grant Edwards
On 2021-02-26, MRAB  wrote:
> On 2021-02-26 22:23, Kevin M. Wilson via Python-list wrote:
>
>> Is there a site where I might/can download a version of Tkinter for Python 
>> 2.7?
>
> Tkinter as already included in Python 2.7.

Not always, it depends on how he installed Python 2.7.  That said,
MRAB is right that you don't install Tkinter seperately. You

 1. Include it when you configure and build python

 2. Install a binary Python distribution that aleady includes it.

--
Grant




-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Not able to use python properly

2021-02-27 Thread Peter Pearson
On Sat, 27 Feb 2021 17:45:42 -0500, Sahaj Verma  wrote:
> 
>
>I am not able to install and use pip .
>
>I have installed python 3.9.2 version on my laptop but I am unable to use
>pip function.
>
>Kindly look into this matter as soon as possible.
>
>Thanking You.
>
>Sahaj Verma
>
> 
>
>Sent from [1]Mail for Windows 10
>
> 
>
> References
>
>Visible links
>1. https://go.microsoft.com/fwlink/?LinkId=550986

Your chances of getting useful help will be much improved
if you provide more information.  "I am unable to use
pip function" could result from many varied causes.  Is
your screen completely black?


-- 
To email me, substitute nowhere->runbox, invalid->com.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Not able to use python properly

2021-02-27 Thread Mats Wichmann

On 2/27/21 3:45 PM, Sahaj Verma wrote:
 


I am not able to install and use pip .

I have installed python 3.9.2 version on my laptop but I am unable to use
pip function.

Kindly look into this matter as soon as possible.

Thanking You.

Sahaj Verma

 


Sent from [1]Mail for Windows 10



You're on windows. pip isn't in your path - it's in the Scripts 
subdirectory of the main python installation location.


You can add this to the path, but it's probably more reliable to use it 
as a module instead.  If you have the Python Launcher installed (that's 
recommended for the python.org installation):


py -m pip list

(for example - to show already-installed packages).


--
https://mail.python.org/mailman/listinfo/python-list


Re: Where is the problem?

2021-02-27 Thread RD
In article , [email protected] says...
 
[snip]

>   I have a couple of postscript saving examples
>   that include the following geometry parameters
>   which produce  .ps  files that render the same
>   as the canvas drawings when viewed in ghostsript.

> retval = canvas.postscript( 
>file   = "image/ps/xyzzy.ps , 
>height = 400 , 
>width  = 400 ,
>pagewidth  = 400 , 
>pageheight = 400 ,  
>colormode = "color" )
 
[snip]

Wow! It worked! Thankyouthankyouthankyou.

RD
-- 
https://mail.python.org/mailman/listinfo/python-list


Fwd: How to cycle through servers on Connection Fail in an IRC client?

2021-02-27 Thread inhahe
I'm not sure if it's okay to ask about Twisted in this mailing list, but
Twisted's mailing list seems to have ignored my submission for some reason.
And their mailing list seems mostly dead anyway. So here goes:

I'm making an IRC client  using Twisted, and I want to connect to a
different server when connection fails, but I haven't been able to figure
out how to do that..

Here's a more or less minimal code sample reflecting what I have now:



from twisted.words.protocols import irc
from twisted.internet import protocol
from twisted.internet import reactor

class ServerConnection(irc.IRCClient):

  def __init__(self):
self.signedon = False
self.nickindex = 0

  def signedOn(self):
print("signed on")

  def nickChanged(self, newnick):
self.nickname = newnick

class Network(object):
  def __init__(self, servers, mynick=None):
self.servers = servers
self.mynick = mynick
self.serverindex = 0

class ServerFactory(protocol.ReconnectingClientFactory):
  def __init__(self, nickname="qttwirc", password=None, username="qttwirc",
realname=None, network=None):
self.network = network
self.network.mynick = nickname
self.nickname = nickname
self.username = username
self.password = password
self.realname = realname
protocol.ReconnectingClientFactory.initialDelay = 10 #should i leave
this at 1?
protocol.ReconnectingClientFactory.maxDelay = 10 #no idea what value
this should be. 3.5 wasn't slow enough, i was being throttled.

  def buildProtocol(self, addr):
p = ServerConnection()
self.serverconnection = p
p.server = self
p.nickname = self.nickname
p.username = self.username
self.resetDelay()
return p

  def clientConnectionLost(self, connector, reason):
self.serverconnection = None
protocol.ReconnectingClientFactory.clientConnectionLost(self,
connector, reason)

  def clientConnectionFailed(self, connector, reason):
self.serverconnection = None
addr, port = self.network.servers[self.network.serverindex]
self.network.serverindex = (self.network.serverindex+1) %
len(self.network.servers) #todo: make it actually use these values

#reactor.callLater(config.reconnectdelay, reactor.connectTCP,
addr.encode("ascii"), port, self)
#reactor.connectTCP(addr, port, self) #is this feasible? i don't know a
better way to do this. connector.connect() apparently doesn't take
server/port as arguments.

protocol.ReconnectingClientFactory.clientConnectionFailed(self,
connector, reason)

network = Network([("hitchcock.freenode.net", 6667), ("verne.freenode.net",
6667)])
server = ServerFactory(nickname="test123", username="test123",
network=network)
reactor.connectTCP(*network.servers[network.serverindex], server)
reactor.run()



If I have to completely change the structure of how I connect, that's
fine.. I don't understand Twisted very well, so I'm not aware of what some
other options are for how to make an IRC client.

(It probably doesn't matter, but in my actual program I'm using both
Twisted and PyQt5 in the same run loop using qt5reactor..)

Thanks.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Where is the problem?

2021-02-27 Thread Cousin Stanley
RD wrote:

> In article , [email protected] says...
>  
> [snip]
> 
>>   I have a couple of postscript saving examples
>>   that include the following geometry parameters
>>   which produce  .ps  files that render the same
>>   as the canvas drawings when viewed in ghostsript.
> 
>> retval = canvas.postscript(
>>file   = "image/ps/xyzzy.ps ,
>>height = 400 ,
>>width  = 400 ,
>>pagewidth  = 400 ,
>>pageheight = 400 ,
>>colormode = "color" )
>  
> [snip]
> 
> Wow! It worked! Thankyouthankyouthankyou.
> 
> RD

  You're welcome  
  You're Welcome  
  You're Welcome 
  

-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

-- 
https://mail.python.org/mailman/listinfo/python-list


weirdness with list()

2021-02-27 Thread Cameron Simpson
I just ran into a surprising (to me) issue with list() on an iterable 
object.

My object represents an MDAT box in an MP4 file: it is the ludicrously 
large data box containing the raw audiovideo data; for a TV episode it 
is often about 2GB and a movie is often 4GB to 6GB. For obvious reasons, 
I do not always want to load that into memory, or even read the data 
part at all when scanning an MP4 file, for example to recite its 
metadata.

So my parser has a "skip" mode where it seeks straight past the data, 
but makes a note of its length in bytes. All good.

That length is presented via the object's __len__ method, because I want 
to know that length later and this is a subclass of a suite of things 
which return their length in bytes this way.

So, to my problem:

I've got a walk method which traverses the hierarchy of boxes in the MP4 
file. Until some minutes ago, it looked like this:

  def walk(self):
subboxes = list(self)
yield self, subboxes
for subbox in subboxes:
  if isinstance(subbox, Box):
yield from subbox.walk()

somewhat like os.walk does for a file tree.

I noticed that it was stalling, and investigation revealed it was 
stalling at this line:

subboxes = list(self)

when doing the MDAT box. That box (a) has no subboxes at all and (b) has 
a very large __len__ value.

BUT... It also has a __iter__ value, which like any Box iterates over 
the subboxes. For MDAT that is implemented like this:

def __iter__(self):
yield from ()

What I was expecting was pretty much instant construction of an empty 
list. What I was getting was a very time consuming (10 seconds or more) 
construction of an empty list.

I believe that this is because list() tries to preallocate storage. I 
_infer_ from the docs that this is done maybe using 
operator.length_hint, which in turn consults "the actual length of the 
object" (meaning __len__ for me?), then __length_hint__, then defaults 
to 0.

I've changed my walk function like so:

  def walk(self):
subboxes = []
for subbox in self:
  subboxes.append(subbox)
##subboxes = list(self)

and commented out the former list(self) incantation. This is very fast, 
because it makes an empty list and then appends nothing to it. And for 
your typical movie file this is fine, because there are never _very_ 
many immediate subboxes anyway.

But is there a cleaner way to do this?

I'd like to go back to my former list(self) incantation, and modify the 
MDAT box class to arrange something efficient. Setting __length_hint__ 
didn't help: returning NotImplemeneted or 0 had no effect, because 
presumably __len__ was consulted first.

Any suggestions? My current approach feels rather hacky.

I'm already leaning towards making __len__ return the number of subboxes 
to match the iterator, especially as on reflection not all my subclasses 
are consistent about __len__ meaning the length of their binary form; 
I'm probably going to have to fix that - some subclasses are actually 
namedtuples where __len__ would be the field count. Ugh.

Still, thoughts? I'm interested in any approaches that would have let me 
make list() fast while keeping __len__==binary_length.

I'm accepting that __len__ != len(__iter__) is a bad idea now, though.

Cheers,
Cameron Simpson 
-- 
https://mail.python.org/mailman/listinfo/python-list