[Stoq-devel] [Bug 2715] - Remove station_id from stoq.conf

bugzilla-daemon at async.com.br bugzilla-daemon at async.com.br
Mon Jul 31 16:24:04 BRT 2006


http://bugs.async.com.br/show_bug.cgi?id=2715  


Henrique Romano <henrique at async.com.br> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Attachment #3372|review?(henrique at async.com.b|review+
               Flag|r)                          |




--- Comment #2 from Henrique Romano <henrique at async.com.br>  2006-07-31 16:24 BRT ---
(From update of attachment 3372)
>Index: stoqlib/stoqlib/domain/station.py
>===================================================================

>@@ -77,3 +81,34 @@
>         return u"%05d" % self.identifier
> 
> 
>+def create_station(conn, branch=None):
>+    """
>+    Create a new station id for the current machine.
>+    Optionally a branch can be specified which will be set as the branch
>+    for created station.
>+
>+    @param conn: a database connection
>+    @param branch: Branch
>+    @returns: the name of the created station
>+    @rtype: string
>+    """
>+    from stoqlib.domain.person import PersonAdaptToBranch as Branch

Don't import adapters directly, use getAdapterClass instead -- or, if you like,
use the "interface" methods (eg: iget, iselect, ...) on the Person table.

>+
>+    branches = Branch.select(connection=conn)
>+    if branches.count() == 1:
>+        branch = branches[0]
>+    else:
>+        raise SystemExit("More than one branch detected")

I don't like this "if"... what if we are going to add a station in a "shared"
server (mulitple branches, for example)?

>+
>+    name = socket.gethostname()

I see the socket.gethostname two times in this patch... should we have a
DEFAUT_STATION_NAME constant or it is unneeded? It is always supposed to be the
hostname?


More information about the Stoq-devel mailing list