community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r894005 [1/2] - in /comdev/nearby_people: ./ data/ docs/ lib/ nearby/ nearby/templatetags/ templates/
Date Sat, 26 Dec 2009 17:10:42 GMT
Author: nick
Date: Sat Dec 26 17:10:41 2009
New Revision: 894005

URL: http://svn.apache.org/viewvc?rev=894005&view=rev
Log:
Copy the 'Find Nearby People' application over from the other ASF repo where it has been since ApacheCon. (Couldn't svn mv as a different repo)

Added:
    comdev/nearby_people/   (with props)
    comdev/nearby_people/__init__.py   (with props)
    comdev/nearby_people/data/   (with props)
    comdev/nearby_people/docs/
    comdev/nearby_people/docs/LICENSE
    comdev/nearby_people/docs/NOTICE
    comdev/nearby_people/lib/   (with props)
    comdev/nearby_people/lib/geo_helper.py   (with props)
    comdev/nearby_people/lib/geoname.py   (with props)
    comdev/nearby_people/lib/timeoutsocket.py   (with props)
    comdev/nearby_people/local_settings.py.example
    comdev/nearby_people/manage.py   (with props)
    comdev/nearby_people/nearby/   (with props)
    comdev/nearby_people/nearby/__init__.py   (with props)
    comdev/nearby_people/nearby/foaf.py   (with props)
    comdev/nearby_people/nearby/forms.py   (with props)
    comdev/nearby_people/nearby/models.py   (with props)
    comdev/nearby_people/nearby/shortcuts.py   (with props)
    comdev/nearby_people/nearby/templatetags/   (with props)
    comdev/nearby_people/nearby/templatetags/__init__.py   (with props)
    comdev/nearby_people/nearby/templatetags/distances.py   (with props)
    comdev/nearby_people/nearby/tests.py   (with props)
    comdev/nearby_people/nearby/views.py   (with props)
    comdev/nearby_people/run.cgi   (with props)
    comdev/nearby_people/settings.py   (with props)
    comdev/nearby_people/templates/   (with props)
    comdev/nearby_people/templates/base.html   (with props)
    comdev/nearby_people/templates/people.html   (with props)
    comdev/nearby_people/templates/pick_place.html   (with props)
    comdev/nearby_people/templates/welcome.html   (with props)
    comdev/nearby_people/urls.py   (with props)

Propchange: comdev/nearby_people/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Dec 26 17:10:41 2009
@@ -0,0 +1,3 @@
+*.swp
+*.pyc
+local_settings.py

Added: comdev/nearby_people/__init__.py
URL: http://svn.apache.org/viewvc/comdev/nearby_people/__init__.py?rev=894005&view=auto
==============================================================================
--- comdev/nearby_people/__init__.py (added)
+++ comdev/nearby_people/__init__.py Sat Dec 26 17:10:41 2009
@@ -0,0 +1,16 @@
+# ====================================================================
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ====================================================================

Propchange: comdev/nearby_people/__init__.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: comdev/nearby_people/data/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Dec 26 17:10:41 2009
@@ -0,0 +1,5 @@
+*.swp
+*.pyc
+data
+project
+people

Added: comdev/nearby_people/docs/LICENSE
URL: http://svn.apache.org/viewvc/comdev/nearby_people/docs/LICENSE?rev=894005&view=auto
==============================================================================
--- comdev/nearby_people/docs/LICENSE (added)
+++ comdev/nearby_people/docs/LICENSE Sat Dec 26 17:10:41 2009
@@ -0,0 +1,507 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+
+APACHE POI SUBCOMPONENTS:
+
+Apache POI includes subcomponents with separate copyright notices and
+license terms. Your use of these subcomponents is subject to the terms
+and conditions of the following licenses:
+
+
+Office Open XML schemas (ooxml-schemas-1.0.jar)
+
+    The Office Open XML schema definitions used by Apache POI are
+    a part of the Office Open XML ECMA Specification (ECMA-376, [1]).
+    As defined in section 9.4 of the ECMA bylaws [2], this specification
+    is available to all interested parties without restriction:
+
+        9.4 All documents when approved shall be made available to
+            all interested parties without restriction.
+
+    Furthermore, both Microsoft and Adobe have granted patent licenses
+    to this work [3,4,5].
+
+    [1] http://www.ecma-international.org/publications/standards/Ecma-376.htm
+    [2] http://www.ecma-international.org/memento/Ecmabylaws.htm
+    [3] http://www.microsoft.com/interop/osp/
+    [4] http://www.ecma-international.org/publications/files/ECMA-ST/Ecma%20PATENT/ECMA-376%20Edition%201%20Microsoft%20Patent%20Declaration.pdf
+    [5] http://www.ecma-international.org/publications/files/ECMA-ST/Ecma%20PATENT/ga-2006-191.pdf
+
+
+DOM4J library (dom4j-1.6.1.jar)
+
+    Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved.
+
+    Redistribution and use of this software and associated documentation
+    ("Software"), with or without modification, are permitted provided
+    that the following conditions are met:
+
+    1. Redistributions of source code must retain copyright
+       statements and notices.  Redistributions must also contain a
+       copy of this document.
+
+    2. Redistributions in binary form must reproduce the
+       above copyright notice, this list of conditions and the
+       following disclaimer in the documentation and/or other
+       materials provided with the distribution.
+
+    3. The name "DOM4J" must not be used to endorse or promote
+       products derived from this Software without prior written
+       permission of MetaStuff, Ltd.  For written permission,
+       please contact dom4j-info@metastuff.com.
+
+    4. Products derived from this Software may not be called "DOM4J"
+       nor may "DOM4J" appear in their names without prior written
+       permission of MetaStuff, Ltd. DOM4J is a registered
+       trademark of MetaStuff, Ltd.
+
+    5. Due credit should be given to the DOM4J Project - 
+       http://www.dom4j.org
+ 
+    THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS
+    ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
+    NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+    FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
+    METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+    STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+    OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+JUnit test library (junit-3.8.1.jar)
+
+    Common Public License - v 1.0
+
+    THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON
+    PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION
+    OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+    1. DEFINITIONS
+
+    "Contribution" means:
+
+    a) in the case of the initial Contributor, the initial code and
+       documentation distributed under this Agreement, and
+
+    b) in the case of each subsequent Contributor:
+
+       i)  changes to the Program, and
+
+       ii) additions to the Program;
+
+       where such changes and/or additions to the Program originate from
+       and are distributed by that particular Contributor. A Contribution
+       'originates' from a Contributor if it was added to the Program by
+       such Contributor itself or anyone acting on such Contributor's behalf.
+       Contributions do not include additions to the Program which: (i) are
+       separate modules of software distributed in conjunction with the
+       Program under their own license agreement, and (ii) are not derivative
+       works of the Program.
+
+    "Contributor" means any person or entity that distributes the Program.
+
+    "Licensed Patents " mean patent claims licensable by a Contributor which
+    are necessarily infringed by the use or sale of its Contribution alone
+    or when combined with the Program.
+
+    "Program" means the Contributions distributed in accordance with this
+    Agreement.
+
+    "Recipient" means anyone who receives the Program under this Agreement,
+    including all Contributors.
+
+    2. GRANT OF RIGHTS
+
+    a) Subject to the terms of this Agreement, each Contributor hereby grants
+       Recipient a non-exclusive, worldwide, royalty-free copyright license
+       to reproduce, prepare derivative works of, publicly display, publicly
+       perform, distribute and sublicense the Contribution of such
+       Contributor, if any, and such derivative works, in source code and
+       object code form.
+
+    b) Subject to the terms of this Agreement, each Contributor hereby grants
+       Recipient a non-exclusive, worldwide, royalty-free patent license under
+       Licensed Patents to make, use, sell, offer to sell, import and
+       otherwise transfer the Contribution of such Contributor, if any, in
+       source code and object code form. This patent license shall apply to
+       the combination of the Contribution and the Program if, at the time
+       the Contribution is added by the Contributor, such addition of the
+       Contribution causes such combination to be covered by the Licensed
+       Patents. The patent license shall not apply to any other combinations
+       which include the Contribution. No hardware per se is licensed
+       hereunder.
+
+    c) Recipient understands that although each Contributor grants the
+       licenses to its Contributions set forth herein, no assurances are
+       provided by any Contributor that the Program does not infringe the
+       patent or other intellectual property rights of any other entity.
+       Each Contributor disclaims any liability to Recipient for claims
+       brought by any other entity based on infringement of intellectual
+       property rights or otherwise. As a condition to exercising the rights
+       and licenses granted hereunder, each Recipient hereby assumes sole
+       responsibility to secure any other intellectual property rights
+       needed, if any. For example, if a third party patent license is
+       required to allow Recipient to distribute the Program, it is
+       Recipient's responsibility to acquire that license before
+       distributing the Program.
+
+    d) Each Contributor represents that to its knowledge it has sufficient
+       copyright rights in its Contribution, if any, to grant the copyright
+       license set forth in this Agreement.
+
+    3. REQUIREMENTS
+
+    A Contributor may choose to distribute the Program in object code form
+    under its own license agreement, provided that:
+
+    a) it complies with the terms and conditions of this Agreement; and
+
+    b) its license agreement:
+
+       i)   effectively disclaims on behalf of all Contributors all warranties
+            and conditions, express and implied, including warranties or
+            conditions of title and non-infringement, and implied warranties
+            or conditions of merchantability and fitness for a particular
+            purpose;
+
+       ii)  effectively excludes on behalf of all Contributors all liability
+            for damages, including direct, indirect, special, incidental and
+            consequential damages, such as lost profits;
+
+       iii) states that any provisions which differ from this Agreement are
+            offered by that Contributor alone and not by any other party; and
+
+       iv)  states that source code for the Program is available from such
+            Contributor, and informs licensees how to obtain it in a
+            reasonable manner on or through a medium customarily used for
+            software exchange.
+
+    When the Program is made available in source code form:
+
+    a) it must be made available under this Agreement; and
+
+    b) a copy of this Agreement must be included with each copy of
+       the Program.
+
+    Contributors may not remove or alter any copyright notices contained
+    within the Program.
+
+    Each Contributor must identify itself as the originator of its
+    Contribution, if any, in a manner that reasonably allows subsequent
+    Recipients to identify the originator of the Contribution.
+
+    4. COMMERCIAL DISTRIBUTION
+
+    Commercial distributors of software may accept certain responsibilities
+    with respect to end users, business partners and the like. While this
+    license is intended to facilitate the commercial use of the Program,
+    the Contributor who includes the Program in a commercial product offering
+    should do so in a manner which does not create potential liability for
+    other Contributors. Therefore, if a Contributor includes the Program
+    in a commercial product offering, such Contributor ("Commercial
+    Contributor") hereby agrees to defend and indemnify every other
+    Contributor ("Indemnified Contributor") against any losses, damages
+    and costs (collectively "Losses") arising from claims, lawsuits and
+    other legal actions brought by a third party against the Indemnified
+    Contributor to the extent caused by the acts or omissions of such
+    Commercial Contributor in connection with its distribution of the
+    Program in a commercial product offering. The obligations in this
+    section do not apply to any claims or Losses relating to any actual
+    or alleged intellectual property infringement. In order to qualify,
+    an Indemnified Contributor must: a) promptly notify the Commercial
+    Contributor in writing of such claim, and b) allow the Commercial
+    Contributor to control, and cooperate with the Commercial Contributor
+    in, the defense and any related settlement negotiations. The Indemnified
+    Contributor may participate in any such claim at its own expense.
+
+    For example, a Contributor might include the Program in a commercial
+    product offering, Product X. That Contributor is then a Commercial
+    Contributor. If that Commercial Contributor then makes performance
+    claims, or offers warranties related to Product X, those performance
+    claims and warranties are such Commercial Contributor's responsibility
+    alone. Under this section, the Commercial Contributor would have to
+    defend claims against the other Contributors related to those
+    performance claims and warranties, and if a court requires any other
+    Contributor to pay any damages as a result, the Commercial Contributor
+    must pay those damages.
+
+    5. NO WARRANTY
+
+    EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED
+    ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER
+    EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR
+    CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR
+    A PARTICULAR PURPOSE. Each Recipient is solely responsible for
+    determining the appropriateness of using and distributing the Program
+    and assumes all risks associated with its exercise of rights under this
+    Agreement, including but not limited to the risks and costs of program
+    errors, compliance with applicable laws, damage to or loss of data,
+    programs or equipment, and unavailability or interruption of operations.
+
+    6. DISCLAIMER OF LIABILITY
+
+    EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR
+    ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
+    INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING
+    WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF
+    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR
+    DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+    HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+    7. GENERAL
+
+    If any provision of this Agreement is invalid or unenforceable under
+    applicable law, it shall not affect the validity or enforceability of
+    the remainder of the terms of this Agreement, and without further
+    action by the parties hereto, such provision shall be reformed to the
+    minimum extent necessary to make such provision valid and enforceable.
+
+    If Recipient institutes patent litigation against a Contributor with
+    respect to a patent applicable to software (including a cross-claim or
+    counterclaim in a lawsuit), then any patent licenses granted by that
+    Contributor to such Recipient under this Agreement shall terminate as of
+    the date such litigation is filed. In addition, if Recipient institutes
+    patent litigation against any entity (including a cross-claim or
+    counterclaim in a lawsuit) alleging that the Program itself (excluding
+    combinations of the Program with other software or hardware) infringes
+    such Recipient's patent(s), then such Recipient's rights granted under
+    Section 2(b) shall terminate as of the date such litigation is filed.
+
+    All Recipient's rights under this Agreement shall terminate if it fails
+    to comply with any of the material terms or conditions of this Agreement
+    and does not cure such failure in a reasonable period of time after
+    becoming aware of such noncompliance. If all Recipient's rights under
+    this Agreement terminate, Recipient agrees to cease use and distribution
+    of the Program as soon as reasonably practicable. However, Recipient's
+    obligations under this Agreement and any licenses granted by Recipient
+    relating to the Program shall continue and survive.
+
+    Everyone is permitted to copy and distribute copies of this Agreement,
+    but in order to avoid inconsistency the Agreement is copyrighted and may
+    only be modified in the following manner. The Agreement Steward reserves
+    the right to publish new versions (including revisions) of this Agreement
+    from time to time. No one other than the Agreement Steward has the right
+    to modify this Agreement. IBM is the initial Agreement Steward. IBM may
+    assign the responsibility to serve as the Agreement Steward to a suitable
+    separate entity. Each new version of the Agreement will be given a
+    distinguishing version number. The Program (including Contributions) may
+    always be distributed subject to the version of the Agreement under which
+    it was received. In addition, after a new version of the Agreement is
+    published, Contributor may elect to distribute the Program (including
+    its Contributions) under the new version. Except as expressly stated in
+    Sections 2(a) and 2(b) above, Recipient receives no rights or licenses
+    to the intellectual property of any Contributor under this Agreement,
+    whether expressly, by implication, estoppel or otherwise. All rights in
+    the Program not expressly granted under this Agreement are reserved.
+
+    This Agreement is governed by the laws of the State of New York and the
+    intellectual property laws of the United States of America. No party to
+    this Agreement will bring a legal action under this Agreement more than
+    one year after the cause of action arose. Each party waives its rights
+    to a jury trial in any resulting litigation.

Added: comdev/nearby_people/docs/NOTICE
URL: http://svn.apache.org/viewvc/comdev/nearby_people/docs/NOTICE?rev=894005&view=auto
==============================================================================
--- comdev/nearby_people/docs/NOTICE (added)
+++ comdev/nearby_people/docs/NOTICE Sat Dec 26 17:10:41 2009
@@ -0,0 +1,21 @@
+Apache Nearby People
+Copyright 2009 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
+
+This product contains the Geoname-Python Library
+ <http://www.zindep.com/blog-zindep/Geoname-python/>
+which is under the Python License
+Copyright (c) 2006 Nicolas Laurance
+
+This product contains the geo_helper Python Library
+ <http://gagravarr.org/code/>
+which has been re-licensed under the Apache Software License
+Copyright (c) 2006-2009 Nick Burch
+
+This product contains parts of Django
+ <http://www.djangoproject.com/>
+which is under the Python License
+Copyright (c) Django Software Foundation

Propchange: comdev/nearby_people/lib/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Dec 26 17:10:41 2009
@@ -0,0 +1,2 @@
+*.swp
+*.pyc

Added: comdev/nearby_people/lib/geo_helper.py
URL: http://svn.apache.org/viewvc/comdev/nearby_people/lib/geo_helper.py?rev=894005&view=auto
==============================================================================
--- comdev/nearby_people/lib/geo_helper.py (added)
+++ comdev/nearby_people/lib/geo_helper.py Sat Dec 26 17:10:41 2009
@@ -0,0 +1,526 @@
+# Geographical helper functions for nmea_info.py and friends
+#
+# Helps with geographic functions, including:
+#  Lat+Long+Height -> XYZ
+#  XYZ -> Lat+Long+Height
+#  Lat+Long -> other Lat+Long (Helmert Transform)
+#  Lat+Long -> easting/northing (OS GB+IE Only)
+#  easting/northing -> Lat+Long (OS GB+IE Only)
+#  OS easting/northing -> OS 6 figure ref
+#
+# See http://gagravarr.org/code/ for updates and information
+#
+# Licensed under the Apache Software License v2
+#      http://www.apache.org/licenses/LICENSE-2.0
+
+import math
+
+# For each co-ordinate system we do, what are the A, B and E2 values?
+# List is A, B, E^2 (E^2 calculated after)
+abe_values = {
+	'wgs84': [ 6378137.0, 6356752.3141, -1 ],
+	'osgb' : [ 6377563.396, 6356256.91, -1 ],
+	'osie' : [ 6377340.189, 6356034.447, -1 ]
+}
+
+# The earth's radius, in meters, as taken from an average of the WGS84
+#  a and b parameters (should be close enough)
+earths_radius = (abe_values['wgs84'][0] + abe_values['wgs84'][1]) / 2.0
+
+# Calculate the E2 values
+for system in abe_values.keys():
+	a = abe_values[system][0]
+	b = abe_values[system][1]
+	e2 = (a*a - b*b) / (a*a)
+	abe_values[system][2] = e2
+
+# For each co-ordinate system we can translate between, what are
+#  the tx, ty, tz, s, rx, ry and rz values?
+# List is tx, ty, tz, s, rx, ry, rz
+transform_values = {
+	'wgs84_to_osgb' : [ -446.448, 125.157, -542.060, 
+							20.4894 / 1000.0 / 1000.0, # given as ppm
+							-0.1502 / 206265.0, # given as seconds of arc
+							-0.2470 / 206265.0, # given as seconds of arc
+							-0.8421 / 206265.0  # given as seconds of arc
+					],
+	'wgs84_to_osie' : [ -482.530, 130.596, -564.557, 
+							-8.1500 / 1000.0 / 1000.0, # given as ppm
+							-1.0420 / 206265.0, # given as seconds of arc
+							-0.2140 / 206265.0, # given as seconds of arc
+							-0.6310 / 206265.0  # given as seconds of arc
+					],
+	'itrs2000_to_etrs89' : [ 0.054, 0.051, -0.048, 0,
+							 0.000081 / 206265.0, # given as seconds of arc
+							 0.00049 / 206265.0, # given as seconds of arc
+							 0.000792 / 206265.0  # given as seconds of arc
+					]
+}
+
+# Calculate reverse transforms
+for systems in [('wgs84','osgb'), ('wgs84','osie'), ('itrs2000','etrs89')]:
+	fs = systems[0] + "_to_" + systems[1]
+	rs = systems[1] + "_to_" + systems[0]
+	ra = []
+	for val in transform_values[fs]:
+		ra.append(-1.0 * val)
+	transform_values[rs] = ra
+
+# Easting and Northin system values, for the systems we work with.
+# List is n0, e0, F0, theta0 and landa0
+en_values = {
+	'osgb' : [ -100000.0, 400000.0, 0.9996012717,
+					49.0 /360.0 *2.0*math.pi,
+					-2.0 /360.0 *2.0*math.pi
+			 ],
+	'osie' : [ 250000.0, 200000.0, 1.000035,
+					53.5 /360.0 *2.0*math.pi,
+					-8.0 /360.0 *2.0*math.pi
+			 ]
+}
+
+# Cassini Projection Origins
+# List is lat (rad), long (rad), false easting, false northing
+cassini_values = {
+	'osgb' : [ (53.0 + (13.0 / 60.0) + (17.274 / 3600.0)) /360.0 *2.0*math.pi,
+	           -(2.0 + (41.0 / 60.0) +  (3.562 / 3600.0)) /360.0 *2.0*math.pi,
+	           0, 0 ]				 
+}
+
+# How many feet to the meter
+feet_per_meter = 1.0 / 0.3048007491   # 3.28083
+
+##############################################################
+#         OS GB Specific Helpers for Generic Methods         #
+##############################################################
+
+def turn_wgs84_into_osgb36(lat_dec,long_dec,height):
+	"""See http://www.gps.gov.uk/guide6.asp#6.2 and http://www.gps.gov.uk/guide6.asp#6.6 for the calculations, and http://www.posc.org/Epicentre.2_2/DataModel/ExamplesofUsage/eu_cs34h.html for some background."""
+
+	wgs84_xyz = turn_llh_into_xyz(lat_dec,long_dec,height,'wgs84')
+
+	osgb_xyz = turn_xyz_into_other_xyz(
+					wgs84_xyz[0],wgs84_xyz[1],wgs84_xyz[2],'wgs84','osgb')
+
+	osgb_latlong = turn_xyz_into_llh(
+					osgb_xyz[0],osgb_xyz[1],osgb_xyz[2],'osgb')
+	return osgb_latlong
+
+def turn_osgb36_into_wgs84(lat_dec,long_dec,height):
+	"""See http://www.gps.gov.uk/guide6.asp#6.2 and http://www.gps.gov.uk/guide6.asp#6.6 for the calculations, and http://www.posc.org/Epicentre.2_2/DataModel/ExamplesofUsage/eu_cs34h.html for some background."""
+
+	osgb_xyz = turn_llh_into_xyz(lat_dec,long_dec,height,'osgb')
+
+	wgs84_xyz = turn_xyz_into_other_xyz(
+					osgb_xyz[0],osgb_xyz[1],osgb_xyz[2],'osgb','wgs84')
+
+	wgs84_latlong = turn_xyz_into_llh(
+					wgs84_xyz[0],wgs84_xyz[1],wgs84_xyz[2],'wgs84')
+
+	return wgs84_latlong
+
+def turn_osgb36_into_eastingnorthing(lat_dec,long_dec):
+	"""Turn OSGB36 (decimal) lat/long values into OS easting and northing values."""
+	return turn_latlong_into_eastingnorthing(lat_dec,long_dec,'osgb')
+
+def turn_eastingnorthing_into_osgb36(easting,northing):
+	"""Turn OSGB36 easting and northing values into (decimal) lat/long values inOSGB36."""
+	return turn_eastingnorthing_into_latlong(easting,northing,'osgb')
+
+##############################################################
+#         OS IE Specific Helpers for Generic Methods         #
+##############################################################
+
+def turn_wgs84_into_osie36(lat_dec,long_dec,height):
+	"""As per turn_wgs84_into_osgb36, but for Irish grid"""
+
+	wgs84_xyz = turn_llh_into_xyz(lat_dec,long_dec,height,'wgs84')
+
+	osie_xyz = turn_xyz_into_other_xyz(
+					wgs84_xyz[0],wgs84_xyz[1],wgs84_xyz[2],'wgs84','osie')
+
+	osie_latlong = turn_xyz_into_llh(
+					osie_xyz[0],osie_xyz[1],osie_xyz[2],'osie')
+	return osie_latlong
+
+def turn_osie36_into_wgs84(lat_dec,long_dec,height):
+	"""As per turn_osgb36_into_wgs84, but for Irish grid"""
+
+	osie_xyz = turn_llh_into_xyz(lat_dec,long_dec,height,'osie')
+
+	wgs84_xyz = turn_xyz_into_other_xyz(
+					osie_xyz[0],osie_xyz[1],osie_xyz[2],'osie','wgs84')
+
+	wgs84_latlong = turn_xyz_into_llh(
+					wgs84_xyz[0],wgs84_xyz[1],wgs84_xyz[2],'wgs84')
+
+	return wgs84_latlong
+
+def turn_osie36_into_eastingnorthing(lat_dec,long_dec):
+	"""Turn OSIE36 (decimal) lat/long values into OS IE easting and northing values."""
+	return turn_latlong_into_eastingnorthing(lat_dec,long_dec,'osie')
+
+def turn_eastingnorthing_into_osie36(easting,northing):
+	"""Turn OSIE36 easting and northing values into (decimal) lat/long values inOSIE36."""
+	return turn_eastingnorthing_into_latlong(easting,northing,'osie')
+
+##############################################################
+#             Generic Transform Functions                    #
+##############################################################
+
+def turn_llh_into_xyz(lat_dec,long_dec,height,system):
+	"""Convert Lat, Long and Height into 3D Cartesian x,y,z
+       See http://www.ordnancesurvey.co.uk/gps/docs/convertingcoordinates3D.pdf"""
+
+	a = abe_values[system][0]
+	b = abe_values[system][1]
+	e2 = abe_values[system][2]
+
+	theta = float(lat_dec)  / 360.0 * 2.0 * math.pi
+	landa = float(long_dec) / 360.0 * 2.0 * math.pi
+	height = float(height)
+
+	v = a / math.sqrt( 1.0 - e2 * (math.sin(theta) * math.sin(theta)) )
+	x = (v + height) * math.cos(theta) * math.cos(landa)
+	y = (v + height) * math.cos(theta) * math.sin(landa)
+	z = ( (1.0 - e2) * v + height ) * math.sin(theta)
+
+	return [x,y,z]
+
+def turn_xyz_into_llh(x,y,z,system):
+	"""Convert 3D Cartesian x,y,z into Lat, Long and Height
+       See http://www.ordnancesurvey.co.uk/gps/docs/convertingcoordinates3D.pdf"""
+
+	a = abe_values[system][0]
+	b = abe_values[system][1]
+	e2 = abe_values[system][2]
+
+	p = math.sqrt(x*x + y*y)
+
+	long = math.atan(y/x)
+	lat_init = math.atan( z / (p * (1.0 - e2)) )
+	v = a / math.sqrt( 1.0 - e2 * (math.sin(lat_init) * math.sin(lat_init)) )
+	lat = math.atan( (z + e2*v*math.sin(lat_init)) / p )
+
+	height = (p / math.cos(lat)) - v # Ignore if a bit out
+
+	# Turn from radians back into degrees
+	long = long / 2 / math.pi * 360
+	lat = lat / 2 / math.pi * 360
+
+	return [lat,long,height]
+
+def turn_xyz_into_other_xyz(old_x,old_y,old_z,from_scheme,to_scheme):
+	"""Helmert Transformation between one lat+long system and another
+See http://www.ordnancesurvey.co.uk/oswebsite/gps/information/coordinatesystemsinfo/guidecontents/guide6.html for the calculations, and http://www.movable-type.co.uk/scripts/LatLongConvertCoords.html for a friendlier version with examples"""
+
+	transform = from_scheme + "_to_" + to_scheme
+	tx = transform_values[transform][0]
+	ty = transform_values[transform][1]
+	tz = transform_values[transform][2]
+	s =  transform_values[transform][3]
+	rx = transform_values[transform][4]
+	ry = transform_values[transform][5]
+	rz = transform_values[transform][6]
+
+	# Do the transform
+	new_x = tx + ((1.0+s) * old_x) + (-rz * old_y) + (ry * old_z)
+	new_y = ty + (rz * old_x) + ((1.0+s) * old_y) + (-rx * old_z)
+	new_z = tz + (-ry * old_x) + (rx * old_y) + ((1.0+s) * old_z)
+
+	return [new_x,new_y,new_z]
+
+def calculate_distance_and_bearing(from_lat_dec,from_long_dec,to_lat_dec,to_long_dec):
+	"""Uses the spherical law of cosines to calculate the distance and bearing between two positions"""
+
+	# Turn them all into radians
+	from_theta = float(from_lat_dec)  / 360.0 * 2.0 * math.pi
+	from_landa = float(from_long_dec) / 360.0 * 2.0 * math.pi
+	to_theta = float(to_lat_dec)  / 360.0 * 2.0 * math.pi
+	to_landa = float(to_long_dec) / 360.0 * 2.0 * math.pi
+
+	d = math.acos(
+			math.sin(from_theta) * math.sin(to_theta) +
+			math.cos(from_theta) * math.cos(to_theta) * math.cos(to_landa-from_landa)
+		) * earths_radius
+
+	bearing = math.atan2(
+			math.sin(to_landa-from_landa) * math.cos(to_theta),
+			math.cos(from_theta) * math.sin(to_theta) -
+			math.sin(from_theta) * math.cos(to_theta) * math.cos(to_landa-from_landa)
+		)
+	bearing = bearing / 2.0 / math.pi * 360.0
+
+	return [d,bearing]
+
+##############################################################
+#            Easting/Northing Transform Methods              #
+##############################################################
+
+def turn_latlong_into_eastingnorthing(lat_dec,long_dec,scheme):
+	"""Turn OSGB36 or OSIE36 (decimal) lat/long values into OS easting and northing values. See http://www.ordnancesurvey.co.uk/oswebsite/gps/information/coordinatesystemsinfo/guidecontents/guide7.html for the calculations, and http://www.posc.org/Epicentre.2_2/DataModel/ExamplesofUsage/eu_cs34h.html for some background."""
+
+	n0 = en_values[scheme][0]
+	e0 = en_values[scheme][1]
+	f0 = en_values[scheme][2]
+
+	theta0 = en_values[scheme][3]
+	landa0 = en_values[scheme][4]
+
+	a = abe_values[scheme][0]
+	b = abe_values[scheme][1]
+	e2 = abe_values[scheme][2]
+
+	theta = float(lat_dec)  /360.0 *2.0*math.pi
+	landa = float(long_dec) /360.0 *2.0*math.pi
+
+	n = (a-b) / (a+b)
+	v = a * f0 * math.pow( (1 - e2 * math.sin(theta)*math.sin(theta)), -0.5 )
+	ro = a * f0 * (1 - e2) * math.pow( (1 - e2 * math.sin(theta)*math.sin(theta)), -1.5 )
+	nu2 = v/ro - 1
+
+	M = b * f0 * ( \
+		(1.0 + n + 5.0/4.0 *n*n + 5.0/4.0 *n*n*n) * (theta-theta0) - \
+		(3.0*n + 3.0*n*n + 21.0/8.0 *n*n*n) *math.sin(theta-theta0) *math.cos(theta+theta0) + \
+		(15.0/8.0*n*n + 15.0/8.0*n*n*n) *math.sin(2.0*(theta-theta0)) *math.cos(2.0*(theta+theta0)) - \
+		35.0/24.0*n*n*n *math.sin(3.0*(theta-theta0)) *math.cos(3.0*(theta+theta0)) \
+	)
+
+	I = M + n0
+	II = v/2.0 * math.sin(theta) * math.cos(theta)
+	III = v/24.0 * math.sin(theta) * math.pow( math.cos(theta),3 ) * \
+		(5.0 - math.pow(math.tan(theta),2) + 9.0*nu2)
+	IIIa = v/720.0 * math.sin(theta) * math.pow( math.cos(theta),5 ) * \
+		( 61.0 - 58.0 *math.pow(math.tan(theta),2) + math.pow(math.tan(theta),4) )
+	IV = v * math.cos(theta)
+	V = v/6.0 * math.pow( math.cos(theta),3 ) * \
+		( v/ro - math.pow(math.tan(theta),2) )
+	VI = v/120.0 * math.pow(math.cos(theta),5) * \
+		( 5.0 - 18.0 *math.pow(math.tan(theta),2) + \
+		math.pow(math.tan(theta),4) + 14.0*nu2 - \
+		58.0 * math.pow(math.tan(theta),2)*nu2 )
+
+	northing = I + II*math.pow(landa-landa0,2) + \
+		III*math.pow(landa-landa0,4) + \
+		IIIa*math.pow(landa-landa0,6)
+	easting = e0 + IV*(landa-landa0) + V*math.pow(landa-landa0,3) + \
+		VI*math.pow(landa-landa0,5)
+	
+	return (easting,northing)
+
+def turn_eastingnorthing_into_latlong(easting,northing,scheme):
+	"""Turn OSGB36 or OSIE36 easting and northing values into (decimal) lat/long values in OSGB36 / OSIE36. See http://www.ordnancesurvey.co.uk/oswebsite/gps/information/coordinatesystemsinfo/guidecontents/guide7.html for the calculations, and http://www.posc.org/Epicentre.2_2/DataModel/ExamplesofUsage/eu_cs34h.html for some background."""
+
+	n0 = en_values[scheme][0]
+	e0 = en_values[scheme][1]
+	f0 = en_values[scheme][2]
+
+	theta0 = en_values[scheme][3]
+	landa0 = en_values[scheme][4]
+
+	a = abe_values[scheme][0]
+	b = abe_values[scheme][1]
+	e2 = abe_values[scheme][2]
+
+	n = (a-b) / (a+b)
+
+	# Prepare to iterate
+	M = 0
+	theta = theta0
+	# Iterate, 4 times should be enough
+	for i in range(4):
+		theta = ((northing - n0 - M) / (a * f0)) + theta
+		M = b * f0 * ( \
+			(1.0 + n + 5.0/4.0 *n*n + 5.0/4.0 *n*n*n) * (theta-theta0) - \
+			(3.0*n + 3.0*n*n + 21.0/8.0 *n*n*n) *math.sin(theta-theta0) *math.cos(theta+theta0) + \
+			(15.0/8.0*n*n + 15.0/8.0*n*n*n) *math.sin(2.0*(theta-theta0)) *math.cos(2.0*(theta+theta0)) - \
+			35.0/24.0*n*n*n *math.sin(3.0*(theta-theta0)) *math.cos(3.0*(theta+theta0)) \
+		)
+
+	# Compute intermediate values
+	v = a * f0 * math.pow( (1 - e2 * math.sin(theta)*math.sin(theta)), -0.5 )
+	ro = a * f0 * (1 - e2) * math.pow( (1 - e2 * math.sin(theta)*math.sin(theta)), -1.5 )
+	nu2 = v/ro - 1
+	tantheta2 = math.pow(math.tan(theta),2)
+
+	VII = math.tan(theta) / (2 * ro * v)
+	VIII = math.tan(theta) / (24 * ro * math.pow(v,3)) \
+			* (5 + 3 * tantheta2 + nu2 - \
+			   9 * tantheta2 *  nu2 )
+	IX = math.tan(theta) / (720 * ro * math.pow(v,5)) \
+			* (61 + 90 * tantheta2 + 45 * tantheta2 * tantheta2)
+	X = 1 / (math.cos(theta) * v)
+	XI = 1 / (math.cos(theta) * 6 * math.pow(v,3)) \
+			* (v/ro + 2*tantheta2)
+	XII = 1 / (math.cos(theta) * 120 * math.pow(v,5)) \
+			* (5 + 28 * tantheta2 + 24 * tantheta2 * tantheta2)
+	XIIa = 1 / (math.cos(theta) * 5040 * math.pow(v,7)) \
+			* (61 + 662 * tantheta2 + 1320 * tantheta2 * tantheta2 \
+				+ 720 * tantheta2 * tantheta2 * tantheta2)
+
+	lat_rad = theta - VII * math.pow((easting-e0),2) \
+				+ VIII * math.pow((easting-e0),4) \
+				- IX * math.pow((easting-e0),6)
+	long_rad = landa0 + X * (easting-e0) \
+				- XI * math.pow((easting-e0),3) \
+				+ XII * math.pow((easting-e0),5) \
+				- XIIa * math.pow((easting-e0),7)
+
+	lat = lat_rad / 2.0 / math.pi * 360.0
+	long = long_rad / 2.0 / math.pi * 360.0
+
+	return (lat,long)
+
+##############################################################
+#         Cassini Easting/Northing Transform Methods         #
+##############################################################
+
+def turn_latlong_into_cassini_en(lat_dec,long_dec,scheme):
+	"""Latitude and Longitude, into Cassini-Soldner easting and northing co-ordinates, in the given scheme. See http://www.posc.org/Epicentre.2_2/DataModel/ExamplesofUsage/eu_cs34g.html for details of the calculation used"""
+	
+	a = abe_values[scheme][0]
+	b = abe_values[scheme][1]
+	e2 = abe_values[scheme][2]
+
+	e4 = e2 * e2
+	e6 = e2 * e2 * e2
+
+	theta = float(lat_dec)  /360.0 *2.0*math.pi
+	landa = float(long_dec) /360.0 *2.0*math.pi
+
+	theta0 = cassini_values[scheme][0]
+	landa0 = cassini_values[scheme][1]
+	false_easting = cassini_values[scheme][2]
+	false_northing = cassini_values[scheme][3]
+
+	# Compute intermediate values
+	A = (landa - landa0) * math.cos(theta)
+	T = math.tan(theta) * math.tan(theta)
+	C = e2 / (1.0 - e2) * math.cos(theta) * math.cos(theta)
+	v = a / math.sqrt( 1 - (e2 * math.sin(theta) * math.sin(theta)) )
+
+	A2 = A ** 2
+	A3 = A ** 3
+	A4 = A ** 4
+	A5 = A ** 5
+
+	# And M, which is how far along the meridian our latitude is from the origin
+	def makeM(picked_theta):
+		return a * (
+			(1.0 - e2/4.0 - 3.0*e4/64.0 - 5.0*e6/256.0) * picked_theta
+		  - (3.0*e2/8.0 + 3.0*e4/32.0 + 45.0*e6/1024.0) * math.sin(2.0*picked_theta)
+		  + (15.0*e4/256.0 + 45.0*e6/1024.0) * math.sin(4.0*picked_theta)
+		  - (35.0*e6/3072.0) * math.sin(6.0*picked_theta)
+	    )
+	M = makeM(theta)
+	M0 = makeM(theta0)
+
+	# Now calculate
+	easting = false_easting + v * (
+				A - T * A3 / 6.0 - (8.0 - T + 8.0*C) * T * A5 / 120.0 )
+	northing = false_northing + M - M0 + v * math.tan(theta) * (
+				A2 / 2.0 + (5.0 - T + 6.0*C) * A4 / 24.0 )
+
+	return (easting,northing)
+
+def turn_cassini_en_into_latlong(easting,northing,scheme):
+	"""Cassini-Soldner easting and northing, into Latitude and Longitude, in the given scheme. See http://www.posc.org/Epicentre.2_2/DataModel/ExamplesofUsage/eu_cs34g.html for details of the calculation used"""
+	
+	a = abe_values[scheme][0]
+	b = abe_values[scheme][1]
+	e2 = abe_values[scheme][2]
+
+	e4 = e2 * e2
+	e6 = e2 * e2 * e2
+
+	theta0 = cassini_values[scheme][0]
+	landa0 = cassini_values[scheme][1]
+	false_easting = cassini_values[scheme][2]
+	false_northing = cassini_values[scheme][3]
+
+	def makeM(picked_theta):
+		return a * (
+			(1.0 - e2/4.0 - 3.0*e4/64.0 - 5.0*e6/256.0) * picked_theta
+		  - (3.0*e2/8.0 + 3.0*e4/32.0 + 45.0*e6/1024.0) * math.sin(2.0*picked_theta)
+		  + (15.0*e4/256.0 + 45.0*e6/1024.0) * math.sin(4.0*picked_theta)
+		  - (35.0*e6/3072.0) * math.sin(6.0*picked_theta)
+	    )
+
+	# Compute first batch of intermediate values
+	M1 = makeM(theta0) + (northing - false_northing)
+	mu1 = M1 / (a * (1.0 - e2/4.0 - 3.0*e4/64.0 - 5.0*e6/256.0) )
+	e1 = (1 - ((1-e2) ** 0.5)) / (1 + ((1-e2) ** 0.5))
+
+	e1_2 = e1 ** 2
+	e1_3 = e1 ** 3
+	e1_4 = e1 ** 4
+
+	# Now compute theta1 at T1
+	theta1 = mu1 + (
+        + (3.0*e1 / 2.0 - 27.0*e1_3 / 32.0) * math.sin(2.0*mu1)
+        + (21.0*e1_2 / 16.0 - 55.0*e1_4 / 32.0) * math.sin(4.0*mu1)
+        + (151.0*e1_3 / 96.0) * math.sin(6.0*mu1)
+        + (1097.0*e1_4 / 512.0) * math.sin(8.0*mu1) 
+	)
+	T1 = (math.tan(theta1)) ** 2
+
+	# Now we can find v1, ro1 and D
+	v1 = a / math.sqrt( 1.0 - (e2 * math.sin(theta1) * math.sin(theta1)) )
+	ro1 = a * (1 - e2) / ((1 - e2 * math.sin(theta1) * math.sin(theta1)) ** 1.5)
+	D = (easting - false_easting) / v1
+
+	# And finally the lat and long
+	lat = theta1 - (v1 * math.tan(theta1)) / ro1 * (
+			D*D/2.0 - (1.0 + 3.0 * T1) * ( (D**4) / 24.0 ) )
+	long = landa0 + (
+				D - T1 * (D**3) / 3.0 + (1 + 3.0 * T1) * T1 * (D**5) / 15.0
+			) / math.cos(theta1)
+
+	# Now make decimal versions
+	lat_dec = lat * 360.0 / 2.0 / math.pi
+	long_dec = long * 360.0 / 2.0 / math.pi
+
+	return (lat_dec,long_dec)
+
+##############################################################
+#             OS Specific Methods Follow                     #
+##############################################################
+
+def turn_easting_northing_into_six_fig(easting,northing):
+	"""Turn OS easting and northing values into the six figure OS grid refecence. See http://www.jstott.me.uk/jscoord/"""
+	first_letter = ""
+	second_letter = ""
+
+	easting = int(easting)
+	northing = int(northing)
+
+	# Get the 100 km part
+	hkm_east = int( math.floor(easting / 100000.0) )
+	hkm_north = int( math.floor(northing / 100000.0) )
+	if hkm_north < 5:
+		if hkm_east < 5:
+			first_letter = "S"
+		else:
+			first_letter = "T"
+	elif hkm_north < 10:
+		if hkm_east < 5:
+			first_letter = "N"
+		else:
+			first_letter = "O"
+	else:
+		first_letter = "H"
+
+	# Get the 10km part
+	index = 65 + ((4 - (hkm_north % 5)) * 5) + (hkm_east % 5)
+	ti = index
+	if index >= 73:
+		index += 1
+	second_letter = chr(index)
+
+	# Get digits 2-4 on easting and northing
+	e = math.floor( (easting  - (100000.0 * hkm_east))  / 100.0)
+	n = math.floor( (northing - (100000.0 * hkm_north)) / 100.0)
+	e = "%03d" % e
+	n = "%03d" % n
+
+	return first_letter + second_letter + e + n

Propchange: comdev/nearby_people/lib/geo_helper.py
------------------------------------------------------------------------------
    svn:eol-style = native

Added: comdev/nearby_people/lib/geoname.py
URL: http://svn.apache.org/viewvc/comdev/nearby_people/lib/geoname.py?rev=894005&view=auto
==============================================================================
--- comdev/nearby_people/lib/geoname.py (added)
+++ comdev/nearby_people/lib/geoname.py Sat Dec 26 17:10:41 2009
@@ -0,0 +1,357 @@
+# -*- coding: utf-8 -*-
+
+"""Python wrapper for geoname web APIs
+
+created 19/03/2006 By Nicolas Laurance
+
+This module allows you to access geoname's web APIs,
+and get the results programmatically.
+Described here:
+  http://www.geonames.org/export/
+
+It is based on the Mark Pilgrim's technorati API :
+  http://www.sifry.com/alerts/archives/000288.html
+
+def postalCodeSearch(postalcode, placename='', country=COUNTRY, maxRows='10', http_proxy=None):
+def postalCodeLookupJSON(postalcode, placename='', country=COUNTRY, maxRows='10',gcallback='', http_proxy=None):
+def findNearbyPostalCodes(postalcode, placename='', country=COUNTRY, radius='5', maxRows='10',lat=None,lng=None, http_proxy=None):
+def postalCodeCountryInfo(http_proxy=None):
+def search(placename='', country=COUNTRY, maxRows='10', style='SHORT',lang=LANG, fclass=None, http_proxy=None):
+def findNearbyPlaceName(lat,lng, http_proxy=None):
+
+Sample usage:
+>>> import geoname
+>>> result=geoname.postalCodeSearch('35580','guichen','fr','10')
+>>> result.totalResultsCount
+1
+>>> result.code[0].lat
+47.966666699999998
+>>> result.code[0].lng
+-1.8
+
+>>> result=geoname.postalCodeLookupJSON('35580','guichen','fr','10')
+>>> result['postalcodes']
+[{'postalcode': '35580', 'placeName': 'Guichen', 'countryCode': 'FR'}]
+
+>>> result=geoname.findNearbyPostalCodes('35000','rennes','FR',10,10)
+>>> for b in result.code:
+...     print '%s : %s' %(b.name,b.postalcode)
+...
+Rennes : 35700
+Rennes : 35200
+Rennes : 35000
+St Jacques De La Lande : 35136
+Noyal Sur Seiche : 35230
+Pont Pean : 35131
+Chartres De Bretagne : 35131
+Chantepie : 35135
+Chatillon Sur Seiche : 35230
+St Gregoire : 35760
+
+>>> result=geoname.findNearbyPostalCodes('','','FR',10,10,47.97,-1.8)
+>>> for b in result.code:
+...      print '%s : %s' %(b.name,b.postalcode)
+...
+Guichen : 35580
+Pont Rean : 35580
+Pont Rean : 35170
+Goven : 35580
+Lassy : 35580
+Bourg Des Comptes : 35890
+Guignen : 35580
+St Senoux : 35580
+Bruz : 35170
+Chavagne : 35310
+
+
+>>> result=geoname.search('guichen','fr',5,'SHORT','fr')
+>>> result.totalResultsCount
+3
+>>> for b in result.geoname:
+...     print '%s' %(b.name)
+...
+Guichen
+Guiche
+La Guiche
+
+
+>>> result=geoname.findNearbyPlaceName(47.97,-1.8)
+>>> for b in result.geoname:
+...     print '%s' % b.name
+...
+Guichen
+
+"""
+
+__author__ = "Nicolas Laurance (nlaurance@zindep.com)"
+__version__ = "0.1"
+__cvsversion__ = "$Revision: 1.0 $"[11:-2]
+__date__ = "$Date: 2003/06/19 22:40:53 $"[7:-2]
+__copyright__ = "Copyright (c) 2006 Nicolas Laurance"
+__license__ = "Python"
+
+from xml.dom import minidom
+import os, sys, urllib, re
+try:
+    import timeoutsocket # http://www.timo-tasi.org/python/timeoutsocket.py
+    timeoutsocket.setDefaultSocketTimeout(120)
+except ImportError:
+    pass
+
+HTTP_PROXY = None
+DEBUG = 0
+COUNTRY = 'FR'
+LANG ='fr'
+
+
+# don't touch the rest of these constants
+class GeonameError(Exception): pass
+
+## administrative functions
+def version():
+    print """PyGeoname %(__version__)s
+%(__copyright__)s
+released %(__date__)s
+""" % globals()
+
+def setProxy(http_proxy):
+    """set HTTP proxy"""
+    global HTTP_PROXY
+    HTTP_PROXY = http_proxy
+
+def getProxy(http_proxy = None):
+    """get HTTP proxy"""
+    return http_proxy or HTTP_PROXY
+
+def getProxies(http_proxy = None):
+    http_proxy = getProxy(http_proxy)
+    if http_proxy:
+        proxies = {"http": http_proxy}
+    else:
+        proxies = None
+    return proxies
+
+def _contentsOf(dirname, filename):
+    filename = os.path.join(dirname, filename)
+    if not os.path.exists(filename): return None
+    fsock = open(filename)
+    contents = fsock.read()
+    fsock.close()
+    return contents
+
+def _getScriptDir():
+    if __name__ == '__main__':
+        return os.path.abspath(os.path.dirname(sys.argv[0]))
+    else:
+        return os.path.abspath(os.path.dirname(sys.modules[__name__].__file__))
+
+class Bag: pass
+
+_intFields = ('totalResultsCount')
+_dateFields = ()
+_listFields = ('code','geoname','country',)
+_floatFields = ('lat','lng','distance')
+
+def unmarshal(element):
+    #import pdb;pdb.set_trace()
+    rc = Bag()
+    childElements = [e for e in element.childNodes if isinstance(e, minidom.Element)]
+    if childElements:
+        for child in childElements:
+            key = child.tagName
+            if hasattr(rc, key):
+                if key in _listFields:
+                    setattr(rc, key, getattr(rc, key) + [unmarshal(child)])
+            elif isinstance(child, minidom.Element) and (child.tagName in ( )):
+                rc = unmarshal(child)
+            elif key in _listFields:
+                setattr(rc, key, [unmarshal(child)])
+            else:
+                setattr(rc, key, unmarshal(child))
+    else:
+        rc = "".join([e.data for e in element.childNodes if isinstance(e, minidom.Text)])
+        if str(element.tagName) in _intFields:
+            rc = int(rc)
+            if DEBUG: print '%s : %s' % (element.tagName,rc)
+        elif str(element.tagName) in _floatFields:
+            rc = float(rc)
+            if DEBUG: print '%s : %s' % (element.tagName,rc)
+        elif str(element.tagName) in _dateFields:
+            year, month, day, hour, minute, second = re.search(r'(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})', rc).groups()
+            rc = (int(year), int(month), int(day), int(hour), int(minute), int(second), 0, 0, 0)
+            if DEBUG: print '%s : %s' % (element.tagName,rc)
+    return rc
+
+def _do(url, http_proxy):
+    proxies = getProxies(http_proxy)
+    u = urllib.FancyURLopener(proxies)
+    usock = u.open(url)
+    rawdata = usock.read()
+    if DEBUG: print rawdata
+    xmldoc = minidom.parseString(rawdata)
+    usock.close()
+    data = unmarshal(xmldoc)
+#    if hasattr(data, 'ErrorMsg'):
+    if 0:
+        raise TechnoratiError, data
+    else:
+        return data
+
+## main functions
+
+def _buildfindNearbyPostalCodes(postalcode, placename, country, radius, maxRows ):
+    placename=urllib.quote(placename)
+    searchUrl = "http://ws.geonames.org/findNearbyPostalCodes?postalcode=%(postalcode)s&placename=%(placename)s&country=%(country)s&radius=%(radius)s&maxRows=%(maxRows)s" % vars()
+    return searchUrl
+
+
+def _buildpostalCodeLookupJSON(postalcode,placename,country,maxRows,gcallback):
+    placename=urllib.quote(placename)
+    searchUrl = "http://ws.geonames.org/postalCodeLookupJSON?postalcode=%(postalcode)s&placename=%(placename)s&country=%(country)s&maxRows=%(maxRows)s&callback=%(gcallback)s" % vars()
+    return searchUrl
+
+def _buildfindNearbyPostalCodesLL(lat,lng,radius,maxRows):
+    searchUrl = "http://ws.geonames.org/findNearbyPostalCodes?lat=%(lat)s&lng=%(lng)s&radius=%(radius)s&maxRows=%(maxRows)s" % vars()
+    return searchUrl
+
+def _buildfindNearbyPlaceName(lat,lng):
+    searchUrl = "http://ws.geonames.org/findNearbyPlaceName?lat=%(lat)s&lng=%(lng)s" % vars()
+    return searchUrl
+
+def _buildpostalCodeSearch(postalcode, placename, country, maxRows ):
+    placename=urllib.quote(placename)
+    searchUrl = "http://ws.geonames.org/postalCodeSearch?postalcode=%(postalcode)s&placename=%(placename)s&country=%(country)s&maxRows=%(maxRows)s" % vars()
+    return searchUrl
+
+def _buildsearch(placename, country, maxRows,style,lang, fclass):
+    placename=urllib.quote(placename)
+    if fclass:
+        urlfclass=''
+        for fc in fclass:
+            urlfclass+="&fclass="
+            urlfclass+=urllib.quote(fc)
+    searchUrl = "http://ws.geonames.org/search?q=%(placename)s&country=%(country)s&maxRows=%(maxRows)s&lang=%(lang)s&style=%(style)s%(urlfclass)s" % vars()
+    return searchUrl
+
+def postalCodeSearch(postalcode, placename='', country=COUNTRY, maxRows='10', http_proxy=None):
+    """
+    http://ws.geonames.org/postalCodeSearch?postalcode=35580&maxRows=10&country=fr
+    Url : ws.geonames.org/postalCodeSearch?
+    Parameters : postalcode ,placename,maxRows,country
+    <geonames>
+    <totalResultsCount>7</totalResultsCount>
+    -
+    <code>
+        <postalcode>35580</postalcode>
+        <name>St Senoux</name>
+        <countryCode>FR</countryCode>
+        <lat>47.9</lat>
+        <lng>-1.7833333</lng>
+    </code>
+    """
+    url = _buildpostalCodeSearch(postalcode,placename,country,maxRows)
+    if DEBUG: print url
+    return _do(url,http_proxy).geonames
+
+def postalCodeLookupJSON(postalcode, placename='', country=COUNTRY, maxRows='10',gcallback='', http_proxy=None):
+    """
+    Webservice Type : REST /JSON
+    Url : ws.geonames.org/postalCodeLookupJSON?
+    Parameters : postalcode,country ,maxRows (default = 20),callback
+    Result : returns a list of places for the given postalcode in JSON format
+    """
+    url = _buildpostalCodeLookupJSON(postalcode,placename,country,maxRows,gcallback)
+#    print url
+    proxies = getProxies(http_proxy)
+    u = urllib.FancyURLopener(proxies)
+    usock = u.open(url)
+    rawdata = usock.read()
+    if DEBUG: print rawdata
+    usock.close()
+    return eval(rawdata[:-3])
+
+def findNearbyPostalCodes(postalcode, placename='', country=COUNTRY, radius='5', maxRows='10',lat=None,lng=None, http_proxy=None):
+    """
+    Find nearby postal codes / reverse geocoding
+    This service comes in two flavors. You can either pass the lat/long or a postalcode/placename.
+
+    Webservice Type : REST
+    Url : ws.geonames.org/findNearbyPostalCodes?
+    Parameters :
+    lat,lng, radius (in km), maxRows (default = 5),country (default = all countries)
+    or
+    postalcode,country, radius (in Km), maxRows (default = 5)
+    Result : returns a list of postalcodes and places for the lat/lng query as xml document
+    Example: 
+    http://ws.geonames.org/findNearbyPostalCodes?postalcode=35580&placename=guichen&country=FR&radius=5
+    <geonames>
+    -
+    <code>
+        <postalcode>35580</postalcode>
+        <name>Guichen</name>
+        <countryCode>FR</countryCode>
+        <lat>47.9666667</lat>
+        <lng>-1.8</lng>
+        <distance>0.0</distance>
+    </code>
+    """
+    if lat and lng :
+        url = _buildfindNearbyPostalCodesLL(lat,lng,radius,maxRows)
+    else:
+        url = _buildfindNearbyPostalCodes(postalcode,placename,country,radius,maxRows)
+    if DEBUG: print url
+#    import pdb;pdb.set_trace()
+    return _do(url,http_proxy).geonames
+
+
+def postalCodeCountryInfo(http_proxy=None):
+    """
+    http://ws.geonames.org/postalCodeCountryInfo?
+    <country>
+    <countryCode>FR</countryCode>
+    <countryName>France</countryName>
+    <numPostalCodes>39163</numPostalCodes>
+    <minPostalCode>01000</minPostalCode>
+    <maxPostalCode>98000</maxPostalCode>
+    </country>
+
+    """
+    return _do("http://ws.geonames.org/postalCodeCountryInfo?",http_proxy).geonames.country
+
+def search(placename='', country=COUNTRY, maxRows='10', style='SHORT',lang=LANG, fclass=None, http_proxy=None):
+    """
+    Url : ws.geonames.org/search?
+    Parameters : 	q : place name (urlencoded utf8)
+    maxRows : maximal number of rows returned (default = 100)
+    country : iso country code, two characters (default = all countries)
+    fclass : featureclass(es) (default= all feature classes); this parameter may occur more then once, example: fclass=P&fclass=A
+    style : SHORT,MEDIUM,LONG (default = MEDIUM), verbosity of returned xml document
+    lang : ISO 2-letter language code. (default = en), countryName will be returned in the specified language. 
+
+    http://ws.geonames.org/search?q=guichen&maxRows=10&style=SHORT&lang=fr&country=fr
+        <geonames>
+        <totalResultsCount>3</totalResultsCount>
+        -
+        <geoname>
+            <name>Laillé</name>
+            <lat>47.9833333</lat>
+            <lng>-1.7166667</lng>
+        </geoname>
+    """
+    url = _buildsearch(placename, country, maxRows,style,lang, fclass)
+    if DEBUG: print url
+    return _do(url,http_proxy).geonames
+
+def findNearbyPlaceName(lat,lng, http_proxy=None):
+    """
+    Webservice Type : REST
+    Url : ws.geonames.org/findNearbyPlaceName?
+    Parameters : lat,lng
+    Result : returns the closest populated place for the lat/lng query as xml document
+    Example:
+    http://ws.geonames.org/findNearbyPlaceName?lat=47.3&lng=9     
+    """
+    url = _buildfindNearbyPlaceName(lat,lng)
+    if DEBUG: print url
+    return _do(url,http_proxy).geonames
+

Propchange: comdev/nearby_people/lib/geoname.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: comdev/nearby_people/lib/geoname.py
------------------------------------------------------------------------------
    svn:executable = *

Added: comdev/nearby_people/lib/timeoutsocket.py
URL: http://svn.apache.org/viewvc/comdev/nearby_people/lib/timeoutsocket.py?rev=894005&view=auto
==============================================================================
--- comdev/nearby_people/lib/timeoutsocket.py (added)
+++ comdev/nearby_people/lib/timeoutsocket.py Sat Dec 26 17:10:41 2009
@@ -0,0 +1,424 @@
+
+####
+# Copyright 2000,2001 by Timothy O'Malley <timo@alum.mit.edu>
+# 
+#                All Rights Reserved
+# 
+# Permission to use, copy, modify, and distribute this software
+# and its documentation for any purpose and without fee is hereby
+# granted, provided that the above copyright notice appear in all
+# copies and that both that copyright notice and this permission
+# notice appear in supporting documentation, and that the name of
+# Timothy O'Malley  not be used in advertising or publicity
+# pertaining to distribution of the software without specific, written
+# prior permission. 
+# 
+# Timothy O'Malley DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+# SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+# AND FITNESS, IN NO EVENT SHALL Timothy O'Malley BE LIABLE FOR
+# ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+# PERFORMANCE OF THIS SOFTWARE. 
+#
+####
+
+"""Timeout Socket
+
+This module enables a timeout mechanism on all TCP connections.  It
+does this by inserting a shim into the socket module.  After this module
+has been imported, all socket creation goes through this shim.  As a
+result, every TCP connection will support a timeout.
+
+The beauty of this method is that it immediately and transparently
+enables the entire python library to support timeouts on TCP sockets.
+As an example, if you wanted to SMTP connections to have a 20 second
+timeout:
+
+    import timeoutsocket
+    import smtplib
+    timeoutsocket.setDefaultSocketTimeout(20)
+
+
+The timeout applies to the socket functions that normally block on
+execution:  read, write, connect, and accept.  If any of these 
+operations exceeds the specified timeout, the exception Timeout
+will be raised.
+
+The default timeout value is set to None.  As a result, importing
+this module does not change the default behavior of a socket.  The
+timeout mechanism only activates when the timeout has been set to
+a numeric value.  (This behavior mimics the behavior of the
+select.select() function.)
+
+This module implements two classes: TimeoutSocket and TimeoutFile.
+
+The TimeoutSocket class defines a socket-like object that attempts to
+avoid the condition where a socket may block indefinitely.  The
+TimeoutSocket class raises a Timeout exception whenever the
+current operation delays too long. 
+
+The TimeoutFile class defines a file-like object that uses the TimeoutSocket
+class.  When the makefile() method of TimeoutSocket is called, it returns
+an instance of a TimeoutFile.
+
+Each of these objects adds two methods to manage the timeout value:
+
+    get_timeout()   -->  returns the timeout of the socket or file
+    set_timeout()   -->  sets the timeout of the socket or file
+
+
+As an example, one might use the timeout feature to create httplib
+connections that will timeout after 30 seconds:
+
+    import timeoutsocket
+    import httplib
+    H = httplib.HTTP("www.python.org")
+    H.sock.set_timeout(30)
+
+Note:  When used in this manner, the connect() routine may still
+block because it happens before the timeout is set.  To avoid
+this, use the 'timeoutsocket.setDefaultSocketTimeout()' function.
+
+Good Luck!
+
+"""
+
+__version__ = "$Revision: 1.23 $"
+__author__  = "Timothy O'Malley <timo@alum.mit.edu>"
+
+#
+# Imports
+#
+import select, string
+import socket
+if not hasattr(socket, "_no_timeoutsocket"):
+    _socket = socket.socket
+else:
+    _socket = socket._no_timeoutsocket
+
+
+#
+# Set up constants to test for Connected and Blocking operations.
+# We delete 'os' and 'errno' to keep our namespace clean(er).
+# Thanks to Alex Martelli and G. Li for the Windows error codes.
+#
+import os
+if os.name == "nt":
+    _IsConnected = ( 10022, 10056 )
+    _ConnectBusy = ( 10035, )
+    _AcceptBusy  = ( 10035, )
+else:
+    import errno
+    _IsConnected = ( errno.EISCONN, )
+    _ConnectBusy = ( errno.EINPROGRESS, errno.EALREADY, errno.EWOULDBLOCK )
+    _AcceptBusy  = ( errno.EAGAIN, errno.EWOULDBLOCK )
+    del errno
+del os
+
+
+#
+# Default timeout value for ALL TimeoutSockets
+#
+_DefaultTimeout = None
+def setDefaultSocketTimeout(timeout):
+    global _DefaultTimeout
+    _DefaultTimeout = timeout
+def getDefaultSocketTimeout():
+    return _DefaultTimeout
+
+#
+# Exceptions for socket errors and timeouts
+#
+Error = socket.error
+class Timeout(Exception):
+    pass
+
+
+#
+# Factory function
+#
+from socket import AF_INET, SOCK_STREAM
+def timeoutsocket(family=AF_INET, type=SOCK_STREAM, proto=None):
+    if family != AF_INET or type != SOCK_STREAM:
+        if proto:
+            return _socket(family, type, proto)
+        else:
+            return _socket(family, type)
+    return TimeoutSocket( _socket(family, type), _DefaultTimeout )
+# end timeoutsocket
+
+#
+# The TimeoutSocket class definition
+#
+class TimeoutSocket:
+    """TimeoutSocket object
+    Implements a socket-like object that raises Timeout whenever
+    an operation takes too long.
+    The definition of 'too long' can be changed using the
+    set_timeout() method.
+    """
+
+    _copies = 0
+    _blocking = 1
+    
+    def __init__(self, sock, timeout):
+        self._sock     = sock
+        self._timeout  = timeout
+    # end __init__
+
+    def __getattr__(self, key):
+        return getattr(self._sock, key)
+    # end __getattr__
+
+    def get_timeout(self):
+        return self._timeout
+    # end set_timeout
+
+    def set_timeout(self, timeout=None):
+        self._timeout = timeout
+    # end set_timeout
+
+    def setblocking(self, blocking):
+        self._blocking = blocking
+        return self._sock.setblocking(blocking)
+    # end set_timeout
+
+    def connect_ex(self, addr):
+        errcode = 0
+        try:
+            self.connect(addr)
+        except Error, why:
+            errcode = why[0]
+        return errcode
+    # end connect_ex
+        
+    def connect(self, addr, port=None, dumbhack=None):
+        # In case we were called as connect(host, port)
+        if port != None:  addr = (addr, port)
+
+        # Shortcuts
+        sock    = self._sock
+        timeout = self._timeout
+        blocking = self._blocking
+
+        # First, make a non-blocking call to connect
+        try:
+            sock.setblocking(0)
+            sock.connect(addr)
+            sock.setblocking(blocking)
+            return
+        except Error, why:
+            # Set the socket's blocking mode back
+            sock.setblocking(blocking)
+            
+            # If we are not blocking, re-raise
+            if not blocking:
+                raise
+            
+            # If we are already connected, then return success.
+            # If we got a genuine error, re-raise it.
+            errcode = why[0]
+            if dumbhack and errcode in _IsConnected:
+                return
+            elif errcode not in _ConnectBusy:
+                raise
+            
+        # Now, wait for the connect to happen
+        # ONLY if dumbhack indicates this is pass number one.
+        #   If select raises an error, we pass it on.
+        #   Is this the right behavior?
+        if not dumbhack:
+            r,w,e = select.select([], [sock], [], timeout)
+            if w:
+                return self.connect(addr, dumbhack=1)
+
+        # If we get here, then we should raise Timeout
+        raise Timeout("Attempted connect to %s timed out." % str(addr) )
+    # end connect
+
+    def accept(self, dumbhack=None):
+        # Shortcuts
+        sock     = self._sock
+        timeout  = self._timeout
+        blocking = self._blocking
+
+        # First, make a non-blocking call to accept
+        #  If we get a valid result, then convert the
+        #  accept'ed socket into a TimeoutSocket.
+        # Be carefult about the blocking mode of ourselves.
+        try:
+            sock.setblocking(0)
+            newsock, addr = sock.accept()
+            sock.setblocking(blocking)
+            timeoutnewsock = self.__class__(newsock, timeout)
+            timeoutnewsock.setblocking(blocking)
+            return (timeoutnewsock, addr)
+        except Error, why:
+            # Set the socket's blocking mode back
+            sock.setblocking(blocking)
+
+            # If we are not supposed to block, then re-raise
+            if not blocking:
+                raise
+            
+            # If we got a genuine error, re-raise it.
+            errcode = why[0]
+            if errcode not in _AcceptBusy:
+                raise
+            
+        # Now, wait for the accept to happen
+        # ONLY if dumbhack indicates this is pass number one.
+        #   If select raises an error, we pass it on.
+        #   Is this the right behavior?
+        if not dumbhack:
+            r,w,e = select.select([sock], [], [], timeout)
+            if r:
+                return self.accept(dumbhack=1)
+
+        # If we get here, then we should raise Timeout
+        raise Timeout("Attempted accept timed out.")
+    # end accept
+
+    def send(self, data, flags=0):
+        sock = self._sock
+        if self._blocking:
+            r,w,e = select.select([],[sock],[], self._timeout)
+            if not w:
+                raise Timeout("Send timed out")
+        return sock.send(data, flags)
+    # end send
+
+    def recv(self, bufsize, flags=0):
+        sock = self._sock
+        if self._blocking:
+            r,w,e = select.select([sock], [], [], self._timeout)
+            if not r:
+                raise Timeout("Recv timed out")
+        return sock.recv(bufsize, flags)
+    # end recv
+
+    def makefile(self, flags="r", bufsize=-1):
+        self._copies = self._copies +1
+        return TimeoutFile(self, flags, bufsize)
+    # end makefile
+
+    def close(self):
+        if self._copies <= 0:
+            self._sock.close()
+        else:
+            self._copies = self._copies -1
+    # end close
+
+# end TimeoutSocket
+
+
+class TimeoutFile:
+    """TimeoutFile object
+    Implements a file-like object on top of TimeoutSocket.
+    """
+    
+    def __init__(self, sock, mode="r", bufsize=4096):
+        self._sock          = sock
+        self._bufsize       = 4096
+        if bufsize > 0: self._bufsize = bufsize
+        if not hasattr(sock, "_inqueue"): self._sock._inqueue = ""
+
+    # end __init__
+
+    def __getattr__(self, key):
+        return getattr(self._sock, key)
+    # end __getattr__
+
+    def close(self):
+        self._sock.close()
+        self._sock = None
+    # end close
+    
+    def write(self, data):
+        self.send(data)
+    # end write
+
+    def read(self, size=-1):
+        _sock = self._sock
+        _bufsize = self._bufsize
+        while 1:
+            datalen = len(_sock._inqueue)
+            if datalen >= size >= 0:
+                break
+            bufsize = _bufsize
+            if size > 0:
+                bufsize = min(bufsize, size - datalen )
+            buf = self.recv(bufsize)
+            if not buf:
+                break
+            _sock._inqueue = _sock._inqueue + buf
+        data = _sock._inqueue
+        _sock._inqueue = ""
+        if size > 0 and datalen > size:
+            _sock._inqueue = data[size:]
+            data = data[:size]
+        return data
+    # end read
+
+    def readline(self, size=-1):
+        _sock = self._sock
+        _bufsize = self._bufsize
+        while 1:
+            idx = string.find(_sock._inqueue, "\n")
+            if idx >= 0:
+                break
+            datalen = len(_sock._inqueue)
+            if datalen >= size >= 0:
+                break
+            bufsize = _bufsize
+            if size > 0:
+                bufsize = min(bufsize, size - datalen )
+            buf = self.recv(bufsize)
+            if not buf:
+                break
+            _sock._inqueue = _sock._inqueue + buf
+
+        data = _sock._inqueue
+        _sock._inqueue = ""
+        if idx >= 0:
+            idx = idx + 1
+            _sock._inqueue = data[idx:]
+            data = data[:idx]
+        elif size > 0 and datalen > size:
+            _sock._inqueue = data[size:]
+            data = data[:size]
+        return data
+    # end readline
+
+    def readlines(self, sizehint=-1):
+        result = []
+        data = self.read()
+        while data:
+            idx = string.find(data, "\n")
+            if idx >= 0:
+                idx = idx + 1
+                result.append( data[:idx] )
+                data = data[idx:]
+            else:
+                result.append( data )
+                data = ""
+        return result
+    # end readlines
+
+    def flush(self):  pass
+
+# end TimeoutFile
+
+
+#
+# Silently replace the socket() builtin function with
+# our timeoutsocket() definition.
+#
+if not hasattr(socket, "_no_timeoutsocket"):
+    socket._no_timeoutsocket = socket.socket
+    socket.socket = timeoutsocket
+del socket
+socket = timeoutsocket
+# Finis

Propchange: comdev/nearby_people/lib/timeoutsocket.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: comdev/nearby_people/lib/timeoutsocket.py
------------------------------------------------------------------------------
    svn:executable = *

Added: comdev/nearby_people/local_settings.py.example
URL: http://svn.apache.org/viewvc/comdev/nearby_people/local_settings.py.example?rev=894005&view=auto
==============================================================================
--- comdev/nearby_people/local_settings.py.example (added)
+++ comdev/nearby_people/local_settings.py.example Sat Dec 26 17:10:41 2009
@@ -0,0 +1,25 @@
+# Django settings for nearby_people project.
+DEBUG = True
+TEMPLATE_DEBUG = DEBUG
+
+ADMINS = (
+    # ('Your Name', 'your_email@domain.com'),
+)
+
+# Database settings
+DATABASE_ENGINE = ''           # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
+DATABASE_NAME = ''             # Or path to database file if using sqlite3.
+DATABASE_USER = ''             # Not used with sqlite3.
+DATABASE_PASSWORD = ''         # Not used with sqlite3.
+DATABASE_HOST = ''             # Set to empty string for localhost. Not used with sqlite3.
+DATABASE_PORT = ''             # Set to empty string for default. Not used with sqlite3.
+
+
+import os, sys
+BASE_PATH = os.path.realpath(os.path.dirname(__file__))
+
+# FOAF/DOAP settings
+COMDEV_DOAP = os.path.join(BASE_PATH, "data/project/CommunityDevelopment.rdf")
+SPEAKERS_DOAP = os.path.join(BASE_PATH, "data/project/LocalSpeakers.rdf")
+PEOPLE_FOAF_PATH = os.path.join(BASE_PATH, "data/people/")
+PEOPLE_FOAF_NAMESPACE = "http://people.apache.org/"

Added: comdev/nearby_people/manage.py
URL: http://svn.apache.org/viewvc/comdev/nearby_people/manage.py?rev=894005&view=auto
==============================================================================
--- comdev/nearby_people/manage.py (added)
+++ comdev/nearby_people/manage.py Sat Dec 26 17:10:41 2009
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+# ====================================================================
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ====================================================================
+
+from django.core.management import execute_manager
+try:
+    import settings # Assumed to be in the same directory.
+except ImportError:
+    import sys
+    sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
+    sys.exit(1)
+
+if __name__ == "__main__":
+    execute_manager(settings)

Propchange: comdev/nearby_people/manage.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: comdev/nearby_people/manage.py
------------------------------------------------------------------------------
    svn:executable = *

Propchange: comdev/nearby_people/nearby/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Dec 26 17:10:41 2009
@@ -0,0 +1,2 @@
+*.swp
+*.pyc

Added: comdev/nearby_people/nearby/__init__.py
URL: http://svn.apache.org/viewvc/comdev/nearby_people/nearby/__init__.py?rev=894005&view=auto
==============================================================================
--- comdev/nearby_people/nearby/__init__.py (added)
+++ comdev/nearby_people/nearby/__init__.py Sat Dec 26 17:10:41 2009
@@ -0,0 +1,16 @@
+# ====================================================================
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ====================================================================

Propchange: comdev/nearby_people/nearby/__init__.py
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message