当前位置: 首页>>代码示例>>Python>>正文


Python Search.eval方法代码示例

本文整理汇总了Python中pyasm.search.Search.eval方法的典型用法代码示例。如果您正苦于以下问题:Python Search.eval方法的具体用法?Python Search.eval怎么用?Python Search.eval使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyasm.search.Search的用法示例。


在下文中一共展示了Search.eval方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _test_time

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import eval [as 别名]
    def _test_time(my):
        """ test timezone related behavior"""
        sobject = SearchType.create("sthpw/task")
        sobject.set_value("project_code", "unittest")
        sobject.set_value("bid_start_date", "2014-11-11 05:00:00")
        time = sobject.get_value("bid_start_date")
        my.assertEquals(time, "2014-11-11 05:00:00")

        sobject.commit()

        time = sobject.get_value("bid_start_date")
        my.assertEquals(time, "2014-11-11 05:00:00")
        from pyasm.search import DbContainer

        sql = DbContainer.get("sthpw")
        db_value = sql.do_query("SELECT bid_start_date from task where id = %s" % sobject.get_id())

        # 2014-11-11 00:00:00 is actually written to the database
        my.assertEquals(db_value[0][0].strftime("%Y-%m-%d %H:%M:%S %Z"), "2014-11-11 00:00:00 ")

        # an sType specified without a project but with an id could be a common human error
        # but it should handle that fine
        obj1 = Search.eval('@SOBJECT(unittest/person?project=unittest["id", "%s"])' % sobject.get_id(), single=True)
        obj2 = Search.eval('@SOBJECT(unittest/person?id=2["id", "%s"])' % sobject.get_id(), single=True)
        obj3 = Search.eval('@SOBJECT(sthpw/task?id=2["id", "%s"])' % sobject.get_id(), single=True)
        task = Search.eval('@SOBJECT(sthpw/task["id", "%s"])' % sobject.get_id(), single=True)

        # EST and GMT diff is 5 hours
        my.assertEquals(task.get_value("bid_start_date"), "2014-11-11 05:00:00")
开发者ID:pombredanne,项目名称:TACTIC,代码行数:31,代码来源:biz_test.py

示例2: get_mail_users

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import eval [as 别名]
    def get_mail_users(my, column):
        # mail groups
        recipients = set()

        expr = my.notification.get_value(column, no_exception=True)
        if expr:
            sudo = Sudo()
            # Introduce an environment that can be reflected
            env = {
                'sobject': my.sobject
            }

            #if expr.startswith("@"):
            #    logins = Search.eval(expr, list=True, env_sobjects=env)
            #else:
            parts = expr.split("\n")

            # go through each login and evaluate each
            logins = []
            for part in parts:
                if part.startswith("@") or part.startswith("{"):
                    results = Search.eval(part, list=True, env_sobjects=env)
                    # clear the container after each expression eval
                    ExpressionParser.clear_cache()
                    # these can just be login names, get the actual Logins
                    if results:
                        if isinstance(results[0], basestring):
                            login_sobjs = Search.eval("@SOBJECT(sthpw/login['login','in','%s'])" %'|'.join(results),  list=True)
                        
                            login_list = SObject.get_values(login_sobjs, 'login')
                            
                            for result in results:
                                # the original result could be an email address already
                                if result not in login_list:
                                    logins.append(result)
                                
                            if login_sobjs:
                                logins.extend( login_sobjs )
                        else:
                            logins.extend(results)

                elif part.find("@") != -1:
                    # this is just an email address
                    logins.append( part )
                elif part:
                    # this is a group
                    group = LoginGroup.get_by_code(part)
                    if group:
                        logins.extend( group.get_logins() )

            del sudo
        else:
            notification_id = my.notification.get_id()
            logins = GroupNotification.get_logins_by_id(notification_id)

        for login in logins:
            recipients.add(login) 

        return recipients
开发者ID:CeltonMcGrath,项目名称:TACTIC,代码行数:61,代码来源:email_handler.py

示例3: execute

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import eval [as 别名]
    def execute(self):

        trigger_sobj = self.get_trigger_sobj()
        data = trigger_sobj.get_value("data")
        #data = """
        #{ "columns": [column1, column2]
        #"""

        data = jsonloads(data)

        column = data.get('column')
        src_status = data.get('src_status')

        

        item = self.get_caller()


        if isinstance(item, SObject):
            if isinstance(item, Task):
                if src_status != None:
                    if item.get_value("status") != src_status:
                        return

                item.set_now(column)
                item.commit()

            #Item can be a note when trigger input is adding or modifying notes
            else:
                process = item.get_value('process')
                expr = '@SOBJECT(parent.sthpw/task["process","%s"])'%process
                tasks = Search.eval(expr, sobjects=[item])

                if tasks:
                    for task in tasks:
                        task.set_now(column)
                        task.commit()

        #item can be a command such as check-in                 
        else:
            if hasattr(item, 'process'):
                process = item.process
                expr = '@SOBJECT(sthpw/task["process","%s"])'%process
                tasks = Search.eval(expr, sobjects=[item.sobject])

                if tasks:
                    for task in tasks:
                        task.set_now(column)
                        task.commit()
开发者ID:mincau,项目名称:TACTIC,代码行数:51,代码来源:pipeline_task_trigger.py

示例4: get_display

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import eval [as 别名]
    def get_display(my):

        my.context = ''
        sobject = my.get_current_sobject()

        if sobject.get_base_search_type() in ['sthpw/task', 'sthpw/note']:
            my.process = sobject.get_value('process')
            my.context = sobject.get_value('context')
            if not my.process:
                my.process = ''


            sobject_mode = my.kwargs.get("sobject_mode")
            if not sobject_mode:
                sobject_mode = "parent"
            #sobject_mode = "connect"
            if sobject_mode == "parent":
                parent = sobject.get_parent()
            elif sobject_mode == "connect":
                parent = Search.eval("@SOBJECT(connect)", sobject, single=True)
            elif sobject_mode == "expression":
                expression = "???"
                parent = Search.eval("@SOBJECT(connect)", sobject, single=True)
            else:
                parent = sobject

            if not parent:
                return DivWdg()

            search_key = SearchKey.get_by_sobject(parent)
        else:
            my.process = my.get_option('process')
            if not my.process:
                my.process = "publish"
            search_key = SearchKey.get_by_sobject(sobject)


        #my.behavior['process'] = my.process
        #my.behavior['context'] = my.context
        #my.behavior['search_key'] = search_key

        # set the atrs
        div = super(CheckinButtonElementWdg, my).get_display()
        div.add_attr("spt_process", my.process)
        div.add_attr("spt_context", my.context)
        div.add_attr("spt_search_key", search_key)

        return div
开发者ID:nuxping,项目名称:TACTIC,代码行数:50,代码来源:table_element_wdg.py

示例5: _test_time

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import eval [as 别名]
    def _test_time(my):
        ''' test timezone related behavior'''
        sobject = SearchType.create('sthpw/task')
        sobject.set_value('project_code','unittest')
        sobject.set_value('bid_start_date', '2014-11-11 05:00:00')
        time = sobject.get_value('bid_start_date')
        my.assertEquals(time, '2014-11-11 05:00:00')

        sobject.commit()

        time = sobject.get_value('bid_start_date')
        my.assertEquals(time, '2014-11-11 05:00:00')
        from pyasm.search import DbContainer
        sql = DbContainer.get('sthpw')
        db_value = sql.do_query('SELECT bid_start_date from task where id = %s'%sobject.get_id())
        
        # 2014-11-11 00:00:00 is actually written to the database
        my.assertEquals(db_value[0][0].strftime('%Y-%m-%d %H:%M:%S %Z'), '2014-11-11 00:00:00 ')
        
        # an sType specified without a project but with an id could be a common human error
        # but it should handle that fine
        obj1 = Search.eval('@SOBJECT(unittest/person?project=unittest["id", "%s"])'%sobject.get_id(), single=True)
        obj2= Search.eval('@SOBJECT(unittest/person?id=2["id", "%s"])'%sobject.get_id(), single=True)
        obj3 = Search.eval('@SOBJECT(sthpw/task?id=2["id", "%s"])'%sobject.get_id(), single=True)
        task = Search.eval('@SOBJECT(sthpw/task["id", "%s"])'%sobject.get_id(), single=True)

        # EST and GMT diff is 5 hours
        my.assertEquals(task.get_value('bid_start_date'), '2014-11-11 05:00:00')


        # test NOW() auto conversion
        sobj = SearchType.create('sthpw/note')
        sobj.set_value('process','TEST')
        sobj.set_value('note','123')
        my.assertEquals(sobj.get_value('timestamp'), "")
        sobj.commit()

        # this is local commited time converted back to GMT
        committed_time = sobj.get_value('timestamp')
        
        from dateutil import parser
        committed_time = parser.parse(committed_time)

        from pyasm.common import SPTDate
        now = SPTDate.now()
        diff = now - committed_time
        # should be roughly the same minute, not hours apart
        my.assertEquals(diff.seconds < 60, True)
开发者ID:0-T-0,项目名称:TACTIC,代码行数:50,代码来源:biz_test.py

示例6: get_display

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import eval [as 别名]
    def get_display(my):

        sobject = my.get_current_sobject()

        name = my.get_name()

        top = DivWdg()

        if sobject.is_insert():
            top.add_style("opacity: 0.3")
        else:
            # this gives the swap it's behaviors, so will be disabled
            # on insert
            top.add_class("spt_hidden_row_%s" % name)


        label = my.get_option("label")
        if label:
            label = Search.eval(label, sobject)
        else:
            label = None
        icon = my.get_option("icon")

        swap = SwapDisplayWdg(title=label, icon=icon, show_border=True)
        swap.set_behavior_top(my.layout)

        top.add(swap)

        return top
开发者ID:funic,项目名称:TACTIC,代码行数:31,代码来源:hidden_row_element_wdg.py

示例7: get_item_div

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import eval [as 别名]
    def get_item_div(my, sobjects, related_type):
        item_div = DivWdg()
        item_div.add_style("margin: 15px 10px")

        sobject = sobjects[0]

        checkbox = CheckboxWdg('related_types')
        item_div.add(checkbox)
        checkbox.set_attr("value", related_type)
        if related_type in ["sthpw/snapshot", "sthpw/file"]:
            checkbox.set_checked()

        item_div.add(" ")
        item_div.add(related_type)
        item_div.add(": ")

        if related_type.startswith("@SOBJECT"):
            related_sobjects = Search.eval(related_type, [sobject], list=True)
        else:
            try:
                related_sobjects = []
                for sobject in sobjects:
                    sobjs = sobject.get_related_sobjects(related_type)
                    related_sobjects.extend(sobjs)

            except Exception, e:
                print "WARNING: ", e
                related_sobjects = []
开发者ID:asmboom,项目名称:TACTIC,代码行数:30,代码来源:delete_wdg.py

示例8: get_display

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import eval [as 别名]
    def get_display(my):

        top = my.top
        top.add_style("position: relative")

        width = my.kwargs.get("width")
        if not width:
            width = "200px"
        height = my.kwargs.get("height")
        if not height:
            height = "100px"
        label = my.kwargs.get("label")
        if label and my.sobjects:
            label = Search.eval(label, my.sobjects[0], single=True)
        if not label:
            label = "No Label"

        top.add_border()
        top.add_style("width: %s" % width)
        top.add_style("height: %s" % height)

        if label:
            label_div = DivWdg()
            top.add(label_div)
            label_div.add(label)

            label_div.add_style("position: absolute")
            label_div.add_style("top: -13px")
            label_div.add_style("left: 6px")

        return top
开发者ID:hellios78,项目名称:TACTIC,代码行数:33,代码来源:freeform_layout_wdg.py

示例9: create

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import eval [as 别名]
    def create(self):

        project = Project.get_by_code(self.project_code)
        if project:

            self.delete()

        print "Setting up a basic Sample3d project"

        # create the project
        create_cmd = CreateProjectCmd(project_code=self.project_code, project_title="Sample 3D") #, project_type="unittest")
        create_cmd.execute()

        # install the unittest plugin
        installer = PluginInstaller(relative_dir="TACTIC/internal/sample3d", verbose=False)
        installer.execute()

        # add 30 shots
        for x in xrange(30):
            shot = SearchType.create("prod/shot")
            shot.set_value('name','shot%s'%x)
            shot.set_value('sequence_code','SEQ_01')
            shot.commit(triggers=False)

        if not Search.eval("@SOBJECT(prod/sequence['code','SEQ_01'])"):
            seq = SearchType.create("prod/sequence")
            seq.set_value('code','SEQ_01')
            seq.commit(triggers=False)
开发者ID:mincau,项目名称:TACTIC,代码行数:30,代码来源:environment.py

示例10: add_user_info

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import eval [as 别名]
    def add_user_info(my, login, password):
        '''update password, first and last name  in tactic account'''
        if not my.internal:
            return

        encrypted = hashlib.md5(password).hexdigest()
        login.set_value("password", encrypted)
        first = ''
        last = ''
        if len(my.login_name.split('.')) > 1:
            first, last = my.login_name.split('.',1)
        else:
            first = my.login_name.split('.')[0]
        if len(first) > 0:
            first = '%s%s' % (first[0].upper(), first[1:])
        if len(last) > 0:
            last = '%s%s' % (last[0].upper(), last[1:])
        
        login.set_value("first_name", first)
        login.set_value("last_name", last)
        login.set_value("license_type", 'user')
        login.set_value("location", "internal")
        login.set_value("email", '%[email protected]'%my.login_name)

        # Hard code adding this user to a group so he can view projects
        # this can't be done in a trigger yet
        login_in_group = Search.eval("@SOBJECT(sthpw/login_in_group['login','%s']['login_group','user'])" %my.login_name, single=True)
        if not login_in_group:
            login.add_to_group("user")
开发者ID:2gDigitalPost,项目名称:custom,代码行数:31,代码来源:ldap_authenticate.py

示例11: get_display

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import eval [as 别名]
    def get_display(self):
        top = self.top
        self.result = ''

        sobject = self.get_current_sobject()
        
        current_value = sobject.get_value(self.get_name(), no_exception=True)
        if current_value:
            top.add(current_value)
            return top

        result = self.get_result(sobject)

        if result == "":
            return top

        sobject.set_value(self.get_name(), result, temp=True)
        display_format = self.get_option("display_format")
        if display_format:
            expr = "@FORMAT(@GET(.%s), '%s')" % (self.get_name(), display_format)
            result = Search.eval(expr, sobject, single=True)

        self.result = result
        
        top.add(result)
        return top
开发者ID:mincau,项目名称:TACTIC,代码行数:28,代码来源:python_element_wdg.py

示例12: _add_css_style

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import eval [as 别名]
    def _add_css_style(my, element, prefix, name=None, value=None):
        # skip the edit/ insert row
        #sobject = my.get_current_sobject()
        #if not sobject or sobject.get_id() == -1:
        #    return

        if value is None:
            value = my.get_value()
        if name is None:
            name = my.get_name()

        if not value:
            value = 0
        
        vars = {
            "ELEMENT":  name,
            "VALUE":    value
        }

        for key, expr in my.kwargs.items():
            if not key.startswith(prefix):
                continue

            if expr:
                sobject = my.get_current_sobject()
                prefix, property = key.split("_", 1)
                value = Search.eval(expr, sobject, vars=vars)
                if value:
                    element.add_style("%s: %s" % (property, value) )
开发者ID:davidsouthpaw,项目名称:TACTIC,代码行数:31,代码来源:base_table_element_wdg.py

示例13: get_group_bottom_wdg

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import eval [as 别名]
    def get_group_bottom_wdg(self, sobjects):

        summary = self.get_option("total_summary")
        if not summary:
            return None

        # parse the expression
        self.vars = self.get_vars()
 
        expression, title = self.get_expression(summary)
        try:
            result = Search.eval(expression, sobjects=sobjects, vars=self.vars)
        except Exception as e:
            print("WARNING: ", e.message)
            result = "Calculation Error"
            title = ''
        """
        widget_type = self.get_option("type")
        
        if widget_type in ['date','time']:
            name = self.get_name()
            if not SObject.is_day_column(name):
                result = SPTDate.convert_to_local(result)
                result= str(result)
        """
        format = self.get_option('format')
        formatted_result = self.get_format_value( result, format )

        div = DivWdg()
        div.add(str(formatted_result))
        div.add_style("text-align: right")

        return div, result
开发者ID:mincau,项目名称:TACTIC,代码行数:35,代码来源:format_element_wdg.py

示例14: get_data

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import eval [as 别名]
    def get_data(my, sobject):

        values = []
        labels = []

        if not my.config:
            return values, labels



        for element in my.elements:
            options = my.config.get_display_options(element)
            attrs = my.config.get_element_attributes(element)


            label = attrs.get('title')
            if not label:
                label = Common.get_display_title(element)
            labels.append(label)



            expression = options.get("expression")
            if not expression:
                value = 0
            else:
                value = Search.eval(expression, sobject, single=True)

            values.append(value)        


        return values, labels
开发者ID:0-T-0,项目名称:TACTIC,代码行数:34,代码来源:task_status_report_wdg.py

示例15: import_default_side_bar

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import eval [as 别名]
    def import_default_side_bar(self):
        code = Search.eval("@GET(config/widget_config['code','WIDGET_CONFIG000000'].code)", single=True)
        if code:
            print "Default side bar already exists!"
            return

        
        project_code = self.kwargs.get('project_code')
        # It looks like project=XXX on SearchType.create does not work
        Project.set_project(project_code)
        config = SearchType.create("config/widget_config?project=%s" % project_code)
        config.set_value("code", "WIDGET_CONFIG000000")
        config.set_value("category", "SideBarWdg")
        config.set_value("search_type", "SideBarWdg")
        config.set_value("view", "project_view")
        
        xml = '''<?xml version='1.0' encoding='UTF-8'?>
<config>
  <project_view>
    <element name='_home' title='Examples'/>
  </project_view>
</config>
'''
        config.set_value("config", xml)

        config.commit()
开发者ID:mincau,项目名称:TACTIC,代码行数:28,代码来源:create_project_cmd.py


注:本文中的pyasm.search.Search.eval方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。