<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    Yes, optionally. But i prefere to stay on a safe side and avoid
    using 'date' word at all. Thanks again.<br>
    <br>
    <div class="moz-cite-prefix">31.07.2014 17:33, Alexander Kozlovsky
      пишет:<br>
    </div>
    <blockquote
cite="mid:CAGM6z1sTgFH9q5yY=mn_2Ys9tvBwc7ZqEqQ56isLWM4rG5QULQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">Actually `date` is not a reserved word in Python,
        so if you really want it to be named 'date', you can do it as in
        the following:<br>
        <br>
            import datetime<br>
        <br>
            ...<br>
            class MyEntity(db.Entity):<br>
                date = Required(datetime.date)<br>
        <br>
        This way you can avoid name conflict. But renaming 'date'
        attribute is the valid way too.<br>
            </div>
      <div class="gmail_extra"><br>
        <br>
        <div class="gmail_quote">On Thu, Jul 31, 2014 at 3:13 PM, Вадим
          Бажов <span dir="ltr"><<a moz-do-not-send="true"
              href="mailto:vadim@ideco.ru" target="_blank">vadim@ideco.ru</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div text="#000000" bgcolor="#FFFFFF"> Yes, my fault ! Thank
              you Alexander.<br>
              And the second mistake is the 'date' name for the field
              variable. It's reserved in python. I had to rename it to
              'insdate' and now everithyng works fine.<br>
              Thanks a lot for the Pony ORM and immediate support ))<br>
              <br>
              <div>31.07.2014 16:55, Alexander Kozlovsky пишет:<br>
              </div>
              <div>
                <div class="h5">
                  <blockquote type="cite">
                    <div dir="ltr">Hi Vadim!<br>
                      <br>
                      The datatype that is specifed in attribute
                      definition is a normal Python type. In Python,
                      `int` and `str` types can be used immediately, but
                      `date` and `datetime` types must be imported from
                      stadard `datetime` module.<br>
                      <br>
                      You can add this import to the beginning of your
                      program:<br>
                      <br>
                          from datetime import date, datetime<br>
                      <br>
                      After that, all should work without the exception:<br>
                      <br>
                          <span
                        style="font-size:13px;font-family:arial,sans-serif">date

                        = Required(date)<br>
                      </span>    updated_at = Optional(datetime)<br>
                      <br>
                      Alternatively, you can just import `datetime`
                      module itself:<br>
                      <br>
                          import datetime<br>
                      <br>
                      After that, refer to `date` and `datetime` types
                      as `datetime.date` and `datetime.datetime`:<br>
                      <br>
                          <span
                        style="font-family:arial,sans-serif;font-size:13px">date

                        = Required(datetime.date)</span><br>
                          updated_at = Optional(datetime.datetime)<br>
                      <br>
                      Regards,<br>
                      Alexander Kozlovsky<br>
                      <br>
                    </div>
                    <div class="gmail_extra"> <br>
                      <br>
                      <div class="gmail_quote">On Thu, Jul 31, 2014 at
                        2:33 PM, Вадим Бажов <span dir="ltr"><<a
                            moz-do-not-send="true"
                            href="mailto:vadim@ideco.ru" target="_blank">vadim@ideco.ru</a>></span>
                        wrote:<br>
                        <blockquote class="gmail_quote" style="margin:0
                          0 0 .8ex;border-left:1px #ccc
                          solid;padding-left:1ex"> Hi people !<br>
                          <br>
                          Whenever i create a date or datetime field in
                          entity python always gives me an exception:<br>
                          <br>
                          "NameError: name 'date' is not defined" for
                          "date = Required(date)" record according your
                          documentation documentation<br>
                          <br>
                          "pony.orm.core.ERDiagramError: Entity
                          definition date was not found" for "date =
                          Required('date')"<br>
                          <br>
                          I am trying to run i file with folowing code:<br>
                          <br>
                          #!/usr/bin/python<br>
                          <br>
                          # -*- coding: utf-8 -*-<br>
                          <br>
                          from pony.orm import *<br>
                          <br>
                          db = Database('sqlite', 'db.sqlite',
                          create_db=True)<br>
                          <br>
                          class subscribers(db.Entity):<br>
                          <br>
                              id = PrimaryKey(int, auto=True)<br>
                          <br>
                              email   = Optional(str)<br>
                          <br>
                              date = Required(date)<br>
                          <br>
                          sql_debug(True)<br>
                          <br>
                          db.generate_mapping(create_tables=True)<br>
                          <br>
                          <br>
                          Running that code from python shell gives me
                          the following:<br>
                          <br>
                          <blockquote class="gmail_quote"
                            style="margin:0 0 0 .8ex;border-left:1px
                            #ccc solid;padding-left:1ex">
                            <blockquote class="gmail_quote"
                              style="margin:0 0 0 .8ex;border-left:1px
                              #ccc solid;padding-left:1ex">
                              <blockquote class="gmail_quote"
                                style="margin:0 0 0 .8ex;border-left:1px
                                #ccc solid;padding-left:1ex"> from
                                pony.orm import *<br>
                              </blockquote>
                            </blockquote>
                          </blockquote>
                          <br>
                          <blockquote class="gmail_quote"
                            style="margin:0 0 0 .8ex;border-left:1px
                            #ccc solid;padding-left:1ex">
                            <blockquote class="gmail_quote"
                              style="margin:0 0 0 .8ex;border-left:1px
                              #ccc solid;padding-left:1ex">
                              <blockquote class="gmail_quote"
                                style="margin:0 0 0 .8ex;border-left:1px
                                #ccc solid;padding-left:1ex"> db =
                                Database('sqlite', '/tmp/db.sqlite',
                                create_db=True)<br>
                              </blockquote>
                            </blockquote>
                          </blockquote>
                          <br>
                          GET NEW CONNECTION<br>
                          <br>
                          RELEASE CONNECTION<br>
                          <br>
                          <blockquote class="gmail_quote"
                            style="margin:0 0 0 .8ex;border-left:1px
                            #ccc solid;padding-left:1ex">
                            <blockquote class="gmail_quote"
                              style="margin:0 0 0 .8ex;border-left:1px
                              #ccc solid;padding-left:1ex">
                              <blockquote class="gmail_quote"
                                style="margin:0 0 0 .8ex;border-left:1px
                                #ccc solid;padding-left:1ex"> class
                                subscribers(db.Entity):<br>
                              </blockquote>
                            </blockquote>
                          </blockquote>
                          <br>
                          ...     id = PrimaryKey(int, auto=True)<br>
                          <br>
                          ...     email   = Optional(str)<br>
                          <br>
                          ...     date = Required('date')<br>
                          <br>
                          ...<br>
                          <br>
                          <blockquote class="gmail_quote"
                            style="margin:0 0 0 .8ex;border-left:1px
                            #ccc solid;padding-left:1ex">
                            <blockquote class="gmail_quote"
                              style="margin:0 0 0 .8ex;border-left:1px
                              #ccc solid;padding-left:1ex">
                              <blockquote class="gmail_quote"
                                style="margin:0 0 0 .8ex;border-left:1px
                                #ccc solid;padding-left:1ex">
                                sql_debug(True)<br>
                              </blockquote>
                            </blockquote>
                          </blockquote>
                          <br>
                          <blockquote class="gmail_quote"
                            style="margin:0 0 0 .8ex;border-left:1px
                            #ccc solid;padding-left:1ex">
                            <blockquote class="gmail_quote"
                              style="margin:0 0 0 .8ex;border-left:1px
                              #ccc solid;padding-left:1ex">
                              <blockquote class="gmail_quote"
                                style="margin:0 0 0 .8ex;border-left:1px
                                #ccc solid;padding-left:1ex">
                                db.generate_mapping(create_tables=True)<br>
                              </blockquote>
                            </blockquote>
                          </blockquote>
                          <br>
                          Traceback (most recent call last):<br>
                          <br>
                            File "<stdin>", line 1, in
                          <module><br>
                          <br>
                            File "<auto generated wrapper of
                          generate_mapping() function>", line 2, in
                          generate_mapping<br>
                          <br>
                            File
                          "/usr/local/lib/python2.7/dist-packages/pony/orm/core.py",
                          line 2698, in _resolve_attr_types_<br>
                          <br>
                              throw(ERDiagramError, 'Entity definition
                          %s was not found' % py_type)<br>
                          <br>
                            File
                          "/usr/local/lib/python2.7/dist-packages/pony/utils.py",
                          line 126, in throw<br>
                          <br>
                              raise exc  # Set
                          "pony.options.CUT_TRACEBACK = False" to see
                          full traceback<br>
                          <br>
                          pony.orm.core.ERDiagramError: Entity
                          definition date was not found<br>
                          <br>
                          <br>
                          So database can't be created after all.<br>
                          <br>
                          Pony version installed with pip:<br>
                          <br>
                          pony                      - Pony
                          Object-Relational Mapper<br>
                          <br>
                            INSTALLED: 0.5.1<br>
                          <br>
                            LATEST:    0.5-beta<br>
                          <br>
                          Is it a bug or something? How i should create
                          a datefield with Pony ?<br>
                          <br>
                          I've couldn't create a table with several
                          tables with Pony until i commented out all
                          datefields strings from the code. So Pony
                          works if i don't use datetime fields.<br>
                          <br>
                          <br>
                          -- <br>
                          С уважением,<br>
                          Бажов Вадим,<br>
                          Инженер отдела технической поддержки,<br>
                          Компания Айдеко<br>
                          --<br>
                          Телефоны: +7 (495) 987-32-70; +7 (495)
                          662-87-34 (тех. поддержка); +7 (343)
                          345-15-75; Факс: +7 (343) 383-75-13<br>
                          <br>
                          Электронная почта:<br>
                          Вопросы по приобретению: <a
                            moz-do-not-send="true"
                            href="mailto:sales@ideco.ru" target="_blank">sales@ideco.ru</a><br>
                          Технические вопросы: <a
                            moz-do-not-send="true"
                            href="mailto:support@ideco.ru"
                            target="_blank">support@ideco.ru</a><br>
                          Партнерство: <a moz-do-not-send="true"
                            href="mailto:partners@ideco.ru"
                            target="_blank">partners@ideco.ru</a><br>
                          Общие вопросы: <a moz-do-not-send="true"
                            href="mailto:info@ideco.ru" target="_blank">info@ideco.ru</a><br>
                          <br>
                          Сайт: <a moz-do-not-send="true"
                            href="http://www.ideco.ru/" target="_blank">http://www.ideco.ru/</a><br>
                          Форум: <a moz-do-not-send="true"
                            href="http://www.ideco.ru/forum/"
                            target="_blank">http://www.ideco.ru/forum/</a><br>
                          <br>
_______________________________________________<br>
                          ponyorm-list mailing list<br>
                          <a moz-do-not-send="true"
                            href="mailto:ponyorm-list@ponyorm.org"
                            target="_blank">ponyorm-list@ponyorm.org</a><br>
                          <a moz-do-not-send="true"
                            href="/ponyorm-list"
                            target="_blank">/ponyorm-list</a><br>
                        </blockquote>
                      </div>
                      <br>
                    </div>
                    <br>
                    <fieldset></fieldset>
                    <br>
                    <pre>_______________________________________________
ponyorm-list mailing list
<a moz-do-not-send="true" href="mailto:ponyorm-list@ponyorm.org" target="_blank">ponyorm-list@ponyorm.org</a>
<a moz-do-not-send="true" href="/ponyorm-list" target="_blank">/ponyorm-list</a>
</pre>
                  </blockquote>
                  <br>
                  <pre cols="72">-- 
С уважением,
Бажов Вадим,
Инженер отдела технической поддержки,
Компания Айдеко
--
Телефоны: +7 (495) 987-32-70; +7 (495) 662-87-34 (тех. поддержка); +7 (343) 345-15-75; Факс: +7 (343) 383-75-13 

Электронная почта: 
Вопросы по приобретению: <a moz-do-not-send="true" href="mailto:sales@ideco.ru" target="_blank">sales@ideco.ru</a> 
Технические вопросы: <a moz-do-not-send="true" href="mailto:support@ideco.ru" target="_blank">support@ideco.ru</a>
Партнерство: <a moz-do-not-send="true" href="mailto:partners@ideco.ru" target="_blank">partners@ideco.ru</a> 
Общие вопросы: <a moz-do-not-send="true" href="mailto:info@ideco.ru" target="_blank">info@ideco.ru</a>

Сайт: <a moz-do-not-send="true" href="http://www.ideco.ru/" target="_blank">http://www.ideco.ru/</a>
Форум: <a moz-do-not-send="true" href="http://www.ideco.ru/forum/" target="_blank">http://www.ideco.ru/forum/</a> 

</pre>
                </div>
              </div>
            </div>
            <br>
            _______________________________________________<br>
            ponyorm-list mailing list<br>
            <a moz-do-not-send="true"
              href="mailto:ponyorm-list@ponyorm.org">ponyorm-list@ponyorm.org</a><br>
            <a moz-do-not-send="true"
              href="/ponyorm-list"
              target="_blank">/ponyorm-list</a><br>
            <br>
          </blockquote>
        </div>
        <br>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
ponyorm-list mailing list
<a class="moz-txt-link-abbreviated" href="mailto:ponyorm-list@ponyorm.org">ponyorm-list@ponyorm.org</a>
<a class="moz-txt-link-freetext" href="/ponyorm-list">/ponyorm-list</a>
</pre>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
С уважением,
Бажов Вадим,
Инженер отдела технической поддержки,
Компания Айдеко
--
Телефоны: +7 (495) 987-32-70; +7 (495) 662-87-34 (тех. поддержка); +7 (343) 345-15-75; Факс: +7 (343) 383-75-13 

Электронная почта: 
Вопросы по приобретению: <a class="moz-txt-link-abbreviated" href="mailto:sales@ideco.ru">sales@ideco.ru</a> 
Технические вопросы: <a class="moz-txt-link-abbreviated" href="mailto:support@ideco.ru">support@ideco.ru</a>
Партнерство: <a class="moz-txt-link-abbreviated" href="mailto:partners@ideco.ru">partners@ideco.ru</a> 
Общие вопросы: <a class="moz-txt-link-abbreviated" href="mailto:info@ideco.ru">info@ideco.ru</a>

Сайт: <a class="moz-txt-link-freetext" href="http://www.ideco.ru/">http://www.ideco.ru/</a>
Форум: <a class="moz-txt-link-freetext" href="http://www.ideco.ru/forum/">http://www.ideco.ru/forum/</a> 

</pre>
  </body>
</html>